From e192250454ef26d08894b3d46e561e9b0b9b44f0 Mon Sep 17 00:00:00 2001 From: Eike Rathke Date: Mon, 10 Apr 2017 23:31:14 +0200 Subject: finally free the SdrObject in ScCaptionPtr::decRefAndDestroy() There may be cases left still to be discovered where a setInUndo() is necessary in some Undo situations, but this is a start. Change-Id: Ic62267e3c3d24e4587343ff42da0292fbb166929 --- sc/source/core/data/postit.cxx | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index 447ee6def7df..757f87f6d9dc 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -691,18 +691,20 @@ void ScCaptionPtr::decRefAndDestroy() assert(mpHead->mpFirst == this); // this must be one and only one assert(!mpNext); // this must be one and only one assert(mpCaption); -#if 0 - if (what?) + + // Destroying Draw Undo deletes its SdrObject, don't attempt that twice. + if (!mbInUndo) { - /* FIXME: this should eventually remove the caption from drawing layer - * foo and call SdrObject::Free(), likely with mpCaption, see - * ScPostIt::RemoveCaption(). Further work needed to be able to do so. - * */ + removeFromDrawPageAndFree( true ); // ignoring Undo + if (mpCaption) + { + // There's no draw page associated so removeFromDrawPageAndFree() + // didn't do anything, but still we want to delete the caption + // object. release()/dissolve() also resets mpCaption. + SdrObject* pObj = release(); + SdrObject::Free( pObj ); + } } - /* FIXME: once we got ownership right */ - //SdrObject::Free( mpCaption ); -#endif - mpCaption = nullptr; delete mpHead; mpHead = nullptr; } -- cgit v1.2.3