animations/source/animcore/animcore.cxx | 13 ++++++++----- svx/inc/svx/svdobj.hxx | 2 +- svx/source/svdraw/svdobj.cxx | 5 ++++- 3 files changed, 13 insertions(+), 7 deletions(-)
New commits: commit d6e752d5ebfaf66d1c9b0694f9c8582311d6151a Author: Jian Fang Zhang <zhan...@apache.org> Date: Mon Jun 18 12:26:30 2012 +0000 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 diff --git a/animations/source/animcore/animcore.cxx b/animations/source/animcore/animcore.cxx index 6307f30..a503097 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 75cc0e4..27a4568 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 e35c994..1e52b4f 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; } _______________________________________________ Libreoffice-commits mailing list libreoffice-comm...@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits