summaryrefslogtreecommitdiff
path: root/sw
diff options
context:
space:
mode:
authorJan Holesovsky <kendy@collabora.com>2018-01-24 12:47:20 +0100
committerJan Holesovsky <kendy@collabora.com>2018-01-25 10:04:19 +0100
commit3a9c80c4cdcd4387ff07ddd4347973aaa7df9860 (patch)
tree7d42d880f5529ced6fc0808bfe5a1b17f08dd829 /sw
parent4158cbabd6587431c89f288abea6080947d9f421 (diff)
lokdialog: Convert the Tools -> Thesaurus... to async exec.
Change-Id: Iee25e3fa970e5e28a14a95cfc8804ce944d4f762 Reviewed-on: https://gerrit.libreoffice.org/48497 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'sw')
-rw-r--r--sw/source/uibase/uiview/viewling.cxx23
1 files changed, 16 insertions, 7 deletions
diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx
index 70dbdb94fa2e..cb7f8b11c546 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -28,6 +28,7 @@
#include <comphelper/processfactory.hxx>
#include <comphelper/propertyvalue.hxx>
#include <comphelper/propertysequence.hxx>
+#include <comphelper/scopeguard.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/msgbox.hxx>
#include <svtools/ehdl.hxx>
@@ -546,8 +547,9 @@ void SwView::StartThesaurus()
}
SwViewOption* pVOpt = const_cast<SwViewOption*>(m_pWrtShell->GetViewOptions());
- bool bOldIdle = pVOpt->IsIdle();
+ const bool bOldIdle = pVOpt->IsIdle();
pVOpt->SetIdle( false );
+ comphelper::ScopeGuard guard([&]() { pVOpt->SetIdle(bOldIdle); }); // restore when leaving scope
// get initial LookUp text
const bool bSelection = static_cast<SwCursorShell*>(m_pWrtShell)->HasSelection();
@@ -559,20 +561,27 @@ void SwView::StartThesaurus()
SpellError( eLang );
else
{
- ScopedVclPtr<AbstractThesaurusDialog> pDlg;
+ VclPtr<AbstractThesaurusDialog> pDlg;
// create dialog
{ //Scope for SwWait-Object
SwWait aWait( *GetDocShell(), true );
// load library with dialog only on demand ...
SvxAbstractDialogFactory* pFact = SvxAbstractDialogFactory::Create();
- pDlg.disposeAndReset(pFact->CreateThesaurusDialog( &GetEditWin(), xThes, aTmp, eLang ));
+ pDlg.reset(pFact->CreateThesaurusDialog(&GetEditWin(), xThes, aTmp, eLang));
}
- if ( pDlg->Execute()== RET_OK )
- InsertThesaurusSynonym( pDlg->GetWord(), aTmp, bSelection );
- }
+ if (pDlg)
+ {
+ guard.dismiss(); // ignore, we'll call SetIdle() explictly after the dialog ends
- pVOpt->SetIdle( bOldIdle );
+ pDlg->StartExecuteAsync([=](sal_Int32 nResult){
+ if (nResult == RET_OK )
+ InsertThesaurusSynonym(pDlg->GetWord(), aTmp, bSelection);
+
+ pVOpt->SetIdle(bOldIdle);
+ });
+ }
+ }
}
// Offer online suggestions