incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1353552 - /incubator/ooo/trunk/main/sd/source/core/drawdoc4.cxx
Date Mon, 25 Jun 2012 13:51:26 GMT
Author: alg
Date: Mon Jun 25 13:51:25 2012
New Revision: 1353552

URL: http://svn.apache.org/viewvc?rev=1353552&view=rev
Log:
#1200074# memory leak by not freeing helper class instances of StyleReplaceData.
Patch by: Chao Huang
Found by: Chao Huang
Review by: alg

Modified:
    incubator/ooo/trunk/main/sd/source/core/drawdoc4.cxx

Modified: incubator/ooo/trunk/main/sd/source/core/drawdoc4.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sd/source/core/drawdoc4.cxx?rev=1353552&r1=1353551&r2=1353552&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sd/source/core/drawdoc4.cxx (original)
+++ incubator/ooo/trunk/main/sd/source/core/drawdoc4.cxx Mon Jun 25 13:51:25 2012
@@ -1205,8 +1205,7 @@ void SdDrawDocument::RenameLayoutTemplat
 	// erase everything after '~LT~'
 	aOldName.Erase(nPos + sizeof(SD_LT_SEPARATOR) - 1 );
 	sal_uInt16 nLen = aOldName.Len();
-
-	List aReplList;
+    std::vector< StyleReplaceData* > aRememberedStyleReplaceData; // #120074#
 	SfxStyleSheetIterator aIter(mxStyleSheetPool.get(), SD_STYLE_FAMILY_MASTERPAGE);
 	SfxStyleSheetBase* pSheet = aIter.First();
 
@@ -1225,7 +1224,7 @@ void SdDrawDocument::RenameLayoutTemplat
 			pReplData->nNewFamily = pSheet->GetFamily();
 			pReplData->aName	  = pSheet->GetName();
 			pReplData->aNewName   = aSheetName;
-			aReplList.Insert(pReplData, LIST_APPEND);
+			aRememberedStyleReplaceData.push_back(pReplData);
 
 			pSheet->SetName(aSheetName);
 		}
@@ -1267,13 +1266,11 @@ void SdDrawDocument::RenameLayoutTemplat
 
 							if (pOPO)
 							{
-								StyleReplaceData* pReplData = (StyleReplaceData*) aReplList.First();
-
-								while( pReplData )
-								{
-									pOPO->ChangeStyleSheets( pReplData->aName, pReplData->nFamily, pReplData->aNewName,
pReplData->nNewFamily );
-									pReplData = (StyleReplaceData*) aReplList.Next();
-								}
+                                for(std::vector< StyleReplaceData* >::const_iterator
aData(aRememberedStyleReplaceData.begin());
+                                    aData != aRememberedStyleReplaceData.end(); aData++)
+                                {
+									pOPO->ChangeStyleSheets((*aData)->aName, (*aData)->nFamily, (*aData)->aNewName,
(*aData)->nNewFamily);
+                                }
 							}
 						}
 						break;
@@ -1315,13 +1312,11 @@ void SdDrawDocument::RenameLayoutTemplat
 
 							if (pOPO)
 							{
-								StyleReplaceData* pReplData = (StyleReplaceData*) aReplList.First();
-
-								while( pReplData )
-								{
-									pOPO->ChangeStyleSheets( pReplData->aName, pReplData->nFamily, pReplData->aNewName,
pReplData->nNewFamily );
-									pReplData = (StyleReplaceData*) aReplList.Next();
-								}
+                                for(std::vector< StyleReplaceData* >::const_iterator
aData(aRememberedStyleReplaceData.begin());
+                                    aData != aRememberedStyleReplaceData.end(); aData++)
+                                {
+									pOPO->ChangeStyleSheets((*aData)->aName, (*aData)->nFamily, (*aData)->aNewName,
(*aData)->nNewFamily);
+                                }
 							}
 						}
 						break;
@@ -1333,6 +1328,13 @@ void SdDrawDocument::RenameLayoutTemplat
 			}
 		}
 	}
+
+    // #120074# was not freed in older versoins, memory leak
+    while(!aRememberedStyleReplaceData.empty())
+    {
+        delete aRememberedStyleReplaceData[aRememberedStyleReplaceData.size() - 1];
+        aRememberedStyleReplaceData.pop_back();
+    }
 }
 
 /*************************************************************************



Mime
View raw message