[Libreoffice-commits] .: Branch 'libreoffice-3-5' - 2 commits - sc/source

Kohei Yoshida kohei at kemper.freedesktop.org
Fri Jan 13 08:57:11 PST 2012


 sc/source/core/data/dptablecache.cxx |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)

New commits:
commit 54731b6a25ea7f049a866e9a3c78d0684f7e1bc4
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Fri Jan 13 11:56:35 2012 -0500

    Use a copy; the container gets modified during iteration.

diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index 1baec31..a65785b 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -447,8 +447,11 @@ struct ClearObjectSource : std::unary_function<ScDPObject*, void>
 
 ScDPCache::~ScDPCache()
 {
-    // Make sure no live ScDPObject instances hold reference to this cache any more.
-    std::for_each(maRefObjects.begin(), maRefObjects.end(), ClearObjectSource());
+    // Make sure no live ScDPObject instances hold reference to this cache any
+    // more.  We need to use a copied set because the referencing objects will
+    // modify the original when clearing their source.
+    ObjectSetType aRefs(maRefObjects);
+    std::for_each(aRefs.begin(), aRefs.end(), ClearObjectSource());
 }
 
 bool ScDPCache::IsValid() const
commit 405cd1b404faaed034b1188806a0f7f3ff899664
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date:   Fri Jan 13 10:52:56 2012 -0500

    Make sure no live ScDPObject instances hold reference to the deleted cache.

diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index 57f6ce1..1baec31 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -433,8 +433,22 @@ ScDPCache::ScDPCache(ScDocument* pDoc) :
 {
 }
 
+namespace {
+
+struct ClearObjectSource : std::unary_function<ScDPObject*, void>
+{
+    void operator() (ScDPObject* p) const
+    {
+        p->ClearSource();
+    }
+};
+
+}
+
 ScDPCache::~ScDPCache()
 {
+    // Make sure no live ScDPObject instances hold reference to this cache any more.
+    std::for_each(maRefObjects.begin(), maRefObjects.end(), ClearObjectSource());
 }
 
 bool ScDPCache::IsValid() const


More information about the Libreoffice-commits mailing list