[Libreoffice-commits] .: sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri Jan 6 17:59:47 PST 2012
sc/source/core/data/document.cxx | 30 ++++++++++++++++++------------
1 file changed, 18 insertions(+), 12 deletions(-)
New commits:
commit f60c1cd239da3e2fcb30f4af8761013c8ae9c0fc
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Jan 6 20:56:20 2012 -0500
fdo#44467: Deleting sheets should adjust drawing object pages as well.
Good thing we caught this, because we were also leaking memory by not
deleting the deleted sheet instances.
diff --git a/sc/source/core/data/document.cxx b/sc/source/core/data/document.cxx
index eb03a74..15d5295 100644
--- a/sc/source/core/data/document.cxx
+++ b/sc/source/core/data/document.cxx
@@ -95,6 +95,7 @@
#include "externalrefmgr.hxx"
#include "tabprotection.hxx"
#include "clipparam.hxx"
+#include "stlalgorithm.hxx"
#include <map>
#include <limits>
@@ -651,17 +652,19 @@ bool ScDocument::DeleteTab( SCTAB nTab, ScDocument* pRefUndoDoc )
if ( pUnoBroadcaster )
pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,-1 ) );
- SCTAB i;
- for (i=0; i< static_cast<SCTAB>(maTabs.size()); i++)
+ for (SCTAB i = 0, n = static_cast<SCTAB>(maTabs.size()); i < n; ++i)
if (maTabs[i])
- maTabs[i]->UpdateDeleteTab(nTab,false,
- pRefUndoDoc ? pRefUndoDoc->maTabs[i] : 0);
- maTabs.erase(maTabs.begin()+ nTab);
+ maTabs[i]->UpdateDeleteTab(
+ nTab, false, pRefUndoDoc ? pRefUndoDoc->maTabs[i] : 0);
+
+ TableContainer::iterator it = maTabs.begin() + nTab;
+ delete *it;
+ maTabs.erase(it);
// UpdateBroadcastAreas must be called between UpdateDeleteTab,
// which ends listening, and StartAllListeners, to not modify
// areas that are to be inserted by starting listeners.
UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,-1);
- TableContainer::iterator it = maTabs.begin();
+ it = maTabs.begin();
for (; it != maTabs.end(); ++it)
if ( *it )
(*it)->UpdateCompile();
@@ -738,17 +741,20 @@ bool ScDocument::DeleteTabs( SCTAB nTab, SCTAB nSheets, ScDocument* pRefUndoDoc
if ( pUnoBroadcaster )
pUnoBroadcaster->Broadcast( ScUpdateRefHint( URM_INSDEL, aRange, 0,0,-1*nSheets ) );
- SCTAB i;
- for (i=0; i< static_cast<SCTAB>(maTabs.size()); i++)
+ for (SCTAB i = 0, n = static_cast<SCTAB>(maTabs.size()); i < n; ++i)
if (maTabs[i])
- maTabs[i]->UpdateDeleteTab(nTab,false,
- pRefUndoDoc ? pRefUndoDoc->maTabs[i] : 0,nSheets);
- maTabs.erase(maTabs.begin()+ nTab, maTabs.begin() + nTab + nSheets);
+ maTabs[i]->UpdateDeleteTab(
+ nTab, false, pRefUndoDoc ? pRefUndoDoc->maTabs[i] : 0,nSheets);
+
+ TableContainer::iterator it = maTabs.begin() + nTab;
+ TableContainer::iterator itEnd = it + nSheets;
+ std::for_each(it, itEnd, ScDeleteObjectByPtr<ScTable>());
+ maTabs.erase(it, itEnd);
// UpdateBroadcastAreas must be called between UpdateDeleteTab,
// which ends listening, and StartAllListeners, to not modify
// areas that are to be inserted by starting listeners.
UpdateBroadcastAreas( URM_INSDEL, aRange, 0,0,-1*nSheets);
- TableContainer::iterator it = maTabs.begin();
+ it = maTabs.begin();
for (; it != maTabs.end(); ++it)
if ( *it )
(*it)->UpdateCompile();
More information about the Libreoffice-commits
mailing list