summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-01-09 05:58:00 +0100
committerMichael Stahl <mstahl@redhat.com>2017-01-11 19:36:58 +0000
commit2f0020ba056e2b523c487dc42b40f0e4b9f9a9b0 (patch)
treedb5a88e31a3de5bbd454d99f720ea8992d7a4f8c /framework
parent3defbf74b7fee3e3f9bada7e2721bf97405ac264 (diff)
tdf#104830, need an own termination listener for lib objects
The destruction of the SwDLL object happens already through the normal termination listener but the other termination listeners might still depend on it. Also the outstanding events might need the SwDLL instance to be still around. This makes the destruction of the instance explicit and at a time when it should be safe. We should use the same code for calc, impress, math and base as well. Change-Id: I50b8f30426f5a4a54e362e748fe962839abca73e Reviewed-on: https://gerrit.libreoffice.org/32856 Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk> Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com> (cherry picked from commit ad915fafd54f9115faea7147f82d80a942af2d68) Reviewed-on: https://gerrit.libreoffice.org/32928 Reviewed-by: Michael Meeks <michael.meeks@collabora.com> Reviewed-by: Michael Stahl <mstahl@redhat.com>
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/services/desktop.hxx2
-rw-r--r--framework/source/services/desktop.cxx29
2 files changed, 31 insertions, 0 deletions
diff --git a/framework/inc/services/desktop.hxx b/framework/inc/services/desktop.hxx
index e8fd0017d628..bd766e8fdc5f 100644
--- a/framework/inc/services/desktop.hxx
+++ b/framework/inc/services/desktop.hxx
@@ -454,6 +454,8 @@ class Desktop : private cppu::BaseMutex,
css::uno::Reference< css::frame::XUntitledNumbers > m_xTitleNumberGenerator;
+ std::vector<css::uno::Reference<css::frame::XTerminateListener>> m_xComponentDllListeners;
+
}; // class Desktop
} // namespace framework
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index 3e5f3a0242bc..18eecb3a3ead 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -335,6 +335,14 @@ sal_Bool SAL_CALL Desktop::terminate()
if ( xPipeTerminator.is() )
xPipeTerminator->notifyTermination( aEvent );
+ // we need a copy here as the notifyTermination call might cause a removeTerminateListener call
+ std::vector< css::uno::Reference<css::frame::XTerminateListener> > xComponentDllListeners = m_xComponentDllListeners;
+ for (auto& xListener : xComponentDllListeners)
+ {
+ xListener->notifyTermination(aEvent);
+ }
+ m_xComponentDllListeners.clear();
+
// Must be really the last listener to be called.
// Because it shutdown the whole process asynchronous !
if ( xSfxTerminator.is() )
@@ -407,6 +415,11 @@ void SAL_CALL Desktop::addTerminateListener( const css::uno::Reference< css::fra
m_xSWThreadManager = xListener;
return;
}
+ else if ( sImplementationName == "com.sun.star.comp.ComponentDLLListener" )
+ {
+ m_xComponentDllListeners.push_back(xListener);
+ return;
+ }
}
// No lock required ... container is threadsafe by itself.
@@ -448,6 +461,13 @@ void SAL_CALL Desktop::removeTerminateListener( const css::uno::Reference< css::
m_xSWThreadManager.clear();
return;
}
+ else if (sImplementationName == "com.sun.star.comp.ComponentDLLListener")
+ {
+ m_xComponentDllListeners.erase(
+ std::remove(m_xComponentDllListeners.begin(), m_xComponentDllListeners.end(), xListener),
+ m_xComponentDllListeners.end());
+ return;
+ }
}
// No lock required ... container is threadsafe by itself.
@@ -1076,6 +1096,15 @@ void SAL_CALL Desktop::disposing()
m_xPipeTerminator.clear();
m_xQuickLauncher.clear();
m_xSWThreadManager.clear();
+
+ // we need a copy because the notifyTermination might call the removeEventListener method
+ std::vector< css::uno::Reference<css::frame::XTerminateListener> > xComponentDllListeners = m_xComponentDllListeners;
+ for (auto& xListener: xComponentDllListeners)
+ {
+ xListener->notifyTermination(aEvent);
+ }
+ xComponentDllListeners.clear();
+ m_xComponentDllListeners.clear();
m_xSfxTerminator.clear();
m_xCommandOptions.reset();