diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-04-04 13:01:01 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-04-06 18:21:32 +0200 |
commit | 365f2c072d00246a158725148942160435d892ed (patch) | |
tree | 3ee2bb49eed98b8c94c3192848ffbd51a739f6a6 | |
parent | 0a3454590e124523fb76e94ecc724bf5ae1b075b (diff) |
SOSAW080: Free SdrObjects when SdrModel goes down
In an UNO API test problem is that SvxShapes reference
SdrShapes, but these are not added to a SdrPage and not
'owned' by the SvxShape. Thus these do not get deleted
at all (same in master, memory leak). I extended
SvxShape::Notify the case for ModelCleared to also
Free the SdrObject when not owner and it's not added to
a SdrPage (in that case it gets deleted with deleting
the SdrModel)
Change-Id: I7b5c241faec7488924e5935ae8b19f785846b5e4
-rw-r--r-- | svx/source/unodraw/unoshape.cxx | 25 |
1 files changed, 19 insertions, 6 deletions
diff --git a/svx/source/unodraw/unoshape.cxx b/svx/source/unodraw/unoshape.cxx index ba0aa389a447..c726444e814d 100644 --- a/svx/source/unodraw/unoshape.cxx +++ b/svx/source/unodraw/unoshape.cxx @@ -1019,17 +1019,30 @@ void SvxShape::Notify( SfxBroadcaster&, const SfxHint& rHint ) throw() if( bClearMe ) { - if( !HasSdrObjectOwnership() ) { - if( HasSdrObject() ) + SdrObject* pSdrObject(GetSdrObject()); + + if(!HasSdrObjectOwnership()) + { + if(nullptr != pSdrObject) { - EndListening(GetSdrObject()->getSdrModelFromSdrObject()); - GetSdrObject()->setUnoShape( nullptr ); + EndListening(pSdrObject->getSdrModelFromSdrObject()); + pSdrObject->setUnoShape(nullptr); } - mpSdrObjectWeakReference.reset( nullptr ); + mpSdrObjectWeakReference.reset(nullptr); + + // SdrModel *is* going down, try to Free SdrObject even + // when !HasSdrObjectOwnership + if(nullptr != pSdrObject && !pSdrObject->IsInserted()) + { + SdrObject::Free(pSdrObject); + } } - if ( !mpImpl->mbDisposing ) + + if(!mpImpl->mbDisposing) + { dispose(); + } } } |