You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by or...@apache.org on 2013/08/19 10:20:06 UTC

svn commit: r1515312 - in /openoffice/trunk/main/sw/source: core/crsr/bookmrk.cxx core/doc/docbm.cxx core/inc/bookmrk.hxx ui/dochdl/swdtflvr.cxx

Author: orw
Date: Mon Aug 19 08:20:05 2013
New Revision: 1515312

URL: http://svn.apache.org/r1515312
Log:
122902, 122922, 122992: - <MarkManager::deleteMark(..)> - assure that entry is removed from stl container before its deletion is triggered.
                        - <SwTrnsfrDdeLink::Disconnect(..)> - do not delete DDE bookmark when it is already in its destruction

Modified:
    openoffice/trunk/main/sw/source/core/crsr/bookmrk.cxx
    openoffice/trunk/main/sw/source/core/doc/docbm.cxx
    openoffice/trunk/main/sw/source/core/inc/bookmrk.hxx
    openoffice/trunk/main/sw/source/ui/dochdl/swdtflvr.cxx

Modified: openoffice/trunk/main/sw/source/core/crsr/bookmrk.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/crsr/bookmrk.cxx?rev=1515312&r1=1515311&r2=1515312&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/crsr/bookmrk.cxx (original)
+++ openoffice/trunk/main/sw/source/core/crsr/bookmrk.cxx Mon Aug 19 08:20:05 2013
@@ -187,6 +187,7 @@ namespace sw { namespace mark
     DdeBookmark::DdeBookmark(const SwPaM& aPaM)
         : MarkBase(aPaM, MarkBase::GenerateNewName(our_sNamePrefix))
         , m_aRefObj(NULL)
+        , mbInDestruction( false )
     { }
 
     void DdeBookmark::SetRefObject(SwServerObject* pObj)
@@ -204,6 +205,7 @@ namespace sw { namespace mark
 
     DdeBookmark::~DdeBookmark()
     {
+        mbInDestruction = true;
         if( m_aRefObj.Is() )
         {
             if(m_aRefObj->HasDataLinks())

Modified: openoffice/trunk/main/sw/source/core/doc/docbm.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/doc/docbm.cxx?rev=1515312&r1=1515311&r2=1515312&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/doc/docbm.cxx (original)
+++ openoffice/trunk/main/sw/source/core/doc/docbm.cxx Mon Aug 19 08:20:05 2013
@@ -734,9 +734,18 @@ namespace sw { namespace mark
                 break;
         }
         DdeBookmark* const pDdeBookmark = dynamic_cast<DdeBookmark*>(ppMark->get());
-        if(pDdeBookmark)
+        if ( pDdeBookmark )
+        {
             pDdeBookmark->DeregisterFromDoc(m_pDoc);
-        m_vMarks.erase(m_vMarks.begin() + (ppMark - m_vMarks.begin())); // clumsy const-cast
+        }
+        // keep a temporary instance of the to-be-deleted mark in order to avoid
+        // recursive deletion of the mark triggered via its destructor.
+        // the temporary hold instance assures that the mark is deleted after the
+        // mark container has been updated. Thus, the mark could not be found anymore
+        // in the mark container by other calls trying to recursively delete the mark.
+        iterator_t aToBeDeletedMarkIter = m_vMarks.begin() + (ppMark - m_vMarks.begin());
+        pMark_t pToBeDeletedMark = *aToBeDeletedMarkIter;
+        m_vMarks.erase( aToBeDeletedMarkIter );
     }
 
     void MarkManager::deleteMark(const IMark* const pMark)

Modified: openoffice/trunk/main/sw/source/core/inc/bookmrk.hxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/inc/bookmrk.hxx?rev=1515312&r1=1515311&r2=1515312&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/inc/bookmrk.hxx (original)
+++ openoffice/trunk/main/sw/source/core/inc/bookmrk.hxx Mon Aug 19 08:20:05 2013
@@ -159,8 +159,13 @@ namespace sw { namespace mark
 
             void DeregisterFromDoc(SwDoc* const pDoc);
             virtual ~DdeBookmark();
+            inline bool IsInDestruction() const
+            {
+                return mbInDestruction;
+            }
         private:
-	        SwServerObjectRef m_aRefObj;
+            SwServerObjectRef m_aRefObj;
+            bool mbInDestruction;
             static const ::rtl::OUString our_sNamePrefix;
     };
 

Modified: openoffice/trunk/main/sw/source/ui/dochdl/swdtflvr.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/ui/dochdl/swdtflvr.cxx?rev=1515312&r1=1515311&r2=1515312&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/ui/dochdl/swdtflvr.cxx (original)
+++ openoffice/trunk/main/sw/source/ui/dochdl/swdtflvr.cxx Mon Aug 19 08:20:05 2013
@@ -87,6 +87,7 @@
 #include <IDocumentUndoRedo.hxx>
 #include <pagedesc.hxx>
 #include <IMark.hxx>
+#include <bookmrk.hxx>
 #include <docary.hxx>
 #include <section.hxx>
 #include <ndtxt.hxx>
@@ -3771,12 +3772,6 @@ sal_Bool SwTrnsfrDdeLink::WriteData( SvS
     rStrm.Write( pMem, nLen );
     delete[] pMem;
 
-    //if( bDelBookmrk )
-    //{
-    //  // er wird das erstemal abgeholt, also ins Undo mitaufnehmen
-    //  // aber wie??
-    //}
-
     IDocumentMarkAccess* const pMarkAccess = pDocShell->GetDoc()->getIDocumentMarkAccess();
     IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->findMark(sName);
     if(ppMark != pMarkAccess->getMarksEnd()
@@ -3818,17 +3813,17 @@ sal_Bool SwTrnsfrDdeLink::WriteData( SvS
 
 void SwTrnsfrDdeLink::Disconnect( sal_Bool bRemoveDataAdvise )
 {
-	//JP 29.01.96 Bug 24432:
-	//		kein DataChanged mehr entgegen nehmen, wenn man
-	//		sich schon im Disconnet befindet!
-	// 		(DTOR vom Bookmark verschickt einen DataChanged!)
-	sal_Bool bOldDisconnect = bInDisconnect;
-	bInDisconnect = sal_True;
+    //JP 29.01.96 Bug 24432:
+    //		kein DataChanged mehr entgegen nehmen, wenn man
+    //		sich schon im Disconnet befindet!
+    // 		(DTOR vom Bookmark verschickt einen DataChanged!)
+    const sal_Bool bOldDisconnect = bInDisconnect;
+    bInDisconnect = sal_True;
 
-	// den nicht verwendeten Bookmark wieder zerstoeren (ohne Undo!)?
-	if( bDelBookmrk && refObj.Is() && FindDocShell() )
-	{
-		SwDoc* pDoc = pDocShell->GetDoc();
+    // den nicht verwendeten Bookmark wieder zerstoeren (ohne Undo!)?
+    if( bDelBookmrk && refObj.Is() && FindDocShell() )
+    {
+        SwDoc* pDoc = pDocShell->GetDoc();
         ::sw::UndoGuard const undoGuard(pDoc->GetIDocumentUndoRedo());
 
         // --> OD, CD, OS 2005-11-25 #i58448#
@@ -3838,30 +3833,37 @@ void SwTrnsfrDdeLink::Disconnect( sal_Bo
         sal_Bool bIsModified = pDoc->IsModified();
 
         IDocumentMarkAccess* const pMarkAccess = pDoc->getIDocumentMarkAccess();
-        pMarkAccess->deleteMark(pMarkAccess->findMark(sName));
+        // check, if DdeBookmark is already in its desctruction
+        IDocumentMarkAccess::const_iterator_t ppMark = pMarkAccess->findMark(sName);
+        if ( ppMark != pMarkAccess->getMarksEnd() )
+        {
+            ::sw::mark::DdeBookmark* const pDdeBookmark = dynamic_cast< ::sw::mark::DdeBookmark* >(ppMark->get());
+            if ( pDdeBookmark && !pDdeBookmark->IsInDestruction() )
+            {
+                pMarkAccess->deleteMark(ppMark);
+            }
+        }
 
-		if( !bIsModified )
-			pDoc->ResetModified();
-        // --> OD, CD, OS 2005-11-25 #i58448#
+        if( !bIsModified )
+            pDoc->ResetModified();
         pDoc->SetOle2Link( aSavedOle2Link );
-        // <--
 
-		bDelBookmrk = sal_False;
-	}
+        bDelBookmrk = sal_False;
+    }
 
-	if( refObj.Is() )
-	{
-		refObj->SetUpdateTimeout( nOldTimeOut );
-		refObj->RemoveConnectAdvise( this );
-		if( bRemoveDataAdvise )
-			// in einem DataChanged darf das SelectionObject NIE geloescht
-			// werden; wird schon von der Basisklasse erledigt
-			// (ADVISEMODE_ONLYONCE!!!!)
-			// Im normalen Disconnet aber schon!
-			refObj->RemoveAllDataAdvise( this );
-		refObj.Clear();
-	}
-	bInDisconnect = bOldDisconnect;
+    if( refObj.Is() )
+    {
+        refObj->SetUpdateTimeout( nOldTimeOut );
+        refObj->RemoveConnectAdvise( this );
+        if( bRemoveDataAdvise )
+            // in einem DataChanged darf das SelectionObject NIE geloescht
+            // werden; wird schon von der Basisklasse erledigt
+            // (ADVISEMODE_ONLYONCE!!!!)
+            // Im normalen Disconnet aber schon!
+            refObj->RemoveAllDataAdvise( this );
+        refObj.Clear();
+    }
+    bInDisconnect = bOldDisconnect;
 }
 
 // -----------------------------------------------------------------------