summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-01-19 11:22:06 +0000
committerCaolán McNamara <caolanm@redhat.com>2011-01-19 11:22:06 +0000
commit5d0fe3c2ee20168384330b59b3367c47a31225d6 (patch)
tree1417540a283bcfbc1edeacacc18c4fc5b844cb41 /framework
parent8a8985a8592d0f438a6cf7eb34fc9875f6b7a962 (diff)
Implement dispose and break circular dependency.
listener on configmgr means this dtor is never called.
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/services/pathsettings.hxx10
-rw-r--r--framework/source/services/pathsettings.cxx31
2 files changed, 39 insertions, 2 deletions
diff --git a/framework/inc/services/pathsettings.hxx b/framework/inc/services/pathsettings.hxx
index bdb4b9624a52..35bf79783dec 100644
--- a/framework/inc/services/pathsettings.hxx
+++ b/framework/inc/services/pathsettings.hxx
@@ -47,6 +47,7 @@
//_________________________________________________________________________________________________________________
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/lang/XTypeProvider.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
#include <com/sun/star/util/XStringSubstitution.hpp>
#include <com/sun/star/util/XChangesListener.hpp>
#include <com/sun/star/container/XNameAccess.hpp>
@@ -70,6 +71,7 @@ namespace framework
class PathSettings : public css::lang::XTypeProvider ,
public css::lang::XServiceInfo ,
+ public css::lang::XComponent ,
public css::util::XChangesListener , // => XEventListener
// base classes
// Order is neccessary for right initialization!
@@ -159,6 +161,9 @@ class PathSettings : public css::lang::XTypeProvider ,
/** provides access to the new configuration schema. */
css::uno::Reference< css::container::XNameAccess > m_xCfgNew;
+ /** container for ALL Listeners. */
+ ::cppu::OMultiTypeInterfaceContainerHelper m_aListenerContainer;
+
::cppu::OPropertyArrayHelper* m_pPropHelp;
::sal_Bool m_bIgnoreEvents;
@@ -182,6 +187,11 @@ class PathSettings : public css::lang::XTypeProvider ,
FWK_DECLARE_XTYPEPROVIDER
DECLARE_XSERVICEINFO
+ // css:lang::XComponent
+ void SAL_CALL dispose() throw ( ::com::sun::star::uno::RuntimeException );
+ void SAL_CALL addEventListener( const com::sun::star::uno::Reference< XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException );
+ void SAL_CALL removeEventListener( const com::sun::star::uno::Reference< XEventListener >& xListener ) throw( com::sun::star::uno::RuntimeException );
+
// css::util::XChangesListener
virtual void SAL_CALL changesOccurred(const css::util::ChangesEvent& aEvent) throw (css::uno::RuntimeException);
diff --git a/framework/source/services/pathsettings.cxx b/framework/source/services/pathsettings.cxx
index eaa4caca8195..6d9777a5ab04 100644
--- a/framework/source/services/pathsettings.cxx
+++ b/framework/source/services/pathsettings.cxx
@@ -48,6 +48,7 @@
#include <com/sun/star/container/XContainer.hpp>
#include <com/sun/star/beans/XPropertySet.hpp>
#include <com/sun/star/util/XChangesNotifier.hpp>
+#include <com/sun/star/lang/XComponent.hpp>
// ______________________________________________
// includes of other projects
@@ -98,10 +99,11 @@ namespace framework
//-----------------------------------------------------------------------------
// XInterface, XTypeProvider, XServiceInfo
-DEFINE_XINTERFACE_7 ( PathSettings ,
+DEFINE_XINTERFACE_8 ( PathSettings ,
OWeakObject ,
DIRECT_INTERFACE ( css::lang::XTypeProvider ),
DIRECT_INTERFACE ( css::lang::XServiceInfo ),
+ DIRECT_INTERFACE ( css::lang::XComponent ),
DERIVED_INTERFACE( css::lang::XEventListener, css::util::XChangesListener),
DIRECT_INTERFACE ( css::util::XChangesListener ),
DIRECT_INTERFACE ( css::beans::XPropertySet ),
@@ -109,10 +111,11 @@ DEFINE_XINTERFACE_7 ( PathSettings
DIRECT_INTERFACE ( css::beans::XMultiPropertySet )
)
-DEFINE_XTYPEPROVIDER_7 ( PathSettings ,
+DEFINE_XTYPEPROVIDER_8 ( PathSettings ,
css::lang::XTypeProvider ,
css::lang::XServiceInfo ,
css::lang::XEventListener ,
+ css::lang::XComponent ,
css::util::XChangesListener ,
css::beans::XPropertySet ,
css::beans::XFastPropertySet ,
@@ -150,6 +153,7 @@ PathSettings::PathSettings( const css::uno::Reference< css::lang::XMultiServiceF
, ::cppu::OWeakObject()
// Init member
, m_xSMGR (xSMGR)
+ , m_aListenerContainer(m_aLock.getShareableOslMutex())
, m_pPropHelp(0 )
, m_bIgnoreEvents(sal_False)
{
@@ -215,6 +219,29 @@ void SAL_CALL PathSettings::disposing(const css::lang::EventObject& aSource)
// <- SAFE
}
+void SAL_CALL PathSettings::dispose() throw (css::uno::RuntimeException)
+{
+ css::uno::Reference< css::util::XChangesNotifier > xBroadcaster(m_xCfgNew, css::uno::UNO_QUERY_THROW);
+ if (xBroadcaster.is())
+ xBroadcaster->removeChangesListener(static_cast< css::util::XChangesListener* >(this));
+
+ css::uno::Reference< css::uno::XInterface > xThis ( static_cast< ::cppu::OWeakObject* >(this), css::uno::UNO_QUERY );
+ css::lang::EventObject aEvent( xThis );
+ m_aListenerContainer.disposeAndClear( aEvent );
+}
+
+void SAL_CALL PathSettings::addEventListener(const css::uno::Reference< css::lang::XEventListener >& xListener)
+ throw (css::uno::RuntimeException)
+{
+ m_aListenerContainer.addInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >*) NULL ), xListener );
+}
+
+void SAL_CALL PathSettings::removeEventListener( const css::uno::Reference< css::lang::XEventListener >& xListener)
+ throw (css::uno::RuntimeException)
+{
+ m_aListenerContainer.addInterface( ::getCppuType( ( const css::uno::Reference< css::lang::XEventListener >*) NULL ), xListener );
+}
+
//-----------------------------------------------------------------------------
void PathSettings::impl_readAll()
{