desktop/source/deployment/gui/dp_gui_theextmgr.cxx |   67 +++------------------
 1 file changed, 12 insertions(+), 55 deletions(-)

New commits:
commit 5a6985c124c7a0ca246fbc920ab5e024d72a5e4a
Author:     Michael Weghorn <[email protected]>
AuthorDate: Sat Nov 8 09:42:17 2025 +0100
Commit:     Michael Weghorn <[email protected]>
CommitDate: Mon Nov 10 09:05:37 2025 +0100

    tdf#169318 extension mgr: Deduplicate close logic
    
    Basically the same logic was duplicated
    multiple times.
    
    Update TheExtensionManager::Close with the
    slightly extended logic used in
    TheExtensionManager::disposing (and in most
    places) and call that method from the other
    places instead of reimplementing the same
    logic 5 times.
    
    Change-Id: I5cca8aa0dff5e5ea5d4470be33dc432997df3b51
    Reviewed-on: https://gerrit.libreoffice.org/c/core/+/193615
    Reviewed-by: Michael Weghorn <[email protected]>
    Tested-by: Jenkins

diff --git a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx 
b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
index d5ced48ba205..577ad889d018 100644
--- a/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
+++ b/desktop/source/deployment/gui/dp_gui_theextmgr.cxx
@@ -102,20 +102,7 @@ TheExtensionManager::TheExtensionManager( uno::Reference< 
awt::XWindow > xParent
 
 TheExtensionManager::~TheExtensionManager()
 {
-    if (m_xUpdReqDialog)
-        m_xUpdReqDialog->response(RET_CANCEL);
-    assert(!m_xUpdReqDialog);
-    if (m_xExtMgrDialog)
-    {
-        if (m_bExtMgrDialogExecuting)
-            m_xExtMgrDialog->response(RET_CANCEL);
-        else
-        {
-            m_xExtMgrDialog->Close();
-            m_xExtMgrDialog.reset();
-        }
-    }
-    assert(!m_xExtMgrDialog);
+    Close();
 }
 
 void TheExtensionManager::createDialog( const bool bCreateUpdDlg )
@@ -178,12 +165,19 @@ void TheExtensionManager::Close()
     if (m_xExtMgrDialog)
     {
         if (m_bExtMgrDialogExecuting)
+        {
             m_xExtMgrDialog->response(RET_CANCEL);
+        }
         else
+        {
             m_xExtMgrDialog->Close();
+            m_xExtMgrDialog.reset();
+        }
     }
-    else if (m_xUpdReqDialog)
+    assert(!m_xExtMgrDialog);
+    if (m_xUpdReqDialog)
         m_xUpdReqDialog->response(RET_CANCEL);
+    assert(!m_xUpdReqDialog);
 }
 
 sal_Int16 TheExtensionManager::execute()
@@ -271,20 +265,7 @@ void TheExtensionManager::terminateDialog()
         return;
 
     const SolarMutexGuard guard;
-    if (m_xExtMgrDialog)
-    {
-        if (m_bExtMgrDialogExecuting)
-            m_xExtMgrDialog->response(RET_CANCEL);
-        else
-        {
-            m_xExtMgrDialog->Close();
-            m_xExtMgrDialog.reset();
-        }
-    }
-    assert(!m_xExtMgrDialog);
-    if (m_xUpdReqDialog)
-        m_xUpdReqDialog->response(RET_CANCEL);
-    assert(!m_xUpdReqDialog);
+    Close();
     Application::Quit();
 }
 
@@ -443,20 +424,7 @@ void TheExtensionManager::disposing( lang::EventObject 
const & rEvt )
     if ( dp_misc::office_is_running() )
     {
         const SolarMutexGuard guard;
-        if (m_xExtMgrDialog)
-        {
-            if (m_bExtMgrDialogExecuting)
-                m_xExtMgrDialog->response(RET_CANCEL);
-            else
-            {
-                m_xExtMgrDialog->Close();
-                m_xExtMgrDialog.reset();
-            }
-        }
-        assert(!m_xExtMgrDialog);
-        if (m_xUpdReqDialog)
-            m_xUpdReqDialog->response(RET_CANCEL);
-        assert(!m_xUpdReqDialog);
+        Close();
     }
     s_ExtMgr.clear();
 }
@@ -476,18 +444,7 @@ void TheExtensionManager::queryTermination( 
::lang::EventObject const & )
     else
     {
         clearModified();
-        if (m_xExtMgrDialog)
-        {
-            if (m_bExtMgrDialogExecuting)
-                m_xExtMgrDialog->response(RET_CANCEL);
-            else
-            {
-                m_xExtMgrDialog->Close();
-                m_xExtMgrDialog.reset();
-            }
-        }
-        if (m_xUpdReqDialog)
-            m_xUpdReqDialog->response(RET_CANCEL);
+        Close();
     }
 }
 

Reply via email to