Kaydet (Commit) e60b212c authored tarafından Kohei Yoshida's avatar Kohei Yoshida

Avoid double deletion during data cache object destruction.

üst aa7e1056
......@@ -93,6 +93,8 @@ private:
mutable ScDPItemDataPool maAdditionalData;
bool mbDisposing;
public:
void AddReference(ScDPObject* pObj) const;
void RemoveReference(ScDPObject* pObj) const;
......
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment