[Libreoffice-commits] core.git: 4 commits - sc/inc sc/source

Eike Rathke erack at redhat.com
Tue Apr 11 17:07:01 UTC 2017


 sc/inc/postit.hxx              |    4 ++--
 sc/source/core/data/postit.cxx |   30 ++++++++++++++++++++++--------
 sc/source/ui/undo/undocell.cxx |    8 ++++----
 sc/source/ui/view/notemark.cxx |    3 +++
 4 files changed, 31 insertions(+), 14 deletions(-)

New commits:
commit 8aa8be724dafc266d7daeae325806ca2caae2efe
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Apr 11 19:05:46 2017 +0200

    deleting pModel also deletes the SdrCaptionObj
    
    Change-Id: Icf3aed35ede1c211d6238dc66d86cb2866b247cd

diff --git a/sc/source/ui/view/notemark.cxx b/sc/source/ui/view/notemark.cxx
index a55cc917ab80..52dc58ef26d0 100644
--- a/sc/source/ui/view/notemark.cxx
+++ b/sc/source/ui/view/notemark.cxx
@@ -65,6 +65,9 @@ ScNoteMarker::ScNoteMarker( vcl::Window* pWin, vcl::Window* pRight, vcl::Window*
 
 ScNoteMarker::~ScNoteMarker()
 {
+    if (pModel)
+        mxObject.release();     // deleting pModel also deletes the SdrCaptionObj
+
     InvalidateWin();
 
     delete pModel;
commit 59aebc3e51490ba9c76a261b2e5090b12f30e0da
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Apr 11 18:53:36 2017 +0200

    set mbNotOwner at various places
    
    Change-Id: I1ff14c573d556cad15513dfe3f0fecbf9107fa41

diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index ef15c8556762..e8afbb2479dc 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -481,6 +481,7 @@ ScCaptionPtr::ScCaptionPtr( ScCaptionPtr&& r ) :
 {
     r.replaceInList( this );
     r.mpCaption = nullptr;
+    r.mbNotOwner = false;
 }
 
 ScCaptionPtr& ScCaptionPtr::operator=( ScCaptionPtr&& r )
@@ -490,9 +491,11 @@ ScCaptionPtr& ScCaptionPtr::operator=( ScCaptionPtr&& r )
     mpHead = r.mpHead;
     mpNext = r.mpNext;
     mpCaption = r.mpCaption;
+    mbNotOwner = r.mbNotOwner;
 
     r.replaceInList( this );
     r.mpCaption = nullptr;
+    r.mbNotOwner = false;
 
     return *this;
 }
@@ -525,6 +528,7 @@ ScCaptionPtr& ScCaptionPtr::operator=( const ScCaptionPtr& r )
     removeFromList();
 
     mpCaption = r.mpCaption;
+    mbNotOwner = r.mbNotOwner;
     // That head is this' master.
     mpHead = r.mpHead;
     // Insert into list.
@@ -656,6 +660,7 @@ void ScCaptionPtr::reset( SdrCaptionObj* p )
     decRefAndDestroy();
     removeFromList();
     mpCaption = p;
+    mbNotOwner = false;
     if (p)
     {
         newHead();
@@ -776,6 +781,7 @@ bool ScCaptionPtr::forget()
     bool bRet = decRef();
     removeFromList();
     mpCaption = nullptr;
+    mbNotOwner = false;
     return bRet;
 }
 
@@ -800,6 +806,7 @@ void ScCaptionPtr::clear()
     mpHead = nullptr;
     mpNext = nullptr;
     mpCaption = nullptr;
+    mbNotOwner = false;
 }
 
 
commit 024ddbc7d2ffe6b4b84c48b213296a0716086b6d
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Apr 11 18:05:09 2017 +0200

    reset variables when not owner
    
    Change-Id: Ieab4bf36b89abac2d2ff377fc2b6f31ce0e1d3aa

diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index 78cd43a6a5c2..ef15c8556762 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -695,9 +695,16 @@ void ScCaptionPtr::decRefAndDestroy()
 #if 1
         // FIXME: there are still cases where the caption pointer is dangling
         mpCaption = nullptr;
+        mbNotOwner = false;
 #else
-        // Destroying Draw Undo deletes its SdrObject, don't attempt that twice.
-        if (!mbNotOwner)
+        // Destroying Draw Undo and some other delete the SdrObject, don't
+        // attempt that twice.
+        if (mbNotOwner)
+        {
+            mpCaption = nullptr;
+            mbNotOwner = false;
+        }
+        else
         {
             removeFromDrawPageAndFree( true );  // ignoring Undo
             if (mpCaption)
commit e777618a59b6a66207d416b7b4dd3e77c2662260
Author: Eike Rathke <erack at redhat.com>
Date:   Tue Apr 11 17:16:32 2017 +0200

    rename ScCaptionPtr (mb|set)InUndo to (mb|set)NotOwner
    
    ... which better suits the general purpose we'll need
    
    Change-Id: I32805c91d17180d5f18225a02c8a436826242e19

diff --git a/sc/inc/postit.hxx b/sc/inc/postit.hxx
index a630aef271db..d9584e1e7005 100644
--- a/sc/inc/postit.hxx
+++ b/sc/inc/postit.hxx
@@ -86,7 +86,7 @@ public:
     bool forget();
 
     /** Flag that this instance is in Undo, so drawing layer owns it. */
-    void setInUndo();
+    void setNotOwner();
 
     oslInterlockedCount getRefs() const;
 
@@ -104,7 +104,7 @@ private:
     Head*                 mpHead;       ///< points to the "master" entry
     mutable ScCaptionPtr* mpNext;       ///< next in list
     SdrCaptionObj*        mpCaption;    ///< the caption object, managed by head master
-    bool                  mbInUndo;     ///< whether this caption object is held in Undo
+    bool                  mbNotOwner;   ///< whether this caption object is owned by something else, e.g. held in Undo
                                             /* TODO: can that be moved to Head?
                                              * It's unclear when to reset, so
                                              * each instance has its own flag.
diff --git a/sc/source/core/data/postit.cxx b/sc/source/core/data/postit.cxx
index d2ef02f37b22..78cd43a6a5c2 100644
--- a/sc/source/core/data/postit.cxx
+++ b/sc/source/core/data/postit.cxx
@@ -445,12 +445,12 @@ ScNoteCaptionCreator::ScNoteCaptionCreator( ScDocument& rDoc, const ScAddress& r
 
 
 ScCaptionPtr::ScCaptionPtr() :
-    mpHead(nullptr), mpNext(nullptr), mpCaption(nullptr), mbInUndo(false)
+    mpHead(nullptr), mpNext(nullptr), mpCaption(nullptr), mbNotOwner(false)
 {
 }
 
 ScCaptionPtr::ScCaptionPtr( SdrCaptionObj* p ) :
-    mpHead(nullptr), mpNext(nullptr), mpCaption(p), mbInUndo(false)
+    mpHead(nullptr), mpNext(nullptr), mpCaption(p), mbNotOwner(false)
 {
     if (p)
     {
@@ -459,7 +459,7 @@ ScCaptionPtr::ScCaptionPtr( SdrCaptionObj* p ) :
 }
 
 ScCaptionPtr::ScCaptionPtr( const ScCaptionPtr& r ) :
-    mpHead(r.mpHead), mpCaption(r.mpCaption), mbInUndo(false)
+    mpHead(r.mpHead), mpCaption(r.mpCaption), mbNotOwner(false)
 {
     if (r.mpCaption)
     {
@@ -477,7 +477,7 @@ ScCaptionPtr::ScCaptionPtr( const ScCaptionPtr& r ) :
 }
 
 ScCaptionPtr::ScCaptionPtr( ScCaptionPtr&& r ) :
-    mpHead(r.mpHead), mpNext(r.mpNext), mpCaption(r.mpCaption), mbInUndo(false)
+    mpHead(r.mpHead), mpNext(r.mpNext), mpCaption(r.mpCaption), mbNotOwner(false)
 {
     r.replaceInList( this );
     r.mpCaption = nullptr;
@@ -534,9 +534,9 @@ ScCaptionPtr& ScCaptionPtr::operator=( const ScCaptionPtr& r )
     return *this;
 }
 
-void ScCaptionPtr::setInUndo()
+void ScCaptionPtr::setNotOwner()
 {
-    mbInUndo = true;
+    mbNotOwner = true;
 }
 
 ScCaptionPtr::Head::Head( ScCaptionPtr* p ) :
@@ -697,7 +697,7 @@ void ScCaptionPtr::decRefAndDestroy()
         mpCaption = nullptr;
 #else
         // Destroying Draw Undo deletes its SdrObject, don't attempt that twice.
-        if (!mbInUndo)
+        if (!mbNotOwner)
         {
             removeFromDrawPageAndFree( true );  // ignoring Undo
             if (mpCaption)
diff --git a/sc/source/ui/undo/undocell.cxx b/sc/source/ui/undo/undocell.cxx
index 202acdd26f45..7db4c9065500 100644
--- a/sc/source/ui/undo/undocell.cxx
+++ b/sc/source/ui/undo/undocell.cxx
@@ -712,12 +712,12 @@ ScUndoReplaceNote::ScUndoReplaceNote( ScDocShell& rDocShell, const ScAddress& rP
     if (bInsert)
     {
         maNewData = rNoteData;
-        maNewData.mxCaption.setInUndo();
+        maNewData.mxCaption.setNotOwner();
     }
     else
     {
         maOldData = rNoteData;
-        maOldData.mxCaption.setInUndo();
+        maOldData.mxCaption.setNotOwner();
     }
 }
 
@@ -731,8 +731,8 @@ ScUndoReplaceNote::ScUndoReplaceNote( ScDocShell& rDocShell, const ScAddress& rP
 {
     OSL_ENSURE( maOldData.mxCaption || maNewData.mxCaption, "ScUndoReplaceNote::ScUndoReplaceNote - missing note captions" );
     OSL_ENSURE( !maOldData.mxInitData.get() && !maNewData.mxInitData.get(), "ScUndoReplaceNote::ScUndoReplaceNote - unexpected unitialized note" );
-    maOldData.mxCaption.setInUndo();
-    maNewData.mxCaption.setInUndo();
+    maOldData.mxCaption.setNotOwner();
+    maNewData.mxCaption.setNotOwner();
 }
 
 ScUndoReplaceNote::~ScUndoReplaceNote()


More information about the Libreoffice-commits mailing list