[Libreoffice-commits] core.git: Branch 'distro/collabora/cp-4.1' - sc/inc sc/source

Kohei Yoshida kohei.yoshida at collabora.com
Fri Dec 6 17:05:06 PST 2013


 sc/inc/dpobject.hxx              |    3 ++
 sc/source/core/data/dpobject.cxx |   49 ++++++++++++++++++++++++++++++++++-----
 2 files changed, 46 insertions(+), 6 deletions(-)

New commits:
commit f58941760aa88eb155a2eb7fe39f0ee68265fdb2
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Fri Dec 6 19:44:21 2013 -0500

    fdo#66984: Define an assignment operator to prevent double deletion.
    
    The code path was assigning one ScDPObject to another via assignment,
    but we didn't define one. So we were using the compiler generated
    assignment which only shallow-copies data members, which ultimately
    caused double-deletion of one of its data members.
    
    Change-Id: Ie98d0789e51aebff683dbcc0e533a9a0a87943d5
    (cherry picked from commit bd976e5b070ec68a4f842190db4d0c1ea0e93428)

diff --git a/sc/inc/dpobject.hxx b/sc/inc/dpobject.hxx
index 8505a53..06d4957 100644
--- a/sc/inc/dpobject.hxx
+++ b/sc/inc/dpobject.hxx
@@ -118,11 +118,14 @@ public:
     ScDPObject(const ScDPObject& r);
     ~ScDPObject();
 
+    ScDPObject& operator= (const ScDPObject& r);
+
     void EnableGetPivotData(bool b);
 
     void                SetAllowMove(bool bSet);
 
     void                InvalidateData();
+    void Clear();
     void ClearTableData();
     void ReloadGroupTableData();
 
diff --git a/sc/source/core/data/dpobject.cxx b/sc/source/core/data/dpobject.cxx
index 677ccd5..169231a 100644
--- a/sc/source/core/data/dpobject.cxx
+++ b/sc/source/core/data/dpobject.cxx
@@ -354,12 +354,34 @@ ScDPObject::ScDPObject(const ScDPObject& r) :
 
 ScDPObject::~ScDPObject()
 {
-    delete pOutput;
-    delete pSaveData;
-    delete pSheetDesc;
-    delete pImpDesc;
-    delete pServDesc;
-    ClearTableData();
+    Clear();
+}
+
+ScDPObject& ScDPObject::operator= (const ScDPObject& r)
+{
+    Clear();
+
+    pDoc = r.pDoc;
+    aTableName = r.aTableName;
+    aTableTag = r.aTableTag;
+    aOutRange = r.aOutRange;
+    mnAutoFormatIndex = r.mnAutoFormatIndex;
+    nHeaderRows = r.nHeaderRows;
+    mbHeaderLayout = r.mbHeaderLayout;
+    bAllowMove = false;
+    bSettingsChanged = false;
+    mbEnableGetPivotData = r.mbEnableGetPivotData;
+
+    if (r.pSaveData)
+        pSaveData = new ScDPSaveData(*r.pSaveData);
+    if (r.pSheetDesc)
+        pSheetDesc = new ScSheetSourceDesc(*r.pSheetDesc);
+    if (r.pImpDesc)
+        pImpDesc = new ScImportSourceDesc(*r.pImpDesc);
+    if (r.pServDesc)
+        pServDesc = new ScDPServiceDesc(*r.pServDesc);
+
+    return *this;
 }
 
 void ScDPObject::EnableGetPivotData(bool b)
@@ -780,6 +802,21 @@ void ScDPObject::InvalidateData()
     bSettingsChanged = true;
 }
 
+void ScDPObject::Clear()
+{
+    delete pOutput;
+    delete pSaveData;
+    delete pSheetDesc;
+    delete pImpDesc;
+    delete pServDesc;
+    pOutput = NULL;
+    pSaveData = NULL;
+    pSheetDesc = NULL;
+    pImpDesc = NULL;
+    pServDesc = NULL;
+    ClearTableData();
+}
+
 void ScDPObject::ClearTableData()
 {
     ClearSource();


More information about the Libreoffice-commits mailing list