summaryrefslogtreecommitdiff
path: root/framework/source/services
diff options
context:
space:
mode:
authorMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-06-30 23:23:36 +0200
committerMarkus Mohrhard <markus.mohrhard@googlemail.com>2017-07-02 04:42:09 +0200
commit7250bc4721b334714bb0fa1345211c83330f94b2 (patch)
treebddb706179b4d7eee297544576f1ee4ccb307043 /framework/source/services
parent34c77d4bf3d2924c4ad26728d4c491b393fa0fc8 (diff)
notify the clipboard terminate listener before any other terminate listener
Otherwise we may have destroyed a service that is needed to generate one of the clipboard formats requested by the system clipboard. Change-Id: Id05de3ac569e3ed38cd97efc4c48326bc6a8db0b Reviewed-on: https://gerrit.libreoffice.org/39429 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Markus Mohrhard <markus.mohrhard@googlemail.com>
Diffstat (limited to 'framework/source/services')
-rw-r--r--framework/source/services/desktop.cxx44
1 files changed, 44 insertions, 0 deletions
diff --git a/framework/source/services/desktop.cxx b/framework/source/services/desktop.cxx
index 7c3c2e4b80d1..e96224815441 100644
--- a/framework/source/services/desktop.cxx
+++ b/framework/source/services/desktop.cxx
@@ -324,6 +324,10 @@ sal_Bool SAL_CALL Desktop::terminate()
aWriteLock.clear();
/* UNSAFE AREA ------------------------------------------------------------------------------------- */
+ // The clipboard listener needs to be the first. It can create copies of the
+ // existing document which needs basically all the available infrastructure.
+ impl_sendTerminateToClipboard();
+
impl_sendNotifyTerminationEvent();
{
SolarMutexGuard aGuard;
@@ -1630,6 +1634,46 @@ void Desktop::impl_sendCancelTerminationEvent(const Desktop::TTerminateListenerL
}
}
+void Desktop::impl_sendTerminateToClipboard()
+{
+ TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );
+
+ ::cppu::OInterfaceContainerHelper* pContainer = m_aListenerContainer.getContainer( cppu::UnoType<css::frame::XTerminateListener>::get());
+ if ( ! pContainer )
+ return;
+
+ ::cppu::OInterfaceIteratorHelper aIterator( *pContainer );
+ while ( aIterator.hasMoreElements() )
+ {
+ try
+ {
+ css::uno::Reference< css::lang::XServiceInfo > xInfo( aIterator.next(), css::uno::UNO_QUERY );
+ if ( !xInfo.is() )
+ continue;
+
+ if ( xInfo->getImplementationName() != "com.sun.star.comp.svt.TransferableHelperTerminateListener" )
+ continue;
+
+ css::uno::Reference< css::frame::XTerminateListener > xListener(xInfo, css::uno::UNO_QUERY);
+ if ( ! xListener.is() )
+ continue;
+
+ css::lang::EventObject aEvent( static_cast< ::cppu::OWeakObject* >(this) );
+ xListener->notifyTermination( aEvent );
+
+ // don't notify twice
+ aIterator.remove();
+ }
+ catch( const css::uno::Exception& )
+ {
+ // clean up container.
+ // E.g. dead remote listener objects can make trouble otherwise.
+ // Iterator implementation allows removing objects during it's used !
+ aIterator.remove();
+ }
+ }
+}
+
void Desktop::impl_sendNotifyTerminationEvent()
{
TransactionGuard aTransaction( m_aTransactionManager, E_HARDEXCEPTIONS );