include/svx/srchdlg.hxx       |    2 ++
 svx/source/dialog/srchdlg.cxx |   30 +++++++++++++++++++++---------
 2 files changed, 23 insertions(+), 9 deletions(-)

New commits:
commit 10ed9763b5383d69118b582082e00541ab94d2ef
Author:     Caolán McNamara <[email protected]>
AuthorDate: Mon Jan 19 16:46:19 2026 +0000
Commit:     Miklos Vajna <[email protected]>
CommitDate: Wed Jan 21 09:30:35 2026 +0100

    make search SimilarityDialog async
    
    Change-Id: Ib8a704f929d557b7ceb45762fbcfe452346ea727
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/197599
    Reviewed-by: Miklos Vajna <[email protected]>
    Tested-by: Jenkins CollaboraOffice <[email protected]>

diff --git a/include/svx/srchdlg.hxx b/include/svx/srchdlg.hxx
index 2f9cdd792848..cf00d9a03b4e 100644
--- a/include/svx/srchdlg.hxx
+++ b/include/svx/srchdlg.hxx
@@ -278,6 +278,8 @@ private:
     SVX_DLLPRIVATE bool IsOtherOptionsExpanded() const;
 
     SVX_DLLPRIVATE short executeSubDialog(VclAbstractDialog * dialog);
+    SVX_DLLPRIVATE void executeSubDialog(VclPtr<VclAbstractDialog> dialog,
+                                         const std::function<void(sal_Int32)>& 
func);
 
     DECL_DLLPRIVATE_LINK(PresentTimeoutHdl_Impl, Timer*, void);
 };
diff --git a/svx/source/dialog/srchdlg.cxx b/svx/source/dialog/srchdlg.cxx
index a08dbd88e012..b602f0cb7ae0 100644
--- a/svx/source/dialog/srchdlg.cxx
+++ b/svx/source/dialog/srchdlg.cxx
@@ -1424,19 +1424,20 @@ IMPL_LINK(SvxSearchDialog, CommandHdl_Impl, 
weld::Button&, rBtn, void)
     else if (&rBtn == m_xSimilarityBtn.get())
     {
         SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
-        ScopedVclPtr<AbstractSvxSearchSimilarityDialog> 
pDlg(pFact->CreateSvxSearchSimilarityDialog(m_xDialog.get(),
+        VclPtr<AbstractSvxSearchSimilarityDialog> 
pDlg(pFact->CreateSvxSearchSimilarityDialog(m_xDialog.get(),
                                                                     
pSearchItem->IsLEVRelaxed(),
                                                                     
pSearchItem->GetLEVOther(),
                                                                     
pSearchItem->GetLEVShorter(),
                                                                     
pSearchItem->GetLEVLonger() ));
-        if ( executeSubDialog(pDlg.get()) == RET_OK )
-        {
-            pSearchItem->SetLEVRelaxed( pDlg->IsRelaxed() );
-            pSearchItem->SetLEVOther( pDlg->GetOther() );
-            pSearchItem->SetLEVShorter( pDlg->GetShorter() );
-            pSearchItem->SetLEVLonger( pDlg->GetLonger() );
-            SaveToModule_Impl();
-        }
+        executeSubDialog(pDlg, [pDlg, this](sal_Int32 nResult) {
+            if (nResult == RET_OK ) {
+                pSearchItem->SetLEVRelaxed( pDlg->IsRelaxed() );
+                pSearchItem->SetLEVOther( pDlg->GetOther() );
+                pSearchItem->SetLEVShorter( pDlg->GetShorter() );
+                pSearchItem->SetLEVLonger( pDlg->GetLonger() );
+                SaveToModule_Impl();
+            };
+        });
     }
     else if (&rBtn == m_xJapOptionsBtn.get())
     {
@@ -2365,6 +2366,17 @@ short 
SvxSearchDialog::executeSubDialog(VclAbstractDialog * dialog) {
     return dialog->Execute();
 }
 
+void SvxSearchDialog::executeSubDialog(VclPtr<VclAbstractDialog> dialog, const 
std::function<void(sal_Int32)>& func) {
+    assert(!m_executingSubDialog);
+    m_executingSubDialog = true;
+
+    dialog->StartExecuteAsync([dialog, func, this](sal_Int32 nResult) {
+        func(nResult);
+        dialog->disposeOnce();
+        m_executingSubDialog = false;
+    });
+}
+
 SFX_IMPL_CHILDWINDOW_WITHID(SvxSearchDialogWrapper, SID_SEARCH_DLG);
 
 

Reply via email to