summaryrefslogtreecommitdiff
path: root/sfx2
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2011-04-06 13:43:46 +0100
committerCaolán McNamara <caolanm@redhat.com>2011-04-06 14:09:04 +0100
commit900bc2c56ae5ba21edafccccfd68619e1006b79b (patch)
tree047a602c326335779c8a7394e0710274184bb953 /sfx2
parent9f877a81350edd875a09c0d68a99096e72ef5fef (diff)
fix ownership cycle and leak
Diffstat (limited to 'sfx2')
-rw-r--r--sfx2/source/bastyp/fltfnc.cxx8
-rw-r--r--sfx2/source/bastyp/fltlst.cxx36
-rw-r--r--sfx2/source/bastyp/fltlst.hxx15
3 files changed, 47 insertions, 12 deletions
diff --git a/sfx2/source/bastyp/fltfnc.cxx b/sfx2/source/bastyp/fltfnc.cxx
index 533320e64acd..36b812d24f76 100644
--- a/sfx2/source/bastyp/fltfnc.cxx
+++ b/sfx2/source/bastyp/fltfnc.cxx
@@ -92,6 +92,7 @@
#include <tools/urlobj.hxx>
#include <rtl/logfile.hxx>
+#include <rtl/instance.hxx>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::ucb;
@@ -122,13 +123,18 @@ using namespace ::com::sun::star::beans;
#include <sfx2/appuno.hxx>
#include <sfx2/viewfrm.hxx>
+namespace
+{
+ class theSfxFilterListener : public rtl::Static<SfxFilterListener, theSfxFilterListener> {};
+}
+
static SfxFilterList_Impl* pFilterArr = 0;
static sal_Bool bFirstRead = sal_True;
static void CreateFilterArr()
{
pFilterArr = new SfxFilterList_Impl;
- new SfxFilterListener();
+ theSfxFilterListener::get();
}
//----------------------------------------------------------------
diff --git a/sfx2/source/bastyp/fltlst.cxx b/sfx2/source/bastyp/fltlst.cxx
index 3fc966c45d8e..16f1ccf64d20 100644
--- a/sfx2/source/bastyp/fltlst.cxx
+++ b/sfx2/source/bastyp/fltlst.cxx
@@ -49,6 +49,39 @@
//*****************************************************************************************************************
using namespace ::com::sun::star;
+
+class SfxRefreshListener : public ::cppu::WeakImplHelper1<com::sun::star::util::XRefreshListener>
+{
+ private:
+ SfxFilterListener *m_pOwner;
+
+ public:
+ SfxRefreshListener(SfxFilterListener *pOwner)
+ : m_pOwner(pOwner)
+ {
+ }
+
+ virtual ~SfxRefreshListener()
+ {
+ }
+
+ // util.XRefreshListener
+ virtual void SAL_CALL refreshed( const ::com::sun::star::lang::EventObject& rEvent )
+ throw(com::sun::star::uno::RuntimeException)
+ {
+ m_pOwner->refreshed(rEvent);
+ }
+
+ // lang.XEventListener
+ virtual void SAL_CALL disposing(const com::sun::star::lang::EventObject& rEvent)
+ throw(com::sun::star::uno::RuntimeException)
+ {
+ m_pOwner->disposing(rEvent);
+ }
+};
+
+
+
//*****************************************************************************************************************
// definitions
//*****************************************************************************************************************
@@ -85,7 +118,8 @@ SfxFilterListener::SfxFilterListener()
if( xNotifier.is() == sal_True )
{
m_xFilterCache = xNotifier;
- m_xFilterCache->addRefreshListener( this );
+ m_xFilterCacheListener = new SfxRefreshListener(this);
+ m_xFilterCache->addRefreshListener( m_xFilterCacheListener );
}
}
}
diff --git a/sfx2/source/bastyp/fltlst.hxx b/sfx2/source/bastyp/fltlst.hxx
index 02af4663037c..e7d010bbbcd7 100644
--- a/sfx2/source/bastyp/fltlst.hxx
+++ b/sfx2/source/bastyp/fltlst.hxx
@@ -42,28 +42,23 @@
#include <com/sun/star/lang/EventObject.hpp>
#include <com/sun/star/uno/RuntimeException.hpp>
-//*****************************************************************************************************************
-// declarations
-//*****************************************************************************************************************
-class SfxFilterListener : public ::cppu::WeakImplHelper1< ::com::sun::star::util::XRefreshListener >
+class SfxFilterListener
{
- // member
private:
::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshable > m_xFilterCache;
+ ::com::sun::star::uno::Reference< ::com::sun::star::util::XRefreshListener > m_xFilterCacheListener;
- // c++ interface
public:
- SfxFilterListener();
- ~SfxFilterListener();
+ SfxFilterListener();
+ ~SfxFilterListener();
- // uno interface
public:
// XRefreshListener
virtual void SAL_CALL refreshed( const ::com::sun::star::lang::EventObject& aSource ) throw( ::com::sun::star::uno::RuntimeException );
// XEventListener
virtual void SAL_CALL disposing( const ::com::sun::star::lang::EventObject& aSource ) throw( ::com::sun::star::uno::RuntimeException );
-}; // SfxFilterListener
+};
#endif // _SFX_FLTLST_HXX