incubator-ooo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From a..@apache.org
Subject svn commit: r1355277 - /incubator/ooo/trunk/main/sc/source/ui/unoobj/cellsuno.cxx
Date Fri, 29 Jun 2012 09:04:32 GMT
Author: alg
Date: Fri Jun 29 09:04:31 2012
New Revision: 1355277

URL: http://svn.apache.org/viewvc?rev=1355277&view=rev
Log:
#120105# Avoid MemoryLeak in ScTableSheetObj::PrintAreaUndo_Impl by handling created ScPrintRageSaver
objects more careful.
Found by: Chao Huang
Patch by: Chao Huang, alg
Review by: alg

Modified:
    incubator/ooo/trunk/main/sc/source/ui/unoobj/cellsuno.cxx

Modified: incubator/ooo/trunk/main/sc/source/ui/unoobj/cellsuno.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sc/source/ui/unoobj/cellsuno.cxx?rev=1355277&r1=1355276&r2=1355277&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sc/source/ui/unoobj/cellsuno.cxx (original)
+++ incubator/ooo/trunk/main/sc/source/ui/unoobj/cellsuno.cxx Fri Jun 29 09:04:31 2012
@@ -7365,31 +7365,43 @@ void SAL_CALL ScTableSheetObj::copyRange
 void ScTableSheetObj::PrintAreaUndo_Impl( ScPrintRangeSaver* pOldRanges )
 {
 	//	Umbrueche und Undo
-
 	ScDocShell* pDocSh = GetDocShell();
-	if ( pDocSh )
+	ScDocument* pDoc = pDocSh ? pDocSh->GetDocument() : 0;
+
+    if(pDocSh && pDoc)
 	{
-		ScDocument* pDoc = pDocSh->GetDocument();
-		sal_Bool bUndo(pDoc->IsUndoEnabled());
-		SCTAB nTab = GetTab_Impl();
+		const bool bUndo(pDoc->IsUndoEnabled());
+		const SCTAB nTab(GetTab_Impl());
 
-		ScPrintRangeSaver* pNewRanges = pDoc->CreatePrintRangeSaver();
-		if (bUndo)
+		if(bUndo)
 		{
-			pDocSh->GetUndoManager()->AddUndoAction(
-						new ScUndoPrintRange( pDocSh, nTab, pOldRanges, pNewRanges ) );
-		}
+            pDocSh->GetUndoManager()->AddUndoAction(
+			    new ScUndoPrintRange( 
+                    pDocSh, 
+                    nTab, 
+                    pOldRanges,
+                    pDoc->CreatePrintRangeSaver())); // create new ranges
 
-		ScPrintFunc( pDocSh, pDocSh->GetPrinter(), nTab ).UpdatePages();
+            // #120105# ownership of old ranges has changed, mark as consumed
+            pOldRanges = 0;
+		}
 
+		ScPrintFunc(pDocSh, pDocSh->GetPrinter(), nTab).UpdatePages();
 		SfxBindings* pBindings = pDocSh->GetViewBindings();
-		if (pBindings)
-			pBindings->Invalidate( SID_DELETE_PRINTAREA );
+
+        if(pBindings)
+        {
+			pBindings->Invalidate(SID_DELETE_PRINTAREA);
+        }
 
 		pDocSh->SetDocumentModified();
 	}
-	else
+
+    if(pOldRanges)
+    {
+        // #120105# pOldRanges not used, need to cleanup
 		delete pOldRanges;
+    }
 }
 
 uno::Sequence<table::CellRangeAddress> SAL_CALL ScTableSheetObj::getPrintAreas()



Mime
View raw message