diff options
| author | Eike Rathke <erack@redhat.com> | 2017-04-12 23:24:34 +0200 |
|---|---|---|
| committer | Eike Rathke <erack@redhat.com> | 2017-04-13 00:48:47 +0200 |
| commit | 06e427c24d75311c0ab79d2da586b961881db766 (patch) | |
| tree | ac0cd7408d219846b93115bfefd4775c6a26ebce | |
| parent | 6b4b2752fa876c219ee37a799b64211529f950e2 (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 20f2f485bfe4..ee8f82ee0a2c 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 ); @@ -1133,6 +1135,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 @@ -1140,6 +1143,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. |
