diff options
author | Eike Rathke <erack@redhat.com> | 2017-04-12 23:24:34 +0200 |
---|---|---|
committer | Jan Holesovsky <kendy@collabora.com> | 2017-05-15 21:59:12 +0200 |
commit | 5ef67aa7c9a4f370b091fdf4b280596d5668553a (patch) | |
tree | d491c61ddf73e29a2f9e82dddc40093cf250e0a1 | |
parent | b7280da0b67cc53bfb8d384389832cfdef4a9b48 (diff) |
control deletion of SdrCaptionObj within ScCaptionPtr by refcount
I guess this is about the first time ever that repeated Undo and Redo of
Cut&Paste of a cell comment does not crash..
Change-Id: I493a0a5439efde133a07d73ddcbcdf5bda4bc276
-rw-r--r-- | sc/source/core/data/postit.cxx | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx index b48bdcf8d206..310bddfa606f 100644 --- a/sc/source/core/data/postit.cxx +++ b/sc/source/core/data/postit.cxx @@ -761,7 +761,9 @@ void ScCaptionPtr::removeFromDrawPageAndFree( bool bIgnoreUndo ) } // remove the object from the drawing page, delete if undo is disabled removeFromDrawPage( *pDrawPage ); - if (!bRecording) + // If called from outside mnRefs must be 1 to delete. If called from + // decRefAndDestroy() mnRefs is already 0. + if (!bRecording && getRefs() <= 1) { SdrObject* pObj = release(); SdrObject::Free( pObj ); @@ -1136,6 +1138,7 @@ void ScPostIt::RemoveCaption() if (pDrawLayer == maNoteData.mxCaption->GetModel()) maNoteData.mxCaption.removeFromDrawPageAndFree(); +#if 0 // Either the caption object is gone or, because of Undo or clipboard is // held in at least two instances, or only one instance in Undo because the // original sheet in this document is just deleted, or the Undo document is @@ -1143,6 +1146,7 @@ void ScPostIt::RemoveCaption() // Let's detect other use cases.. assert(!maNoteData.mxCaption || maNoteData.mxCaption.getRefs() >= 2 || (!mrDoc.IsUndo() && !mrDoc.IsClipboard()) || (mrDoc.IsUndo() && mrDoc.IsInDtorClear())); +#endif // Forget the caption object if removeFromDrawPageAndFree() above did not // free it. |