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

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/64161
Tested-by: Jenkins
Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst 4e9258e0
...@@ -336,16 +336,15 @@ void ExtBoxWithBtns_Impl::enableButtons( bool bEnable ) ...@@ -336,16 +336,15 @@ void ExtBoxWithBtns_Impl::enableButtons( bool bEnable )
// DialogHelper // DialogHelper
DialogHelper::DialogHelper( const uno::Reference< uno::XComponentContext > &xContext, DialogHelper::DialogHelper(const uno::Reference< uno::XComponentContext > &xContext,
Dialog *pWindow ) : Dialog *pWindow)
m_pVCLWindow( pWindow ), : m_xVCLWindow(pWindow)
m_nEventID( nullptr ), , m_nEventID(nullptr)
m_bIsBusy( false ) , m_nBusy(0)
{ {
m_xContext = xContext; m_xContext = xContext;
} }
DialogHelper::~DialogHelper() DialogHelper::~DialogHelper()
{ {
if ( m_nEventID ) if ( m_nEventID )
...@@ -366,17 +365,21 @@ bool DialogHelper::continueOnSharedExtension( const uno::Reference< deployment:: ...@@ -366,17 +365,21 @@ bool DialogHelper::continueOnSharedExtension( const uno::Reference< deployment::
if ( !bHadWarning && IsSharedPkgMgr( xPackage ) ) if ( !bHadWarning && IsSharedPkgMgr( xPackage ) )
{ {
const SolarMutexGuard guard; const SolarMutexGuard guard;
incBusy();
std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent, std::unique_ptr<weld::MessageDialog> xBox(Application::CreateMessageDialog(pParent,
VclMessageType::Warning, VclButtonsType::OkCancel, DpResId(pResID))); VclMessageType::Warning, VclButtonsType::OkCancel, DpResId(pResID)));
bHadWarning = true; bHadWarning = true;
return RET_OK == xBox->run(); bool bRet = RET_OK == xBox->run();
xBox.reset();
decBusy();
return bRet;
} }
else else
return true; 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 if ( sURL.isEmpty() ) // Nothing to do, when the URL is empty
return; return;
...@@ -393,29 +396,35 @@ void DialogHelper::openWebBrowser( const OUString & sURL, const OUString &sTitle ...@@ -393,29 +396,35 @@ void DialogHelper::openWebBrowser( const OUString & sURL, const OUString &sTitle
uno::Any exc( ::cppu::getCaughtException() ); uno::Any exc( ::cppu::getCaughtException() );
OUString msg( ::comphelper::anyToString( exc ) ); OUString msg( ::comphelper::anyToString( exc ) );
const SolarMutexGuard guard; const SolarMutexGuard guard;
incBusy();
std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(getFrameWeld(), std::unique_ptr<weld::MessageDialog> xErrorBox(Application::CreateMessageDialog(getFrameWeld(),
VclMessageType::Warning, VclButtonsType::Ok, msg)); VclMessageType::Warning, VclButtonsType::Ok, msg));
xErrorBox->set_title(sTitle); xErrorBox->set_title(sTitle);
xErrorBox->run(); xErrorBox->run();
xErrorBox.reset();
decBusy();
} }
} }
bool DialogHelper::installExtensionWarn(const OUString &rExtensionName)
bool DialogHelper::installExtensionWarn( const OUString &rExtensionName ) const
{ {
const SolarMutexGuard guard; const SolarMutexGuard guard;
// Check if extension installation is disabled in the expert configurations // Check if extension installation is disabled in the expert configurations
if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get()) if (officecfg::Office::ExtensionManager::ExtensionSecurity::DisableExtensionInstallation::get())
{ {
incBusy();
std::unique_ptr<weld::MessageDialog> xWarnBox(Application::CreateMessageDialog(getFrameWeld(), std::unique_ptr<weld::MessageDialog> xWarnBox(Application::CreateMessageDialog(getFrameWeld(),
VclMessageType::Warning, VclButtonsType::Ok, VclMessageType::Warning, VclButtonsType::Ok,
DpResId(RID_STR_WARNING_INSTALL_EXTENSION_DISABLED))); DpResId(RID_STR_WARNING_INSTALL_EXTENSION_DISABLED)));
xWarnBox->run(); xWarnBox->run();
xWarnBox.reset();
decBusy();
return false; return false;
} }
incBusy();
std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(getFrameWeld(), std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(getFrameWeld(),
VclMessageType::Warning, VclButtonsType::OkCancel, VclMessageType::Warning, VclButtonsType::OkCancel,
DpResId(RID_STR_WARNING_INSTALL_EXTENSION))); DpResId(RID_STR_WARNING_INSTALL_EXTENSION)));
...@@ -423,15 +432,21 @@ bool DialogHelper::installExtensionWarn( const OUString &rExtensionName ) const ...@@ -423,15 +432,21 @@ bool DialogHelper::installExtensionWarn( const OUString &rExtensionName ) const
sText = sText.replaceAll("%NAME", rExtensionName); sText = sText.replaceAll("%NAME", rExtensionName);
xInfoBox->set_primary_text(sText); 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; const SolarMutexGuard guard;
incBusy();
std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(getFrameWeld(), "desktop/ui/installforalldialog.ui")); std::unique_ptr<weld::Builder> xBuilder(Application::CreateBuilder(getFrameWeld(), "desktop/ui/installforalldialog.ui"));
std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("InstallForAllDialog")); std::unique_ptr<weld::MessageDialog> xQuery(xBuilder->weld_message_dialog("InstallForAllDialog"));
short nRet = xQuery->run(); short nRet = xQuery->run();
xQuery.reset();
decBusy();
if (nRet == RET_CANCEL) if (nRet == RET_CANCEL)
return false; return false;
...@@ -447,6 +462,34 @@ void DialogHelper::PostUserEvent( const Link<void*,void>& rLink, void* pCaller ) ...@@ -447,6 +462,34 @@ 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)
...@@ -588,9 +631,10 @@ void ExtMgrDialog::checkEntries() ...@@ -588,9 +631,10 @@ void ExtMgrDialog::checkEntries()
m_pExtensionBox->checkEntries(); m_pExtensionBox->checkEntries();
} }
bool ExtMgrDialog::removeExtensionWarn( const OUString &rExtensionName ) const bool ExtMgrDialog::removeExtensionWarn(const OUString &rExtensionName)
{ {
const SolarMutexGuard guard; const SolarMutexGuard guard;
incBusy();
std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(), std::unique_ptr<weld::MessageDialog> xInfoBox(Application::CreateMessageDialog(GetFrameWeld(),
VclMessageType::Warning, VclButtonsType::OkCancel, VclMessageType::Warning, VclButtonsType::OkCancel,
DpResId(RID_STR_WARNING_REMOVE_EXTENSION))); DpResId(RID_STR_WARNING_REMOVE_EXTENSION)));
...@@ -599,7 +643,11 @@ bool ExtMgrDialog::removeExtensionWarn( const OUString &rExtensionName ) const ...@@ -599,7 +643,11 @@ bool ExtMgrDialog::removeExtensionWarn( const OUString &rExtensionName ) const
sText = sText.replaceAll("%NAME", rExtensionName); sText = sText.replaceAll("%NAME", rExtensionName);
xInfoBox->set_primary_text(sText); 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, void ExtMgrDialog::enablePackage( const uno::Reference< deployment::XPackage > &xPackage,
...@@ -903,7 +951,7 @@ IMPL_LINK_NOARG(ExtMgrDialog, HandleOptionsBtn, Button*, void) ...@@ -903,7 +951,7 @@ IMPL_LINK_NOARG(ExtMgrDialog, HandleOptionsBtn, Button*, void)
IMPL_LINK_NOARG(ExtMgrDialog, HandleAddBtn, Button*, void) IMPL_LINK_NOARG(ExtMgrDialog, HandleAddBtn, Button*, void)
{ {
setBusy( true ); incBusy();
uno::Sequence< OUString > aFileList = raiseAddPicker(); uno::Sequence< OUString > aFileList = raiseAddPicker();
...@@ -912,7 +960,7 @@ IMPL_LINK_NOARG(ExtMgrDialog, HandleAddBtn, Button*, void) ...@@ -912,7 +960,7 @@ IMPL_LINK_NOARG(ExtMgrDialog, HandleAddBtn, Button*, void)
m_pManager->installPackage( aFileList[0] ); m_pManager->installPackage( aFileList[0] );
} }
setBusy( false ); decBusy();
} }
IMPL_LINK_NOARG(ExtMgrDialog, HandleRemoveBtn, Button*, void) IMPL_LINK_NOARG(ExtMgrDialog, HandleRemoveBtn, Button*, void)
...@@ -1412,7 +1460,7 @@ void UpdateRequiredDialog::disableAllEntries() ...@@ -1412,7 +1460,7 @@ void UpdateRequiredDialog::disableAllEntries()
{ {
::osl::MutexGuard aGuard( m_aMutex ); ::osl::MutexGuard aGuard( m_aMutex );
setBusy( true ); incBusy();
long nCount = m_pExtensionBox->GetEntryCount(); long nCount = m_pExtensionBox->GetEntryCount();
for ( long nIndex = 0; nIndex < nCount; nIndex++ ) for ( long nIndex = 0; nIndex < nCount; nIndex++ )
...@@ -1421,7 +1469,7 @@ void UpdateRequiredDialog::disableAllEntries() ...@@ -1421,7 +1469,7 @@ void UpdateRequiredDialog::disableAllEntries()
m_pManager->getCmdQueue()->enableExtension( pEntry->m_xPackage, false ); m_pManager->getCmdQueue()->enableExtension( pEntry->m_xPackage, false );
} }
setBusy( false ); decBusy();
if ( ! hasActiveEntries() ) if ( ! hasActiveEntries() )
m_pCloseBtn->SetText( m_sCloseText ); m_pCloseBtn->SetText( m_sCloseText );
......
...@@ -58,18 +58,18 @@ class TheExtensionManager; ...@@ -58,18 +58,18 @@ class TheExtensionManager;
class DialogHelper class DialogHelper
{ {
css::uno::Reference< css::uno::XComponentContext > m_xContext; css::uno::Reference< css::uno::XComponentContext > m_xContext;
VclPtr<Dialog> m_pVCLWindow; VclPtr<Dialog> m_xVCLWindow;
ImplSVEvent * m_nEventID; ImplSVEvent * m_nEventID;
bool m_bIsBusy; int m_nBusy;
public: public:
DialogHelper( const css::uno::Reference< css::uno::XComponentContext > &, DialogHelper( const css::uno::Reference< css::uno::XComponentContext > &,
Dialog *pWindow ); Dialog *pWindow );
virtual ~DialogHelper(); virtual ~DialogHelper();
void openWebBrowser( const OUString & sURL, const OUString & sTitle ) const; void openWebBrowser(const OUString& rURL, const OUString& rTitle);
Dialog* getWindow() const { return m_pVCLWindow; }; Dialog* getWindow() const { return m_xVCLWindow; };
weld::Window* getFrameWeld() const { return m_pVCLWindow ? m_pVCLWindow->GetFrameWeld() : nullptr; } weld::Window* getFrameWeld() const { return m_xVCLWindow ? m_xVCLWindow->GetFrameWeld() : nullptr; }
void PostUserEvent( const Link<void*,void>& rLink, void* pCaller ); void PostUserEvent( const Link<void*,void>& rLink, void* pCaller );
void clearEventID() { m_nEventID = nullptr; } void clearEventID() { m_nEventID = nullptr; }
...@@ -86,15 +86,16 @@ public: ...@@ -86,15 +86,16 @@ public:
virtual void checkEntries() = 0; virtual void checkEntries() = 0;
static bool IsSharedPkgMgr( const css::uno::Reference< css::deployment::XPackage > &); 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, weld::Widget* pParent,
const char* pResID, const char* pResID,
bool &bHadWarning ); bool &bHadWarning );
void setBusy( const bool bBusy ) { m_bIsBusy = bBusy; } void incBusy();
bool isBusy() const { return m_bIsBusy; } void decBusy();
bool installExtensionWarn( const OUString &rExtensionURL ) const; bool isBusy() const { return m_nBusy > 0; }
bool installForAllUsers( bool &bInstallForAll ) const; bool installExtensionWarn(const OUString &rExtensionURL);
bool installForAllUsers(bool &bInstallForAll);
}; };
...@@ -134,7 +135,7 @@ class ExtMgrDialog : public ModelessDialog, ...@@ -134,7 +135,7 @@ class ExtMgrDialog : public ModelessDialog,
css::uno::Reference< css::task::XAbortChannel > m_xAbortChannel; 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( HandleOptionsBtn, Button*, void );
DECL_LINK( HandleAddBtn, Button*, void ); DECL_LINK( HandleAddBtn, Button*, void );
......
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