summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEike Rathke <erack@redhat.com>2017-04-10 23:31:14 +0200
committerHenry Castro <hcastro@collabora.com>2017-05-02 20:35:22 -0400
commite192250454ef26d08894b3d46e561e9b0b9b44f0 (patch)
tree35cab8a767440a4e266c6cc3aeea542a49ec5058
parentc237b3366c7a2b5c07406615cbcf5c08210c5cb3 (diff)
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
-rw-r--r--sc/source/core/data/postit.cxx22
1 files 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;
}