[Libreoffice-commits] core.git: Branch 'libreoffice-6-1' - desktop/source

Libreoffice Gerrit user logerrit at kemper.freedesktop.org
Thu Nov 29 15:47:35 UTC 2018


 desktop/source/deployment/gui/dp_gui_dialog2.cxx |   84 ++++++++++++++++++-----
 desktop/source/deployment/gui/dp_gui_dialog2.hxx |   23 +++---
 2 files changed, 78 insertions(+), 29 deletions(-)

New commits:
commit d559d7085f8c160c9946ef3eb49250aa12358968
Author:     Caolán McNamara <caolanm at redhat.com>
AuthorDate: Wed Nov 28 11:12:55 2018 +0000
Commit:     Xisco Faulí <xiscofauli at libreoffice.org>
CommitDate: Thu Nov 29 16:47:09 2018 +0100

    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/64162
    Tested-by: Jenkins
    Reviewed-by: Xisco Faulí <xiscofauli at libreoffice.org>

diff --git a/desktop/source/deployment/gui/dp_gui_dialog2.cxx b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
index 9330789548e4..fc0f955f2afd 100644
--- a/desktop/source/deployment/gui/dp_gui_dialog2.cxx
+++ b/desktop/source/deployment/gui/dp_gui_dialog2.cxx
@@ -335,16 +335,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 )
@@ -365,17 +364,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;
@@ -392,29 +395,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)));
@@ -422,15 +431,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;
 
@@ -446,6 +461,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)
@@ -587,9 +630,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)));
@@ -598,7 +642,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,
@@ -905,7 +953,7 @@ IMPL_LINK_NOARG(ExtMgrDialog, HandleOptionsBtn, Button*, void)
 
 IMPL_LINK_NOARG(ExtMgrDialog, HandleAddBtn, Button*, void)
 {
-    setBusy( true );
+    incBusy();
 
     uno::Sequence< OUString > aFileList = raiseAddPicker();
 
@@ -914,7 +962,7 @@ IMPL_LINK_NOARG(ExtMgrDialog, HandleAddBtn, Button*, void)
         m_pManager->installPackage( aFileList[0] );
     }
 
-    setBusy( false );
+    decBusy();
 }
 
 IMPL_LINK_NOARG(ExtMgrDialog, HandleRemoveBtn, Button*, void)
@@ -1418,7 +1466,7 @@ void UpdateRequiredDialog::disableAllEntries()
 {
     ::osl::MutexGuard aGuard( m_aMutex );
 
-    setBusy( true );
+    incBusy();
 
     long nCount = m_pExtensionBox->GetEntryCount();
     for ( long nIndex = 0; nIndex < nCount; nIndex++ )
@@ -1427,7 +1475,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 );


More information about the Libreoffice-commits mailing list