diff options
author | Pranav Kant <pranavk@collabora.co.uk> | 2018-02-21 13:10:00 +0530 |
---|---|---|
committer | pranavk <pranavk@collabora.co.uk> | 2018-02-23 08:43:40 +0100 |
commit | 391660de4125da06775f7d94ef352da3926c115f (patch) | |
tree | 9d326579a85eda23038df573223ba47d090c024b /vcl | |
parent | 190a44fe052f034368e254d263fca21fc000d6ce (diff) |
lokdialog: Allow Execute()ing first, silently cancels others
We want to be able to detect which dialogs are important and need to be
converted to async while not completely disallowing them. Allow only
first instance of such dialogs being Execute()d and warn when another
such instance tries to Execute().
Change-Id: I6742784fa95d9e3f9ff87ece294126d390ae9e9e
Reviewed-on: https://gerrit.libreoffice.org/50092
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: pranavk <pranavk@collabora.co.uk>
Diffstat (limited to 'vcl')
-rw-r--r-- | vcl/source/window/dialog.cxx | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx index 9ba5d57da2d4..2da8e08d7ebc 100644 --- a/vcl/source/window/dialog.cxx +++ b/vcl/source/window/dialog.cxx @@ -23,6 +23,7 @@ #include <com/sun/star/util/thePathSettings.hpp> #include <com/sun/star/frame/theGlobalEventBroadcaster.hpp> #include <comphelper/lok.hxx> +#include <comphelper/scopeguard.hxx> #include <comphelper/processfactory.hxx> #include <officecfg/Office/Common.hxx> #include <osl/file.hxx> @@ -803,13 +804,26 @@ bool Dialog::ImplStartExecuteModal() return false; } + ImplSVData* pSVData = ImplGetSVData(); + switch ( Application::GetDialogCancelMode() ) { case Application::DialogCancelMode::Off: break; case Application::DialogCancelMode::Silent: if (GetLOKNotifier()) - break; + { + // check if there's already some dialog being ::Execute()d + const bool bDialogExecuting = std::any_of(pSVData->maWinData.mpExecuteDialogs.begin(), + pSVData->maWinData.mpExecuteDialogs.end(), + [](const Dialog* pDialog) { + return pDialog->IsInSyncExecute(); + }); + if (!(bDialogExecuting && IsInSyncExecute())) + break; + else + SAL_WARN("lok.dialog", "Dialog \"" << ImplGetDialogText(this) << "\" is being synchronously executed over an existing synchronously executing dialog."); + } SAL_INFO( "vcl", @@ -836,9 +850,7 @@ bool Dialog::ImplStartExecuteModal() } #endif - ImplSVData* pSVData = ImplGetSVData(); - - // link all dialogs which are being executed + // link all dialogs which are being executed pSVData->maWinData.mpExecuteDialogs.push_back(this); // stop capturing, in order to have control over the dialog @@ -950,6 +962,11 @@ short Dialog::Execute() #if HAVE_FEATURE_DESKTOP VclPtr<vcl::Window> xWindow = this; + mbInSyncExecute = true; + comphelper::ScopeGuard aGuard([&]() { + mbInSyncExecute = false; + }); + if ( !ImplStartExecuteModal() ) return 0; @@ -959,7 +976,6 @@ short Dialog::Execute() Application::Yield(); ImplEndExecuteModal(); - #ifdef DBG_UTIL assert (!mpDialogParent || !mpDialogParent->IsDisposed()); #endif |