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/svapp.hxx>
#include <vcl/syswin.hxx>
#include <vcl/dialog.hxx>
#include <unotools/moduleoptions.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 ...
bool bSuccess = false;
if (bCloseFrame)

View File

@@ -371,10 +371,6 @@ void LoadEnv::startLoading()
if (!bStarted)
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
// We can't say - what was the reason for.
if (!bStarted)

View File

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

View File

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

View File

@@ -1384,12 +1384,6 @@ public:
// For vclbootstrapprotector:
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:
DECL_STATIC_LINK( Application, PostEventHandler, void*, void );
};

View File

@@ -959,35 +959,12 @@ executeMessageBox(
vcl::Window * pParent,
OUString const & rTitle,
OUString const & rMessage,
MessBoxStyle nButtonMask,
Dialog::InitFlag eInitFlag)
MessBoxStyle nButtonMask)
{
SolarMutexGuard aGuard;
WinBits nStyle(0);
ScopedVclPtrInstance< MessBox > xBox(pParent, nButtonMask, nStyle, rTitle, rMessage, eInitFlag);
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)));
}
}
ScopedVclPtrInstance< MessBox > xBox(pParent, nButtonMask, nStyle, rTitle, rMessage);
sal_uInt16 aMessResult = xBox->Execute();
DialogMask aResult = DialogMask::NONE;
@@ -1131,8 +1108,7 @@ UUIInteractionHelper::handleGenericErrorRequest(
aTitle += " - " ;
aTitle += aErrTitle;
executeMessageBox(
getParentProperty(), aTitle, aErrorString, MessBoxStyle::Ok, Dialog::InitFlag::NoParentCentered);
executeMessageBox(getParentProperty(), aTitle, aErrorString, MessBoxStyle::Ok);
}
else
ErrorHandler::HandleError(nErrorCode);
@@ -1247,8 +1223,7 @@ UUIInteractionHelper::handleBrokenPackageRequest(
" " +
utl::ConfigManager::getProductVersion() );
switch (
executeMessageBox( getParentProperty(), title, aMessage, nButtonMask, Dialog::InitFlag::NoParentCentered) )
switch (executeMessageBox(getParentProperty(), title, aMessage, nButtonMask))
{
case DialogMask::ButtonsOk:
OSL_ENSURE( xAbort.is(), "unexpected situation" );

View File

@@ -1642,20 +1642,4 @@ void Application::setDeInitHook(Link<LinkParamNone*,void> const & hook) {
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: */

View File

@@ -412,7 +412,7 @@ void Dialog::ImplInit( vcl::Window* pParent, WinBits nStyle, InitFlag eFlag )
// Now, all Dialogs are per default system windows !!!
nStyle |= WB_SYSTEMWINDOW;
if (InitFlag::NoParent == eFlag || InitFlag::NoParentCentered == eFlag)
if (InitFlag::NoParent == eFlag)
{
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 )
{
if ( bModal == mbModalMode )

View File

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