Resolves: tdf#113160 changing all warning dialogs to non-modal is unsafe

existing code doesn't expect that so stuff crashes

partial revert of...

commit db6b703d39
Date:   Thu Aug 24 18:32:38 2017 +0200

    Allow non-modal Dialogs during FileImport/Load

Change-Id: I152feb849186cf035664a700d3f94ee049cdf6d3
Reviewed-on: https://gerrit.libreoffice.org/44227
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
This commit is contained in:
Caolán McNamara
2017-11-02 17:23:00 +00:00
parent 7cca1dc560
commit fdcd11ff68
9 changed files with 12 additions and 85 deletions

View File

@@ -38,7 +38,6 @@
#include <vcl/window.hxx> #include <vcl/window.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <vcl/syswin.hxx> #include <vcl/syswin.hxx>
#include <vcl/dialog.hxx>
#include <unotools/moduleoptions.hxx> #include <unotools/moduleoptions.hxx>
#include <comphelper/processfactory.hxx> #include <comphelper/processfactory.hxx>
@@ -367,14 +366,6 @@ IMPL_LINK_NOARG(CloseDispatcher, impl_asyncCallback, LinkParamNone*, void)
} }
} }
// if we still have dialogs open, temporary suppress termination
if (bTerminateApp && Dialog::AreDialogsOpen())
{
Application::SetShutdownDelayed();
bCloseFrame = true;
bTerminateApp = false;
}
// Do it now ... // Do it now ...
bool bSuccess = false; bool bSuccess = false;
if (bCloseFrame) if (bCloseFrame)

View File

@@ -371,10 +371,6 @@ void LoadEnv::startLoading()
if (!bStarted) if (!bStarted)
bStarted = impl_loadContent(); bStarted = impl_loadContent();
// This may have triggered Dialogs (error cases) that may have
// delayed the shutdown, so give delayed shutdown a chance
Application::TriggerShutdownDelayed();
// not started => general error // not started => general error
// We can't say - what was the reason for. // We can't say - what was the reason for.
if (!bStarted) if (!bStarted)

View File

@@ -39,11 +39,8 @@ public:
/** Use given parent or get a default one using GetDefaultParent(...) */ /** Use given parent or get a default one using GetDefaultParent(...) */
Default, Default,
/** Suppress Parent so that Parent is not blocked (kind of modal mode) */ /** No Parent */
NoParent, NoParent
/** Suppress Parent (no modal, see above) and additionally center on default parent */
NoParentCentered
}; };
private: private:
@@ -168,7 +165,6 @@ public:
void EndDialog( long nResult = 0 ); void EndDialog( long nResult = 0 );
static void EndAllDialogs( vcl::Window const * pParent ); static void EndAllDialogs( vcl::Window const * pParent );
static bool AreDialogsOpen();
void GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder, void GetDrawWindowBorder( sal_Int32& rLeftBorder, sal_Int32& rTopBorder,
sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const; sal_Int32& rRightBorder, sal_Int32& rBottomBorder ) const;

View File

@@ -70,8 +70,7 @@ protected:
public: public:
MessBox(vcl::Window* pParent, MessBoxStyle nMessBoxStyle, WinBits n, MessBox(vcl::Window* pParent, MessBoxStyle nMessBoxStyle, WinBits n,
const OUString& rTitle, const OUString& rMessage, const OUString& rTitle, const OUString& rMessage);
Dialog::InitFlag eInitFlag = Dialog::InitFlag::NoParentCentered);
virtual ~MessBox() override; virtual ~MessBox() override;
virtual void dispose() override; virtual void dispose() override;

View File

@@ -1384,12 +1384,6 @@ public:
// For vclbootstrapprotector: // For vclbootstrapprotector:
static void setDeInitHook(Link<LinkParamNone*,void> const & hook); static void setDeInitHook(Link<LinkParamNone*,void> const & hook);
// for delayed shutdown: set using SetShutdownDelayed, then
// trigger using TriggerShutdownDelayed which may actually shutdown
// when SetShutdownDelayed is set
static void SetShutdownDelayed();
static void TriggerShutdownDelayed();
private: private:
DECL_STATIC_LINK( Application, PostEventHandler, void*, void ); DECL_STATIC_LINK( Application, PostEventHandler, void*, void );
}; };

View File

@@ -959,35 +959,12 @@ executeMessageBox(
vcl::Window * pParent, vcl::Window * pParent,
OUString const & rTitle, OUString const & rTitle,
OUString const & rMessage, OUString const & rMessage,
MessBoxStyle nButtonMask, MessBoxStyle nButtonMask)
Dialog::InitFlag eInitFlag)
{ {
SolarMutexGuard aGuard; SolarMutexGuard aGuard;
WinBits nStyle(0); WinBits nStyle(0);
ScopedVclPtrInstance< MessBox > xBox(pParent, nButtonMask, nStyle, rTitle, rMessage, eInitFlag); ScopedVclPtrInstance< MessBox > xBox(pParent, nButtonMask, nStyle, rTitle, rMessage);
if (Dialog::InitFlag::NoParentCentered == eInitFlag)
{
vcl::Window* pDefaultParent = Dialog::GetDefaultParent(nStyle);
if (pDefaultParent)
{
// need to 'Show' to have the following tasks do something, does
// not work without and may even stumble on nullptrs/errors
xBox->Show();
// center on parent window
const Point aP(pDefaultParent->GetPosPixel());
const Size aS(pDefaultParent->GetSizePixel());
const Size aMySize(xBox->GetSizePixel());
xBox->SetPosPixel(
Point(
aP.X() + ((aS.Width() - aMySize.Width()) >> 1),
aP.Y() + ((aS.Height() - aMySize.Height()) >> 1)));
}
}
sal_uInt16 aMessResult = xBox->Execute(); sal_uInt16 aMessResult = xBox->Execute();
DialogMask aResult = DialogMask::NONE; DialogMask aResult = DialogMask::NONE;
@@ -1131,8 +1108,7 @@ UUIInteractionHelper::handleGenericErrorRequest(
aTitle += " - " ; aTitle += " - " ;
aTitle += aErrTitle; aTitle += aErrTitle;
executeMessageBox( executeMessageBox(getParentProperty(), aTitle, aErrorString, MessBoxStyle::Ok);
getParentProperty(), aTitle, aErrorString, MessBoxStyle::Ok, Dialog::InitFlag::NoParentCentered);
} }
else else
ErrorHandler::HandleError(nErrorCode); ErrorHandler::HandleError(nErrorCode);
@@ -1247,8 +1223,7 @@ UUIInteractionHelper::handleBrokenPackageRequest(
" " + " " +
utl::ConfigManager::getProductVersion() ); utl::ConfigManager::getProductVersion() );
switch ( switch (executeMessageBox(getParentProperty(), title, aMessage, nButtonMask))
executeMessageBox( getParentProperty(), title, aMessage, nButtonMask, Dialog::InitFlag::NoParentCentered) )
{ {
case DialogMask::ButtonsOk: case DialogMask::ButtonsOk:
OSL_ENSURE( xAbort.is(), "unexpected situation" ); OSL_ENSURE( xAbort.is(), "unexpected situation" );

View File

@@ -1642,20 +1642,4 @@ void Application::setDeInitHook(Link<LinkParamNone*,void> const & hook) {
pSVData->maAppData.mbInAppMain = true; pSVData->maAppData.mbInAppMain = true;
} }
void Application::SetShutdownDelayed()
{
ImplSVData * pSVData = ImplGetSVData();
pSVData->maAppData.mbShutdownDelayed = true;
}
void Application::TriggerShutdownDelayed()
{
ImplSVData * pSVData = ImplGetSVData();
if (pSVData->maAppData.mbShutdownDelayed && !Dialog::AreDialogsOpen())
{
Application::PostUserEvent(LINK(nullptr, ImplSVAppData, ImplPrepareExitMsg));
}
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

View File

@@ -412,7 +412,7 @@ void Dialog::ImplInit( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag )
// Now, all Dialogs are per default system windows !!! // Now, all Dialogs are per default system windows !!!
nStyle |= WB_SYSTEMWINDOW; nStyle |= WB_SYSTEMWINDOW;
if (InitFlag::NoParent == eFlag || InitFlag::NoParentCentered == eFlag) if (InitFlag::NoParent == eFlag)
{ {
pParent = nullptr; pParent = nullptr;
} }
@@ -1179,14 +1179,6 @@ void Dialog::EndAllDialogs( vcl::Window const * pParent )
} }
} }
bool Dialog::AreDialogsOpen()
{
ImplSVData* pSVData = ImplGetSVData();
Dialog* pModDialog = pSVData->maWinData.mpLastExecuteDlg;
return (nullptr != pModDialog);
}
void Dialog::SetModalInputMode( bool bModal ) void Dialog::SetModalInputMode( bool bModal )
{ {
if ( bModal == mbModalMode ) if ( bModal == mbModalMode )

View File

@@ -123,14 +123,14 @@ void MessBox::ImplInitButtons()
} }
MessBox::MessBox(vcl::Window* pParent, MessBoxStyle nMessBoxStyle, WinBits nWinBits, MessBox::MessBox(vcl::Window* pParent, MessBoxStyle nMessBoxStyle, WinBits nWinBits,
const OUString& rTitle, const OUString& rMessage, Dialog::InitFlag eInitFlag) : const OUString& rTitle, const OUString& rMessage) :
ButtonDialog( WindowType::MESSBOX ), ButtonDialog( WindowType::MESSBOX ),
mbHelpBtn( false ), mbHelpBtn( false ),
mbCheck( false ), mbCheck( false ),
mnMessBoxStyle( nMessBoxStyle ), mnMessBoxStyle( nMessBoxStyle ),
maMessText( rMessage ) maMessText( rMessage )
{ {
ImplInit( pParent, nWinBits | WB_MOVEABLE | WB_HORZ | WB_CENTER, eInitFlag); ImplInit(pParent, nWinBits | WB_MOVEABLE | WB_HORZ | WB_CENTER);
ImplInitButtons(); ImplInitButtons();
if ( !rTitle.isEmpty() ) if ( !rTitle.isEmpty() )