sw/source/ui/dialog/swdlgfact.cxx | 5 +++++ sw/source/ui/dialog/swdlgfact.hxx | 3 ++- sw/source/ui/misc/bookmark.cxx | 23 +++++++++++++---------- sw/source/uibase/inc/swrenamexnameddlg.hxx | 4 ++-- 4 files changed, 22 insertions(+), 13 deletions(-)
New commits: commit 896d6303040cb86813f1c5bc06bb830f512f3f22 Author: Antony <antonydas.na...@collabora.com> AuthorDate: Thu Mar 14 15:24:11 2024 +0530 Commit: Caolán McNamara <caolan.mcnam...@collabora.com> CommitDate: Wed Mar 27 12:15:51 2024 +0100 cool#8456 : Convert bookmark rename dialog to async * Changed bookmark rename dialog from synchronous to asynchronous execution. * Removed the reference operator from variables m_xNamed and m_xNameAccess declared in swrenamexnameddlg.hxx to prevent use-after-free Change-Id: I2e4e777c5c56137504b646bdbe82e265ef73b2ef Reviewed-on: https://gerrit.libreoffice.org/c/core/+/164803 Tested-by: Jenkins CollaboraOffice <jenkinscollaboraoff...@gmail.com> Reviewed-by: Miklos Vajna <vmik...@collabora.com> (cherry picked from commit 1222d98eaad463e35286f215b3bdeb909ea155bf) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/165323 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolan.mcnam...@collabora.com> diff --git a/sw/source/ui/dialog/swdlgfact.cxx b/sw/source/ui/dialog/swdlgfact.cxx index 7333b4ebefcd..8275f5e65a1d 100644 --- a/sw/source/ui/dialog/swdlgfact.cxx +++ b/sw/source/ui/dialog/swdlgfact.cxx @@ -295,6 +295,11 @@ short AbstractSwRenameXNamedDlg_Impl::Execute() return m_xDlg->run(); } +bool AbstractSwRenameXNamedDlg_Impl::StartExecuteAsync(VclAbstractDialog::AsyncContext& rCtx) +{ + return weld::DialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); +} + bool AbstractSwContentControlListItemDlg_Impl::StartExecuteAsync(VclAbstractDialog::AsyncContext& rCtx) { return weld::DialogController::runAsync(m_xDlg, rCtx.maEndDialogFn); diff --git a/sw/source/ui/dialog/swdlgfact.hxx b/sw/source/ui/dialog/swdlgfact.hxx index 100833f79f67..5d8035b6bfcd 100644 --- a/sw/source/ui/dialog/swdlgfact.hxx +++ b/sw/source/ui/dialog/swdlgfact.hxx @@ -482,13 +482,14 @@ public: class AbstractSwRenameXNamedDlg_Impl : public AbstractSwRenameXNamedDlg { - std::unique_ptr<SwRenameXNamedDlg> m_xDlg; + std::shared_ptr<SwRenameXNamedDlg> m_xDlg; public: explicit AbstractSwRenameXNamedDlg_Impl(std::unique_ptr<SwRenameXNamedDlg> p) : m_xDlg(std::move(p)) { } virtual short Execute() override; + virtual bool StartExecuteAsync(VclAbstractDialog::AsyncContext &rCtx) override; virtual void SetForbiddenChars( const OUString& rSet ) override; virtual void SetAlternativeAccess( css::uno::Reference< css::container::XNameAccess > & xSecond, diff --git a/sw/source/ui/misc/bookmark.cxx b/sw/source/ui/misc/bookmark.cxx index 6431809c9569..40cebea7ead7 100644 --- a/sw/source/ui/misc/bookmark.cxx +++ b/sw/source/ui/misc/bookmark.cxx @@ -215,20 +215,23 @@ IMPL_LINK_NOARG(SwInsertBookmarkDlg, RenameHdl, weld::Button&, void) aObj >>= xTmp; uno::Reference<container::XNamed> xNamed(xTmp, uno::UNO_QUERY); SwAbstractDialogFactory& rFact = swui::GetFactory(); - ScopedVclPtr<AbstractSwRenameXNamedDlg> pDlg( + VclPtr<AbstractSwRenameXNamedDlg> pDlg( rFact.CreateSwRenameXNamedDlg(m_xDialog.get(), xNamed, xNameAccess)); pDlg->SetForbiddenChars(BookmarkTable::aForbiddenChars + OUStringChar(BookmarkTable::s_cSeparator)); - if (pDlg->Execute()) - { - ValidateBookmarks(); - m_xDeleteBtn->set_sensitive(false); - m_xGotoBtn->set_sensitive(false); - m_xEditTextBtn->set_sensitive(false); - m_xRenameBtn->set_sensitive(false); - m_xInsertBtn->set_sensitive(false); - } + pDlg->StartExecuteAsync([pDlg, this](sal_Int32 nResult) { + if (nResult == RET_OK) + { + ValidateBookmarks(); + m_xDeleteBtn->set_sensitive(false); + m_xGotoBtn->set_sensitive(false); + m_xEditTextBtn->set_sensitive(false); + m_xRenameBtn->set_sensitive(false); + m_xInsertBtn->set_sensitive(false); + } + pDlg->disposeOnce(); + }); } // callback to an insert button. Inserts a new text mark to the current position. diff --git a/sw/source/uibase/inc/swrenamexnameddlg.hxx b/sw/source/uibase/inc/swrenamexnameddlg.hxx index 4575df5d414c..4702f1ac20bc 100644 --- a/sw/source/uibase/inc/swrenamexnameddlg.hxx +++ b/sw/source/uibase/inc/swrenamexnameddlg.hxx @@ -25,8 +25,8 @@ class SwRenameXNamedDlg final : public weld::GenericDialogController { - css::uno::Reference< css::container::XNamed > & m_xNamed; - css::uno::Reference< css::container::XNameAccess > & m_xNameAccess; + css::uno::Reference< css::container::XNamed > m_xNamed; + css::uno::Reference< css::container::XNameAccess > m_xNameAccess; css::uno::Reference< css::container::XNameAccess > m_xSecondAccess; css::uno::Reference< css::container::XNameAccess > m_xThirdAccess;