include/vcl/dialog.hxx | 3 +++ vcl/source/window/dialog.cxx | 24 ++++++++++++++++++++---- 2 files changed, 23 insertions(+), 4 deletions(-)
New commits: commit fdfc29078f64223148354551c1cb3b2169454350 Author: Pranav Kant <pran...@collabora.co.uk> Date: Wed Feb 21 13:10:00 2018 +0530 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 <ke...@collabora.com> Tested-by: Jan Holesovsky <ke...@collabora.com> diff --git a/include/vcl/dialog.hxx b/include/vcl/dialog.hxx index f028b7cb57c9..b1bdfcfb1cea 100644 --- a/include/vcl/dialog.hxx +++ b/include/vcl/dialog.hxx @@ -42,6 +42,7 @@ private: std::unique_ptr<DialogImpl> mpDialogImpl; long mnMousePositioned; bool mbInExecute; + bool mbInSyncExecute; bool mbInClose; bool mbModalMode; bool mbPaintComplete; @@ -116,6 +117,8 @@ public: virtual short Execute(); bool IsInExecute() const { return mbInExecute; } + // Return true when dialog is synchronously executed (calling ::Execute()) + bool IsInSyncExecute() const { return mbInSyncExecute; }; virtual FactoryFunction GetUITestFactory() const override; 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 _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits