summaryrefslogtreecommitdiff
path: root/vcl
diff options
context:
space:
mode:
authorPranav Kant <pranavk@collabora.co.uk>2018-02-21 13:10:00 +0530
committerJan Holesovsky <kendy@collabora.com>2018-02-21 17:51:38 +0100
commitfdfc29078f64223148354551c1cb3b2169454350 (patch)
tree25838cdd4d3ee5f4f4ab8e442925f781b3762286 /vcl
parentba114965731dca5e2aba4484124c016ee390572b (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/50095 Reviewed-by: Jan Holesovsky <kendy@collabora.com> Tested-by: Jan Holesovsky <kendy@collabora.com>
Diffstat (limited to 'vcl')
-rw-r--r--vcl/source/window/dialog.cxx24
1 files changed, 20 insertions, 4 deletions
diff --git a/vcl/source/window/dialog.cxx b/vcl/source/window/dialog.cxx
index 79d7f224ab43..c3e22efdeda4 100644
--- a/vcl/source/window/dialog.cxx
+++ b/vcl/source/window/dialog.cxx
@@ -24,6 +24,7 @@
#include <com/sun/star/frame/theGlobalEventBroadcaster.hpp>
#include <comphelper/lok.hxx>
#include <comphelper/processfactory.hxx>
+#include <comphelper/scopeguard.hxx>
#include <officecfg/Office/Common.hxx>
#include <osl/file.hxx>
@@ -820,13 +821,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
+ Dialog* pExeDlg = pSVData->maWinData.mpLastExecuteDlg;
+ while (pExeDlg && !pExeDlg->IsInSyncExecute())
+ pExeDlg = pExeDlg->mpPrevExecuteDlg;
+
+ const bool bDialogExecuting = pExeDlg ? pExeDlg->IsInSyncExecute() : false;
+ 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",
@@ -853,8 +867,6 @@ bool Dialog::ImplStartExecuteModal()
}
#endif
- ImplSVData* pSVData = ImplGetSVData();
-
// link all dialogs which are being executed
mpPrevExecuteDlg = pSVData->maWinData.mpLastExecuteDlg;
if (mpPrevExecuteDlg)
@@ -969,6 +981,10 @@ short Dialog::Execute()
#if HAVE_FEATURE_DESKTOP
VclPtr<vcl::Window> xWindow = this;
+ mbInSyncExecute = true;
+ comphelper::ScopeGuard aGuard([&]() {
+ mbInSyncExecute = false;
+ });
if ( !ImplStartExecuteModal() )
return 0;
@@ -977,8 +993,8 @@ short Dialog::Execute()
while ( !xWindow->IsDisposed() && mbInExecute )
Application::Yield();
+ mbInSyncExecute = false;
ImplEndExecuteModal();
-
#ifdef DBG_UTIL
assert (!mpDialogParent || !mpDialogParent->IsDisposed());
#endif