Author: zhangjf
Date: Mon Jun 18 13:26:30 2012
New Revision: 1351332
URL: http://svn.apache.org/viewvc?rev=1351332&view=rev
Log:
#113608#, memory leak in animations: All animation nodes are leaked and new
exposed crashed problem
Patch by: zhangjf
Review by: Andre Fischer
Modified:
incubator/ooo/trunk/main/animations/source/animcore/animcore.cxx
incubator/ooo/trunk/main/svx/inc/svx/svdobj.hxx
incubator/ooo/trunk/main/svx/source/svdraw/svdobj.cxx
Modified: incubator/ooo/trunk/main/animations/source/animcore/animcore.cxx
URL:
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/animations/source/animcore/animcore.cxx?rev=1351332&r1=1351331&r2=1351332&view=diff
==============================================================================
--- incubator/ooo/trunk/main/animations/source/animcore/animcore.cxx (original)
+++ incubator/ooo/trunk/main/animations/source/animcore/animcore.cxx Mon Jun 18
13:26:30 2012
@@ -49,6 +49,7 @@
#include <com/sun/star/util/XChangesNotifier.hpp>
#include <com/sun/star/lang/XUnoTunnel.hpp>
#include <cppuhelper/interfacecontainer.hxx>
+#include <cppuhelper/weakref.hxx>
#include <cppuhelper/implbase1.hxx>
#include <rtl/uuid.h>
@@ -68,6 +69,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;
@@ -307,7 +309,7 @@ private:
Sequence< NamedValue > maUserData;
// parent interface for XChild interface implementation
- Reference<XInterface> mxParent;
+ WeakReference<XInterface> mxParent;
AnimationNode* mpParent;
// attributes for XAnimate
@@ -1141,7 +1143,7 @@ void SAL_CALL AnimationNode::setUserData
Reference< XInterface > SAL_CALL AnimationNode::getParent() throw
(RuntimeException)
{
Guard< Mutex > aGuard( maMutex );
- return mxParent;
+ return mxParent.get();
}
// --------------------------------------------------------------------
@@ -1150,12 +1152,12 @@ Reference< XInterface > SAL_CALL Animati
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() )));
@@ -2067,7 +2069,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 );
Modified: incubator/ooo/trunk/main/svx/inc/svx/svdobj.hxx
URL:
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/inc/svx/svdobj.hxx?rev=1351332&r1=1351331&r2=1351332&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/inc/svx/svdobj.hxx (original)
+++ incubator/ooo/trunk/main/svx/inc/svx/svdobj.hxx Mon Jun 18 13:26:30 2012
@@ -1127,7 +1127,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;
Modified: incubator/ooo/trunk/main/svx/source/svdraw/svdobj.cxx
URL:
http://svn.apache.org/viewvc/incubator/ooo/trunk/main/svx/source/svdraw/svdobj.cxx?rev=1351332&r1=1351331&r2=1351332&view=diff
==============================================================================
--- incubator/ooo/trunk/main/svx/source/svdraw/svdobj.cxx (original)
+++ incubator/ooo/trunk/main/svx/source/svdraw/svdobj.cxx Mon Jun 18 13:26:30
2012
@@ -2914,17 +2914,20 @@ void SdrObject::impl_setUnoShape( const
}
/** 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
// guarded by the SolarMutex
-#if OSL_DEBUG_LEVE > 0
uno::Reference< uno::XInterface > xShape( maWeakUnoShape );
- OSL_ENSURE( !( !xShapeGuard.is() && mpSvxShape ),
+#if OSL_DEBUG_LEVE > 0
+ 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;
}