diff options
author | Jian Fang Zhang <zhangjf@apache.org> | 2012-06-18 12:26:30 +0000 |
---|---|---|
committer | Eike Rathke <erack@redhat.com> | 2013-03-14 14:35:41 +0100 |
commit | d6e752d5ebfaf66d1c9b0694f9c8582311d6151a (patch) | |
tree | 7c415ddf3e38ab62a1a4a38bc415b6782963fdaa | |
parent | b6e60d3eb5c21a98dfa86fde0bb695986058f463 (diff) |
i#113608#, memory leak in animations: newly exposed crashed problem
Patch by: zhangjf
Review by: Andre Fischer
Conflicts:
animations/source/animcore/animcore.cxx
svx/source/svdraw/svdobj.cxx
Change-Id: I305d5d92d064265edf108a5a34c948c610b4fdc1
-rw-r--r-- | animations/source/animcore/animcore.cxx | 13 | ||||
-rw-r--r-- | svx/inc/svx/svdobj.hxx | 2 | ||||
-rw-r--r-- | svx/source/svdraw/svdobj.cxx | 5 |
3 files changed, 13 insertions, 7 deletions
diff --git a/animations/source/animcore/animcore.cxx b/animations/source/animcore/animcore.cxx index 6307f30d4168..a503097f07d5 100644 --- a/animations/source/animcore/animcore.cxx +++ b/animations/source/animcore/animcore.cxx @@ -46,6 +46,8 @@ #include <com/sun/star/lang/XUnoTunnel.hpp> #include <comphelper/servicehelper.hxx> #include <cppuhelper/interfacecontainer.hxx> +#include <cppuhelper/weakref.hxx> + #include <cppuhelper/implbase1.hxx> #include <rtl/uuid.h> @@ -64,6 +66,7 @@ using ::com::sun::star::uno::XInterface; using ::com::sun::star::uno::RuntimeException; using ::com::sun::star::uno::Sequence; using ::com::sun::star::uno::Reference; +using ::com::sun::star::uno::WeakReference; using ::com::sun::star::uno::XComponentContext; using ::com::sun::star::uno::Exception; using ::com::sun::star::uno::XWeak; @@ -300,7 +303,7 @@ private: Sequence< NamedValue > maUserData; // parent interface for XChild interface implementation - Reference<XInterface> mxParent; + WeakReference<XInterface> mxParent; AnimationNode* mpParent; // attributes for XAnimate @@ -1134,7 +1137,7 @@ void SAL_CALL AnimationNode::setUserData( const Sequence< NamedValue >& _userdat Reference< XInterface > SAL_CALL AnimationNode::getParent() throw (RuntimeException) { Guard< Mutex > aGuard( maMutex ); - return mxParent; + return mxParent.get(); } // -------------------------------------------------------------------- @@ -1143,12 +1146,12 @@ Reference< XInterface > SAL_CALL AnimationNode::getParent() throw (RuntimeExcept void SAL_CALL AnimationNode::setParent( const Reference< XInterface >& Parent ) throw (NoSupportException, RuntimeException) { Guard< Mutex > aGuard( maMutex ); - if( Parent != mxParent ) + if( Parent != mxParent.get() ) { mxParent = Parent; mpParent = 0; - Reference< XUnoTunnel > xTunnel( mxParent, UNO_QUERY ); + Reference< XUnoTunnel > xTunnel( mxParent.get(), UNO_QUERY ); if( xTunnel.is() ) mpParent = reinterpret_cast< AnimationNode* >( sal::static_int_cast< sal_IntPtr >(xTunnel->getSomething( getUnoTunnelId() ))); @@ -2050,7 +2053,7 @@ void AnimationNode::fireChangeListener() { Reference< XInterface > xSource( static_cast<OWeakObject*>(this), UNO_QUERY ); Sequence< ElementChange > aChanges; - const ChangesEvent aEvent( xSource, makeAny( mxParent ), aChanges ); + const ChangesEvent aEvent( xSource, makeAny( mxParent.get() ), aChanges ); while( aIterator.hasMoreElements() ) { Reference< XChangesListener > xListener( aIterator.next(), UNO_QUERY ); diff --git a/svx/inc/svx/svdobj.hxx b/svx/inc/svx/svdobj.hxx index 75cc0e482a45..27a4568ed40e 100644 --- a/svx/inc/svx/svdobj.hxx +++ b/svx/inc/svx/svdobj.hxx @@ -1072,7 +1072,7 @@ protected: private: /** only for internal use! */ - SvxShape* getSvxShape() const; + SvxShape* getSvxShape(); /** do not use directly, always use getSvxShape() if you have to! */ SvxShape* mpSvxShape; diff --git a/svx/source/svdraw/svdobj.cxx b/svx/source/svdraw/svdobj.cxx index e35c9940fc0b..1e52b4f77a06 100644 --- a/svx/source/svdraw/svdobj.cxx +++ b/svx/source/svdraw/svdobj.cxx @@ -2963,7 +2963,7 @@ void SdrObject::impl_setUnoShape( const uno::Reference< uno::XInterface >& _rxUn } /** only for internal use! */ -SvxShape* SdrObject::getSvxShape() const +SvxShape* SdrObject::getSvxShape() { DBG_TESTSOLARMUTEX(); // retrieving the impl pointer and subsequently using it is not thread-safe, of course, so it needs to be @@ -2974,6 +2974,9 @@ SvxShape* SdrObject::getSvxShape() const OSL_ENSURE( !( !xShape.is() && mpSvxShape ), "SdrObject::getSvxShape: still having IMPL-Pointer to dead object!" ); #endif + //#113608#, make sure mpSvxShape is always synchronized with maWeakUnoShape + if ( mpSvxShape && !xShape.is() ) + mpSvxShape = NULL; return mpSvxShape; } |