summaryrefslogtreecommitdiff
path: root/filter/source/config/cache/lateinitlistener.cxx
diff options
context:
space:
mode:
authorVladimir Glazunov <vg@openoffice.org>2010-03-23 11:58:14 +0100
committerVladimir Glazunov <vg@openoffice.org>2010-03-23 11:58:14 +0100
commitb831dc7de1114c1568b6f14f89180fafc7cf11df (patch)
tree039e0dbb367c739beeca9b57c652883c9c74dae3 /filter/source/config/cache/lateinitlistener.cxx
parent85298fa82b939c0366c15b6488df7b8d4079ee9f (diff)
parent8122194ff0a27b467de23498483887fc2b760508 (diff)
CWS-TOOLING: integrate CWS autorecovery
Notes
Notes: split repo tag: filters_ooo/DEV300_m76
Diffstat (limited to 'filter/source/config/cache/lateinitlistener.cxx')
-rw-r--r--filter/source/config/cache/lateinitlistener.cxx14
1 files changed, 12 insertions, 2 deletions
diff --git a/filter/source/config/cache/lateinitlistener.cxx b/filter/source/config/cache/lateinitlistener.cxx
index feaf7f645efc..b9b090025227 100644
--- a/filter/source/config/cache/lateinitlistener.cxx
+++ b/filter/source/config/cache/lateinitlistener.cxx
@@ -56,7 +56,7 @@ LateInitListener::LateInitListener(const css::uno::Reference< css::lang::XMultiS
// important to do so ...
// Otherwhise the temp. reference to ourselves
// will kill us at realeasing time!
- ++m_refCount;
+ osl_incrementInterlockedCount( &m_refCount );
m_xBroadcaster = css::uno::Reference< css::document::XEventBroadcaster >(
m_xSMGR->createInstance(::rtl::OUString::createFromAscii("com.sun.star.frame.GlobalEventBroadcaster")),
@@ -64,7 +64,7 @@ LateInitListener::LateInitListener(const css::uno::Reference< css::lang::XMultiS
m_xBroadcaster->addEventListener(static_cast< css::document::XEventListener* >(this));
- --m_refCount;
+ osl_decrementInterlockedCount( &m_refCount );
}
/*-----------------------------------------------
@@ -92,6 +92,16 @@ void SAL_CALL LateInitListener::notifyEvent(const css::document::EventObject& aE
// SAFE ->
::osl::ResettableMutexGuard aLock(m_aLock);
+ if ( !m_xBroadcaster.is() )
+ // the beauty of multi-threading ... OnLoad can be notified synchronously or asynchronously. In particular,
+ // SFX-based documents notify it synchronously, database documents do it asynchronously.
+ // Now if multiple documents are opened "at the same time", it is well possible that we get two events from
+ // different threads, where upon the first event, we already remove ourself from m_xBroadcaster, and start
+ // the thread, nonetheless there's also a second notification "in the queue", which will arrive short
+ // thereafter.
+ // In such a case, simply ignore this second event.
+ return;
+
m_xBroadcaster->removeEventListener(static_cast< css::document::XEventListener* >(this));
m_xBroadcaster.clear();