Kaydet (Commit) e94dc6f6 authored tarafından Caolán McNamara's avatar Caolán McNamara

Resolves: tdf#122404 unlock just the toplevels that were locked

push what toplevels got locked to just unlock those ones. otherwise the just
dismissed toplevel may still be present in the Application toplevel list.

merge all the similar examples of this.

Change-Id: I77c0d55d1e4b3bcc3b8d88fef00ba289edd1e831
Reviewed-on: https://gerrit.libreoffice.org/66076
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst d095a887
...@@ -340,7 +340,6 @@ DialogHelper::DialogHelper(const uno::Reference< uno::XComponentContext > &xCont ...@@ -340,7 +340,6 @@ DialogHelper::DialogHelper(const uno::Reference< uno::XComponentContext > &xCont
Dialog *pWindow) Dialog *pWindow)
: m_xVCLWindow(pWindow) : m_xVCLWindow(pWindow)
, m_nEventID(nullptr) , m_nEventID(nullptr)
, m_nBusy(0)
{ {
m_xContext = xContext; m_xContext = xContext;
} }
...@@ -462,34 +461,6 @@ void DialogHelper::PostUserEvent( const Link<void*,void>& rLink, void* pCaller ) ...@@ -462,34 +461,6 @@ void DialogHelper::PostUserEvent( const Link<void*,void>& rLink, void* pCaller )
m_nEventID = Application::PostUserEvent( rLink, pCaller, true/*bReferenceLink*/ ); m_nEventID = Application::PostUserEvent( rLink, pCaller, true/*bReferenceLink*/ );
} }
void DialogHelper::incBusy()
{
++m_nBusy;
// lock any toplevel windows from being closed until busy is over
// ensure any dialogs are reset before entering
vcl::Window *xTopWin = Application::GetFirstTopLevelWindow();
while (xTopWin)
{
if (xTopWin != m_xVCLWindow)
xTopWin->IncModalCount();
xTopWin = Application::GetNextTopLevelWindow(xTopWin);
}
}
void DialogHelper::decBusy()
{
--m_nBusy;
// unlock any toplevel windows from being closed until busy is over
// ensure any dialogs are reset before entering
vcl::Window *xTopWin = Application::GetFirstTopLevelWindow();
while (xTopWin)
{
if (xTopWin != m_xVCLWindow)
xTopWin->DecModalCount();
xTopWin = Application::GetNextTopLevelWindow(xTopWin);
}
}
// ExtMgrDialog // ExtMgrDialog
ExtMgrDialog::ExtMgrDialog(vcl::Window *pParent, TheExtensionManager *pManager, Dialog::InitFlag eFlag) ExtMgrDialog::ExtMgrDialog(vcl::Window *pParent, TheExtensionManager *pManager, Dialog::InitFlag eFlag)
: ModelessDialog(pParent, "ExtensionManagerDialog", "desktop/ui/extensionmanager.ui", eFlag) : ModelessDialog(pParent, "ExtensionManagerDialog", "desktop/ui/extensionmanager.ui", eFlag)
......
...@@ -29,6 +29,7 @@ ...@@ -29,6 +29,7 @@
#include <vcl/prgsbar.hxx> #include <vcl/prgsbar.hxx>
#include <vcl/timer.hxx> #include <vcl/timer.hxx>
#include <vcl/idle.hxx> #include <vcl/idle.hxx>
#include <vcl/waitobj.hxx>
#include <vcl/weld.hxx> #include <vcl/weld.hxx>
#include <svtools/svmedit.hxx> #include <svtools/svmedit.hxx>
...@@ -47,6 +48,9 @@ ...@@ -47,6 +48,9 @@
#include <com/sun/star/ui/dialogs/XExecutableDialog.hpp> #include <com/sun/star/ui/dialogs/XExecutableDialog.hpp>
#include <com/sun/star/util/XModifyListener.hpp> #include <com/sun/star/util/XModifyListener.hpp>
#include <stack>
#include <vector>
namespace dp_gui { namespace dp_gui {
...@@ -60,7 +64,7 @@ class DialogHelper ...@@ -60,7 +64,7 @@ class DialogHelper
css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::uno::XComponentContext > m_xContext;
VclPtr<Dialog> m_xVCLWindow; VclPtr<Dialog> m_xVCLWindow;
ImplSVEvent * m_nEventID; ImplSVEvent * m_nEventID;
int m_nBusy; TopLevelWindowLocker m_aBusy;
public: public:
DialogHelper( const css::uno::Reference< css::uno::XComponentContext > &, DialogHelper( const css::uno::Reference< css::uno::XComponentContext > &,
...@@ -91,14 +95,13 @@ public: ...@@ -91,14 +95,13 @@ public:
const char* pResID, const char* pResID,
bool &bHadWarning ); bool &bHadWarning );
void incBusy(); void incBusy() { m_aBusy.incBusy(m_xVCLWindow); }
void decBusy(); void decBusy() { m_aBusy.decBusy(); }
bool isBusy() const { return m_nBusy > 0; } bool isBusy() const { return m_aBusy.isBusy(); }
bool installExtensionWarn(const OUString &rExtensionURL); bool installExtensionWarn(const OUString &rExtensionURL);
bool installForAllUsers(bool &bInstallForAll); bool installForAllUsers(bool &bInstallForAll);
}; };
class ExtMgrDialog : public ModelessDialog, class ExtMgrDialog : public ModelessDialog,
public DialogHelper public DialogHelper
{ {
......
...@@ -133,32 +133,6 @@ void XMLFilterSettingsDialog::dispose() ...@@ -133,32 +133,6 @@ void XMLFilterSettingsDialog::dispose()
ModelessDialog::dispose(); ModelessDialog::dispose();
} }
void XMLFilterSettingsDialog::incBusy()
{
// lock any toplevel windows from being closed until busy is over
// ensure any dialogs are reset before entering
vcl::Window *xTopWin = Application::GetFirstTopLevelWindow();
while (xTopWin)
{
if (xTopWin != this)
xTopWin->IncModalCount();
xTopWin = Application::GetNextTopLevelWindow(xTopWin);
}
}
void XMLFilterSettingsDialog::decBusy()
{
// unlock any toplevel windows from being closed until busy is over
// ensure any dialogs are reset before entering
vcl::Window *xTopWin = Application::GetFirstTopLevelWindow();
while (xTopWin)
{
if (xTopWin != this)
xTopWin->DecModalCount();
xTopWin = Application::GetNextTopLevelWindow(xTopWin);
}
}
IMPL_LINK(XMLFilterSettingsDialog, ClickHdl_Impl, Button *, pButton, void ) IMPL_LINK(XMLFilterSettingsDialog, ClickHdl_Impl, Button *, pButton, void )
{ {
// tdf#122171 block closing libreoffice until the following dialog is dismissed // tdf#122171 block closing libreoffice until the following dialog is dismissed
......
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <vcl/dialog.hxx> #include <vcl/dialog.hxx>
#include <vcl/layout.hxx> #include <vcl/layout.hxx>
#include <vcl/svtabbx.hxx> #include <vcl/svtabbx.hxx>
#include <vcl/waitobj.hxx>
#include <svl/poolitem.hxx> #include <svl/poolitem.hxx>
#include <unotools/moduleoptions.hxx> #include <unotools/moduleoptions.hxx>
...@@ -109,8 +110,8 @@ private: ...@@ -109,8 +110,8 @@ private:
void initFilterList(); void initFilterList();
void disposeFilterList(); void disposeFilterList();
void incBusy(); void incBusy() { maBusy.incBusy(this); }
void decBusy(); void decBusy() { maBusy.decBusy(); }
bool insertOrEdit( filter_info_impl* pNewInfo, const filter_info_impl* pOldInfo = nullptr ); bool insertOrEdit( filter_info_impl* pNewInfo, const filter_info_impl* pOldInfo = nullptr );
...@@ -126,6 +127,7 @@ private: ...@@ -126,6 +127,7 @@ private:
std::vector< std::unique_ptr<filter_info_impl> > maFilterVector; std::vector< std::unique_ptr<filter_info_impl> > maFilterVector;
TopLevelWindowLocker maBusy;
VclPtr<XMLFilterListBox> m_pFilterListBox; VclPtr<XMLFilterListBox> m_pFilterListBox;
VclPtr<SvxPathControl> m_pCtrlFilterList; VclPtr<SvxPathControl> m_pCtrlFilterList;
VclPtr<PushButton> m_pPBNew; VclPtr<PushButton> m_pPBNew;
......
...@@ -40,8 +40,6 @@ private: ...@@ -40,8 +40,6 @@ private:
SAL_DLLPRIVATE virtual bool Start(const OUString& rURL, weld::Widget* pWidget) override; SAL_DLLPRIVATE virtual bool Start(const OUString& rURL, weld::Widget* pWidget) override;
SAL_DLLPRIVATE static OUString GetHelpModuleName_Impl(const OUString &rHelpId); SAL_DLLPRIVATE static OUString GetHelpModuleName_Impl(const OUString &rHelpId);
SAL_DLLPRIVATE static OUString CreateHelpURL_Impl( const OUString& aCommandURL, const OUString& rModuleName ); SAL_DLLPRIVATE static OUString CreateHelpURL_Impl( const OUString& aCommandURL, const OUString& rModuleName );
SAL_DLLPRIVATE static void incBusy(const vcl::Window* pParent);
SAL_DLLPRIVATE static void decBusy(const vcl::Window* pParent);
public: public:
SfxHelp(); SfxHelp();
......
...@@ -23,6 +23,9 @@ ...@@ -23,6 +23,9 @@
#include <vcl/dllapi.h> #include <vcl/dllapi.h>
#include <vcl/window.hxx> #include <vcl/window.hxx>
#include <stack>
#include <vector>
class VCL_DLLPUBLIC WaitObject class VCL_DLLPUBLIC WaitObject
{ {
private: private:
...@@ -37,6 +40,18 @@ public: ...@@ -37,6 +40,18 @@ public:
~WaitObject(); ~WaitObject();
}; };
class VCL_DLLPUBLIC TopLevelWindowLocker
{
private:
std::stack<std::vector<VclPtr<vcl::Window>>> m_aBusyStack;
public:
// lock all toplevels, except the argument
void incBusy(const vcl::Window* pIgnore);
// unlock previous lock
void decBusy();
bool isBusy() const { return !m_aBusyStack.empty(); }
};
#endif // INCLUDED_VCL_WAITOBJ_HXX #endif // INCLUDED_VCL_WAITOBJ_HXX
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
...@@ -62,6 +62,7 @@ ...@@ -62,6 +62,7 @@
#include <rtl/uri.hxx> #include <rtl/uri.hxx>
#include <vcl/commandinfoprovider.hxx> #include <vcl/commandinfoprovider.hxx>
#include <vcl/layout.hxx> #include <vcl/layout.hxx>
#include <vcl/waitobj.hxx>
#include <vcl/weld.hxx> #include <vcl/weld.hxx>
#include <svtools/ehdl.hxx> #include <svtools/ehdl.hxx>
#include <svtools/sfxecode.hxx> #include <svtools/sfxecode.hxx>
...@@ -1011,32 +1012,6 @@ namespace ...@@ -1011,32 +1012,6 @@ namespace
} }
} }
void SfxHelp::incBusy(const vcl::Window* pParent)
{
// lock any toplevel windows from being closed until busy is over
// ensure any dialogs are reset before entering
vcl::Window *xTopWin = Application::GetFirstTopLevelWindow();
while (xTopWin)
{
if (xTopWin != pParent)
xTopWin->IncModalCount();
xTopWin = Application::GetNextTopLevelWindow(xTopWin);
}
}
void SfxHelp::decBusy(const vcl::Window* pParent)
{
// unlock any toplevel windows from being closed until busy is over
// ensure any dialogs are reset before entering
vcl::Window *xTopWin = Application::GetFirstTopLevelWindow();
while (xTopWin)
{
if (xTopWin != pParent)
xTopWin->DecModalCount();
xTopWin = Application::GetNextTopLevelWindow(xTopWin);
}
}
bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow, const OUString& rKeyword) bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow, const OUString& rKeyword)
{ {
OUStringBuffer aHelpRootURL("vnd.sun.star.help://"); OUStringBuffer aHelpRootURL("vnd.sun.star.help://");
...@@ -1143,9 +1118,11 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow, const ...@@ -1143,9 +1118,11 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow, const
pWindow = GetBestParent(pWindow); pWindow = GetBestParent(pWindow);
TopLevelWindowLocker aBusy;
if(bShowOfflineHelpPopUp) if(bShowOfflineHelpPopUp)
{ {
incBusy(pWindow); aBusy.incBusy(pWindow);
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pWindow ? pWindow->GetFrameWeld() : nullptr, "sfx/ui/helpmanual.ui")); std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(pWindow ? pWindow->GetFrameWeld() : nullptr, "sfx/ui/helpmanual.ui"));
std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("onlinehelpmanual")); std::unique_ptr<weld::MessageDialog> xQueryBox(xBuilder->weld_message_dialog("onlinehelpmanual"));
std::unique_ptr<weld::CheckButton> m_xHideOfflineHelpCB(xBuilder->weld_check_button("hidedialog")); std::unique_ptr<weld::CheckButton> m_xHideOfflineHelpCB(xBuilder->weld_check_button("hidedialog"));
...@@ -1156,7 +1133,7 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow, const ...@@ -1156,7 +1133,7 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow, const
short OnlineHelpBox = xQueryBox->run(); short OnlineHelpBox = xQueryBox->run();
bShowOfflineHelpPopUp = OnlineHelpBox != RET_OK; bShowOfflineHelpPopUp = OnlineHelpBox != RET_OK;
aHelpOptions.SetOfflineHelpPopUp(!m_xHideOfflineHelpCB->get_state()); aHelpOptions.SetOfflineHelpPopUp(!m_xHideOfflineHelpCB->get_state());
decBusy(pWindow); aBusy.decBusy();
} }
if(!bShowOfflineHelpPopUp) if(!bShowOfflineHelpPopUp)
{ {
...@@ -1164,10 +1141,10 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow, const ...@@ -1164,10 +1141,10 @@ bool SfxHelp::Start_Impl(const OUString& rURL, const vcl::Window* pWindow, const
return true; return true;
else else
{ {
incBusy(pWindow); aBusy.incBusy(pWindow);
NoHelpErrorBox aErrBox(pWindow ? pWindow->GetFrameWeld() : nullptr); NoHelpErrorBox aErrBox(pWindow ? pWindow->GetFrameWeld() : nullptr);
aErrBox.run(); aErrBox.run();
decBusy(pWindow); aBusy.decBusy();
return false; return false;
} }
} }
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include <vcl/layout.hxx> #include <vcl/layout.hxx>
#include <vcl/svapp.hxx> #include <vcl/svapp.hxx>
#include <vcl/event.hxx> #include <vcl/event.hxx>
#include <vcl/waitobj.hxx>
#include <vcl/wrkwin.hxx> #include <vcl/wrkwin.hxx>
#include <vcl/button.hxx> #include <vcl/button.hxx>
#include <vcl/mnemonic.hxx> #include <vcl/mnemonic.hxx>
...@@ -1548,4 +1549,28 @@ void Dialog::Activate() ...@@ -1548,4 +1549,28 @@ void Dialog::Activate()
SystemWindow::Activate(); SystemWindow::Activate();
} }
void TopLevelWindowLocker::incBusy(const vcl::Window* pIgnore)
{
// lock any toplevel windows from being closed until busy is over
std::vector<VclPtr<vcl::Window>> aTopLevels;
vcl::Window *pTopWin = Application::GetFirstTopLevelWindow();
while (pTopWin)
{
if (pTopWin != pIgnore)
aTopLevels.push_back(pTopWin);
pTopWin = Application::GetNextTopLevelWindow(pTopWin);
}
for (auto& a : aTopLevels)
a->IncModalCount();
m_aBusyStack.push(aTopLevels);
}
void TopLevelWindowLocker::decBusy()
{
// unlock locked toplevel windows from being closed now busy is over
for (auto& a : m_aBusyStack.top())
a->DecModalCount();
m_aBusyStack.pop();
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */ /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment