[Libreoffice-commits] .: Branch 'libreoffice-3-5' - sc/inc sc/source
Kohei Yoshida
kohei at kemper.freedesktop.org
Fri Jan 13 10:56:44 PST 2012
sc/inc/dptablecache.hxx | 2 ++
sc/source/core/data/dptablecache.cxx | 14 +++++++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
New commits:
commit e85bf5d40d66a52898aa6b6bff3f537372a9a0a8
Author: Kohei Yoshida <kohei.yoshida at suse.com>
Date: Fri Jan 13 13:56:34 2012 -0500
Avoid double deletion during data cache object destruction.
diff --git a/sc/inc/dptablecache.hxx b/sc/inc/dptablecache.hxx
index 882f422..dcfc066 100644
--- a/sc/inc/dptablecache.hxx
+++ b/sc/inc/dptablecache.hxx
@@ -93,6 +93,8 @@ private:
mutable ScDPItemDataPool maAdditionalData;
+ bool mbDisposing;
+
public:
void AddReference(ScDPObject* pObj) const;
void RemoveReference(ScDPObject* pObj) const;
diff --git a/sc/source/core/data/dptablecache.cxx b/sc/source/core/data/dptablecache.cxx
index a65785b..ed45647 100644
--- a/sc/source/core/data/dptablecache.cxx
+++ b/sc/source/core/data/dptablecache.cxx
@@ -429,7 +429,8 @@ bool ScDPCache::operator== ( const ScDPCache& r ) const
ScDPCache::ScDPCache(ScDocument* pDoc) :
mpDoc( pDoc ),
- mnColumnCount ( 0 )
+ mnColumnCount ( 0 ),
+ mbDisposing(false)
{
}
@@ -448,10 +449,9 @@ struct ClearObjectSource : std::unary_function<ScDPObject*, void>
ScDPCache::~ScDPCache()
{
// 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());
+ // more.
+ mbDisposing = true;
+ std::for_each(maRefObjects.begin(), maRefObjects.end(), ClearObjectSource());
}
bool ScDPCache::IsValid() const
@@ -1010,6 +1010,10 @@ void ScDPCache::AddReference(ScDPObject* pObj) const
void ScDPCache::RemoveReference(ScDPObject* pObj) const
{
+ if (mbDisposing)
+ // Object being deleted.
+ return;
+
maRefObjects.erase(pObj);
if (maRefObjects.empty())
mpDoc->GetDPCollection()->RemoveCache(this);
More information about the Libreoffice-commits
mailing list