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

svn commit: r1495315 - /openoffice/trunk/main/sw/source/core/bastyp/index.cxx

Author: af
Date: Fri Jun 21 08:02:43 2013
New Revision: 1495315

URL: http://svn.apache.org/r1495315
Log:
120250: Fixed removal of item from linked list SwIndexReg.

Modified:
    openoffice/trunk/main/sw/source/core/bastyp/index.cxx

Modified: openoffice/trunk/main/sw/source/core/bastyp/index.cxx
URL: http://svn.apache.org/viewvc/openoffice/trunk/main/sw/source/core/bastyp/index.cxx?rev=1495315&r1=1495314&r2=1495315&view=diff
==============================================================================
--- openoffice/trunk/main/sw/source/core/bastyp/index.cxx (original)
+++ openoffice/trunk/main/sw/source/core/bastyp/index.cxx Fri Jun 21 08:02:43 2013
@@ -42,29 +42,45 @@ TYPEINIT0(SwIndexReg);	// rtti
 
 #ifdef CHK
 
-#define IDX_CHK_ARRAY       pArray->ChhkArr();
-#define ARR_CHK_ARRAY       ChhkArr();
-
+#define IDX_CHK_ARRAY       pArray->ChkArr();
+#define AR R_CHK_ARRAY       ChkArr();
 
 void SwIndexReg::ChkArr()
 {
-	ASSERT( (pFirst && pLast) || (!pFirst && !pLast),
-			"Array falsch Indiziert" );
+	if ( ! ((pFirst && pLast) || (!pFirst && !pLast)))
+    {
+        ASSERT(false, "array not correctly indexed");
+    }
 
 	if( !pFirst )
 		return;
 
 	xub_StrLen nVal = 0;
 	const SwIndex* pIdx = pFirst, *pPrev = 0;
-	ASSERT( !pIdx->pPrev, "Array-pFirst nicht am Anfang" );
+    if ( ! (!pIdx->pPrev))
+    {
+        ASSERT(false, "array-pFirst not at beginning");
+    }
 
 	while( pIdx != pLast )
 	{
-		ASSERT( pIdx->pPrev != pIdx && pIdx->pNext != pIdx,
-				"Index zeigt auf sich selbst" )
-
-		ASSERT( pIdx->nIndex >= nVal, "Reihenfolge stimmt nicht" );
-		ASSERT( pPrev == pIdx->pPrev, "Verkettung stimmt nicht" );
+		if ( ! (pIdx->pPrev != pIdx && pIdx->pNext != pIdx))
+        {
+            ASSERT(false, "index points to itself");
+        }
+
+		if ( ! (pIdx->nIndex >= nVal))
+        {
+            ASSERT(false, "wrong order");
+        }
+        if ( ! (pPrev == pIdx->pPrev))
+        {
+            ASSERT(false, "wrong array pointers");
+        }
+        if ( ! (this == pIdx->pArray))
+        {
+            ASSERT(false, "wrong array/child relationship");
+        }
 		pPrev = pIdx;
 		pIdx = pIdx->pNext;
 		nVal = pPrev->nIndex;
@@ -224,16 +240,37 @@ IDX_CHK_ARRAY
 
 void SwIndex::Remove()
 {
-	if( !pPrev )
-		pArray->pFirst = pNext;
-	else
-		pPrev->pNext = pNext;
-
-	if( !pNext )
-		pArray->pLast = pPrev;
-	else
-		pNext->pPrev = pPrev;
-
+    if (pArray->pFirst==NULL && pArray->pLast==NULL)
+    {
+        // The index object is not a member of its list and therefore
+        // can not be removed.
+        return;
+    }
+
+    if (pPrev==NULL && pNext==NULL)
+    {
+        // Removing last element in list.
+        pArray->pFirst = NULL;
+        pArray->pLast = NULL;
+    }
+    else
+    {
+        if( !pPrev )
+        {
+            OSL_ASSERT(pNext!=NULL);
+            pArray->pFirst = pNext;
+        }
+        else
+            pPrev->pNext = pNext;
+
+        if( !pNext )
+        {
+            OSL_ASSERT(pPrev!=NULL);
+            pArray->pLast = pPrev;
+        }
+        else
+            pNext->pPrev = pPrev;
+    }
 IDX_CHK_ARRAY
 }