[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-5.3' - sw/source
Jan Holesovsky
kendy at collabora.com
Wed Jan 24 14:00:17 UTC 2018
sw/source/uibase/uiview/viewling.cxx | 23 ++++++++++++++++-------
1 file changed, 16 insertions(+), 7 deletions(-)
New commits:
commit e0487fc331b02b5145dd11a9d786409800f5e780
Author: Jan Holesovsky <kendy at collabora.com>
Date: Wed Jan 24 12:47:20 2018 +0100
lokdialog: Convert the Tools -> Thesaurus... to async exec.
Change-Id: Iee25e3fa970e5e28a14a95cfc8804ce944d4f762
Reviewed-on: https://gerrit.libreoffice.org/48498
Reviewed-by: Aron Budea <aron.budea at collabora.com>
Tested-by: Aron Budea <aron.budea at collabora.com>
diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx
index d1c2054d95b1..b0a596ce2210 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -27,6 +27,7 @@
#include <comphelper/lok.hxx>
#include <comphelper/processfactory.hxx>
#include <comphelper/propertyvalue.hxx>
+#include <comphelper/scopeguard.hxx>
#include <toolkit/helper/vclunohelper.hxx>
#include <vcl/msgbox.hxx>
#include <svtools/ehdl.hxx>
@@ -563,8 +564,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();
@@ -576,20 +578,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
More information about the Libreoffice-commits
mailing list