diff options
author | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-05-04 11:21:15 +0200 |
---|---|---|
committer | Armin Le Grand <Armin.Le.Grand@cib.de> | 2018-05-04 14:48:38 +0200 |
commit | 0fe7bda233da3c1f95a82c0050c8f917dc39c22e (patch) | |
tree | dbead2885836e74023813cd2b99760155f5e403d /svx | |
parent | b72a31b37f9bdcfd3f59b3256b465bf0fb5a50ca (diff) |
tdf#116879 Separate SdrObjList::Clear() as needed
SdrObjList::Clear() does broadcast the SdrObject
removals and deletions and a SetChanged() to SdrModel.
The old version avoided this in the destructor (with
a comment to not call virtual methods in destructor,
but the problem is more that the ::Notify triggered
works on the SdrPage already in destruction). To allow
calls to Clear() without broadcasting I splitted this
to a impClearSdrObjList(bool bBrodacast) and rename
of ::Clear to ::ClearSdrObjList to get all places.
Adapted all places in the code as needed, already pre-
checked on Linux that this fixes the problem.
Change-Id: Iea46758fb6b57f2b3d9896959a35260c6f6d52d5
Reviewed-on: https://gerrit.libreoffice.org/53839
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Armin Le Grand <Armin.Le.Grand@cib.de>
Diffstat (limited to 'svx')
-rw-r--r-- | svx/source/dialog/contwnd.cxx | 3 | ||||
-rw-r--r-- | svx/source/dialog/imapwnd.cxx | 4 | ||||
-rw-r--r-- | svx/source/svdraw/svdpage.cxx | 82 |
3 files changed, 51 insertions, 38 deletions
diff --git a/svx/source/dialog/contwnd.cxx b/svx/source/dialog/contwnd.cxx index 4ac1e23083d5..014a10d9e472 100644 --- a/svx/source/dialog/contwnd.cxx +++ b/svx/source/dialog/contwnd.cxx @@ -54,7 +54,8 @@ void ContourWindow::SetPolyPolygon(const tools::PolyPolygon& rPolyPoly) // them first (!) pView->UnmarkAllObj(); - pPage->Clear(); + // clear SdrObjects with broadcasting + pPage->ClearSdrObjList(); for (sal_uInt16 i = 0; i < nPolyCount; i++) { diff --git a/svx/source/dialog/imapwnd.cxx b/svx/source/dialog/imapwnd.cxx index 3e3f1667fbf2..6275842c6791 100644 --- a/svx/source/dialog/imapwnd.cxx +++ b/svx/source/dialog/imapwnd.cxx @@ -101,8 +101,8 @@ void IMapWindow::ReplaceImageMap( const ImageMap& rImageMap ) if(pPage) { - // clear all draw objects - pPage->Clear(); + // clear SdrObjects with broadcasting + pPage->ClearSdrObjList(); } if(GetSdrView()) diff --git a/svx/source/svdraw/svdpage.cxx b/svx/source/svdraw/svdpage.cxx index a5d16568e049..b5a7f81abccf 100644 --- a/svx/source/svdraw/svdpage.cxx +++ b/svx/source/svdraw/svdpage.cxx @@ -84,9 +84,52 @@ SdrObjList::SdrObjList(SdrPage* pNewPage) eListKind=SdrObjListKind::Unknown; } +void SdrObjList::impClearSdrObjList(bool bBroadcast) +{ + SdrModel* pSdrModelFromRemovedSdrObject(nullptr); + + while(!maList.empty()) + { + // remove last object from list + SdrObject* pObj = maList.back(); + RemoveObjectFromContainer(maList.size()-1); + + // flushViewObjectContacts() is done since SdrObject::Free is not guaranteed + // to delete the object and thus refresh visualisations + pObj->GetViewContact().flushViewObjectContacts(); + + if(bBroadcast) + { + if(nullptr == pSdrModelFromRemovedSdrObject) + { + pSdrModelFromRemovedSdrObject = &pObj->getSdrModelFromSdrObject(); + } + + // sent remove hint (after removal, see RemoveObject()) + SdrHint aHint(SdrHintKind::ObjectRemoved, *pObj, mpPage); + pObj->getSdrModelFromSdrObject().Broadcast(aHint); + } + + // delete the object itself + SdrObject::Free( pObj ); + } + + if(bBroadcast && nullptr != pSdrModelFromRemovedSdrObject) + { + pSdrModelFromRemovedSdrObject->SetChanged(); + } +} + +void SdrObjList::ClearSdrObjList() +{ + // clear SdrObjects with broadcasting + impClearSdrObjList(true); +} + SdrObjList::~SdrObjList() { - Clear(); // delete contents of container + // clear SdrObjects without broadcasting + impClearSdrObjList(false); } void SdrObjList::copyDataFromSdrObjList(const SdrObjList& rSrcList, SdrModel* pNewModelel) @@ -99,7 +142,9 @@ void SdrObjList::copyDataFromSdrObjList(const SdrObjList& rSrcList, SdrModel* pN void SdrObjList::CopyObjects(const SdrObjList& rSrcList, SdrModel* pNewModelel) { - Clear(); + // clear SdrObjects with broadcasting + ClearSdrObjList(); + bObjOrdNumsDirty = false; bRectsDirty = false; size_t nCloneErrCnt(0); @@ -187,39 +232,6 @@ void SdrObjList::CopyObjects(const SdrObjList& rSrcList, SdrModel* pNewModelel) } } -void SdrObjList::Clear() -{ - SdrModel* pSdrModelFromRemovedSdrObject(nullptr); - - while(!maList.empty()) - { - // remove last object from list - SdrObject* pObj = maList.back(); - RemoveObjectFromContainer(maList.size()-1); - - // flushViewObjectContacts() is done since SdrObject::Free is not guaranteed - // to delete the object and thus refresh visualisations - pObj->GetViewContact().flushViewObjectContacts(); - - if(nullptr == pSdrModelFromRemovedSdrObject) - { - pSdrModelFromRemovedSdrObject = &pObj->getSdrModelFromSdrObject(); - } - - // sent remove hint (after removal, see RemoveObject()) - SdrHint aHint(SdrHintKind::ObjectRemoved, *pObj, mpPage); - pObj->getSdrModelFromSdrObject().Broadcast(aHint); - - // delete the object itself - SdrObject::Free( pObj ); - } - - if(nullptr != pSdrModelFromRemovedSdrObject) - { - pSdrModelFromRemovedSdrObject->SetChanged(); - } -} - SdrPage* SdrObjList::GetPage() const { return mpPage; |