diff options
author | Caolán McNamara <caolanm@redhat.com> | 2018-11-28 11:12:55 +0000 |
---|---|---|
committer | Caolán McNamara <caolanm@redhat.com> | 2018-11-28 13:24:13 +0100 |
commit | 01de2fbdedc693dc46c6d3fde276820a52b42a9c (patch) | |
tree | 0615090bae11bd5f9b4a73cb8fc0231897b0e304 /desktop/source/deployment | |
parent | 57bfb56972dc101200466054f0f9446301c214cb (diff) |
Resolves: tdf#121746 block toplevels from closing...
while the extension manager is querying via a dialog. Reuse
the isBusy for this.
Change-Id: I97572404ae296e87fd44711bf1e978bd5bad6280
Reviewed-on: https://gerrit.libreoffice.org/64155
Tested-by: Jenkins
Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'desktop/source/deployment')
-rw-r--r-- | desktop/source/deployment/gui/dp_gui_dialog2.cxx | 84 | ||||
-rw-r--r-- | desktop/source/deployment/gui/dp_gui_dialog2.hxx | 23 |
2 files changed, 78 insertions, 29 deletions
diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx index b36f18d8f5dc..62e2e301bfc4 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx @@ -336,16 +336,15 @@ void ExtBoxWithBtns_Impl::enableButtons( bool bEnable ) // DialogHelper -DialogHelper::DialogHelper( const uno::Reference< uno::XComponentContext > &xContext, - Dialog *pWindow ) : - m_pVCLWindow( pWindow ), - m_nEventID( nullptr ), - m_bIsBusy( false ) +DialogHelper::DialogHelper(const uno::Reference< uno::XComponentContext > &xContext, + Dialog *pWindow) + : m_xVCLWindow(pWindow) + , m_nEventID(nullptr) + , m_nBusy(0) { m_xContext = xContext; } - DialogHelper::~DialogHelper() { if ( m_nEventID ) @@ -366,17 +365,21 @@ bool DialogHelper::continueOnSharedExtension( const uno::Reference< deployment:: if ( !bHadWarning && IsSharedPkgMgr( xPackage ) ) { const SolarMutexGuard guard; + incBusy(); std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent, VclMessageType::Warning, VclButtonsType::OkCancel, DpResId(pResID))); bHadWarning = true; - return RET_OK == xBox->run(); + bool bRet = RET_OK == xBox->run(); + xBox.reset(); + decBusy(); + return bRet; } else return true; } -void DialogHelper::openWebBrowser( const OUString & sURL, const OUString &sTitle ) const +void DialogHelper::openWebBrowser(const OUString& sURL, const OUString& sTitle) { if ( sURL.isEmpty() ) // Nothing to do, when the URL is empty return; @@ -393,29 +396,35 @@ void DialogHelper::openWebBrowser( const OUString & sURL, const OUString &sTitle uno::Any exc( ::cppu::getCaughtException() ); OUString msg( ::comphelper::anyToString( exc ) ); const SolarMutexGuard guard; + incBusy(); std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(getFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, msg)); xErrorBox->set_title(sTitle); xErrorBox->run(); + xErrorBox.reset(); + decBusy(); } } - -bool DialogHelper::installExtensionWarn( const OUString &rExtensionName ) const +bool DialogHelper::installExtensionWarn(const OUString &rExtensionName) { const SolarMutexGuard guard; // Check if extension installation is disabled in the expert configurations if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get()) { + incBusy(); std::unique_ptr<weld::MessageDialog> xWarnBox(Application::CreateMessageDialog(getFrameWeld(), VclMessageType::Warning, VclButtonsType::Ok, DpResId(RID_STR_WARNING_INSTALL_EXTENSION_DISABLED))); xWarnBox->run(); + xWarnBox.reset(); + decBusy(); return false; } + incBusy(); std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(getFrameWeld(), VclMessageType::Warning, VclButtonsType::OkCancel, DpResId(RID_STR_WARNING_INSTALL_EXTENSION))); @@ -423,15 +432,21 @@ bool DialogHelper::installExtensionWarn( const OUString &rExtensionName ) const sText = sText.replaceAll("%NAME", rExtensionName); xInfoBox->set_primary_text(sText); - return (RET_OK == xInfoBox->run()); + bool bRet = RET_OK == xInfoBox->run(); + xInfoBox.reset(); + decBusy(); + return bRet; } -bool DialogHelper::installForAllUsers( bool &bInstallForAll ) const +bool DialogHelper::installForAllUsers(bool &bInstallForAll) { const SolarMutexGuard guard; + incBusy(); std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(getFrameWeld(), "desktop/ui/installforalldialog.ui")); std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("InstallForAllDialog")); short nRet = xQuery->run(); + xQuery.reset(); + decBusy(); if (nRet == RET_CANCEL) return false; @@ -447,6 +462,34 @@ void DialogHelper::PostUserEvent( const Link<void*,void>& rLink, void* pCaller ) 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(vcl::Window *pParent, TheExtensionManager *pManager, Dialog::InitFlag eFlag) : ModelessDialog(pParent, "ExtensionManagerDialog", "desktop/ui/extensionmanager.ui", eFlag) @@ -588,9 +631,10 @@ void ExtMgrDialog::checkEntries() m_pExtensionBox->checkEntries(); } -bool ExtMgrDialog::removeExtensionWarn( const OUString &rExtensionName ) const +bool ExtMgrDialog::removeExtensionWarn(const OUString &rExtensionName) { const SolarMutexGuard guard; + incBusy(); std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), VclMessageType::Warning, VclButtonsType::OkCancel, DpResId(RID_STR_WARNING_REMOVE_EXTENSION))); @@ -599,7 +643,11 @@ bool ExtMgrDialog::removeExtensionWarn( const OUString &rExtensionName ) const sText = sText.replaceAll("%NAME", rExtensionName); xInfoBox->set_primary_text(sText); - return (RET_OK == xInfoBox->run()); + bool bRet = RET_OK == xInfoBox->run(); + xInfoBox.reset(); + decBusy(); + + return bRet; } void ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackage > &xPackage, @@ -903,7 +951,7 @@ IMPL_LINK_NOARG(ExtMgrDialog, HandleOptionsBtn, Button*, void) IMPL_LINK_NOARG(ExtMgrDialog, HandleAddBtn, Button*, void) { - setBusy( true ); + incBusy(); uno::Sequence< OUString > aFileList = raiseAddPicker(); @@ -912,7 +960,7 @@ IMPL_LINK_NOARG(ExtMgrDialog, HandleAddBtn, Button*, void) m_pManager->installPackage( aFileList[0] ); } - setBusy( false ); + decBusy(); } IMPL_LINK_NOARG(ExtMgrDialog, HandleRemoveBtn, Button*, void) @@ -1412,7 +1460,7 @@ void UpdateRequiredDialog::disableAllEntries() { ::osl::MutexGuard aGuard( m_aMutex ); - setBusy( true ); + incBusy(); long nCount = m_pExtensionBox->GetEntryCount(); for ( long nIndex = 0; nIndex < nCount; nIndex++ ) @@ -1421,7 +1469,7 @@ void UpdateRequiredDialog::disableAllEntries() m_pManager->getCmdQueue()->enableExtension( pEntry->m_xPackage, false ); } - setBusy( false ); + decBusy(); if ( ! hasActiveEntries() ) m_pCloseBtn->SetText( m_sCloseText ); diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.hxx b/desktop/source/deployment/gui/dp_gui_dialog2.hxx index 293f83539ccf..dd0dc8bb8160 100644 --- a/desktop/source/deployment/gui/dp_gui_dialog2.hxx +++ b/desktop/source/deployment/gui/dp_gui_dialog2.hxx @@ -58,18 +58,18 @@ class TheExtensionManager; class DialogHelper { css::uno::Reference< css::uno::XComponentContext > m_xContext; - VclPtr<Dialog> m_pVCLWindow; + VclPtr<Dialog> m_xVCLWindow; ImplSVEvent * m_nEventID; - bool m_bIsBusy; + int m_nBusy; public: DialogHelper( const css::uno::Reference< css::uno::XComponentContext > &, Dialog *pWindow ); virtual ~DialogHelper(); - void openWebBrowser( const OUString & sURL, const OUString & sTitle ) const; - Dialog* getWindow() const { return m_pVCLWindow; }; - weld::Window* getFrameWeld() const { return m_pVCLWindow ? m_pVCLWindow->GetFrameWeld() : nullptr; } + void openWebBrowser(const OUString& rURL, const OUString& rTitle); + Dialog* getWindow() const { return m_xVCLWindow; }; + weld::Window* getFrameWeld() const { return m_xVCLWindow ? m_xVCLWindow->GetFrameWeld() : nullptr; } void PostUserEvent( const Link<void*,void>& rLink, void* pCaller ); void clearEventID() { m_nEventID = nullptr; } @@ -86,15 +86,16 @@ public: virtual void checkEntries() = 0; static bool IsSharedPkgMgr( const css::uno::Reference< css::deployment::XPackage > &); - static bool continueOnSharedExtension( const css::uno::Reference< css::deployment::XPackage > &, + bool continueOnSharedExtension( const css::uno::Reference< css::deployment::XPackage > &, weld::Widget* pParent, const char* pResID, bool &bHadWarning ); - void setBusy( const bool bBusy ) { m_bIsBusy = bBusy; } - bool isBusy() const { return m_bIsBusy; } - bool installExtensionWarn( const OUString &rExtensionURL ) const; - bool installForAllUsers( bool &bInstallForAll ) const; + void incBusy(); + void decBusy(); + bool isBusy() const { return m_nBusy > 0; } + bool installExtensionWarn(const OUString &rExtensionURL); + bool installForAllUsers(bool &bInstallForAll); }; @@ -134,7 +135,7 @@ class ExtMgrDialog : public ModelessDialog, css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel; - bool removeExtensionWarn( const OUString &rExtensionTitle ) const; + bool removeExtensionWarn(const OUString &rExtensionTitle); DECL_LINK( HandleOptionsBtn, Button*, void ); DECL_LINK( HandleAddBtn, Button*, void ); |