From 13bc1e0b99dd1d32bc0fef1dbdf0813ff5f4c66c Mon Sep 17 00:00:00 2001 From: Sami Merila Date: Fri, 15 Oct 2010 14:27:26 +0300 Subject: Make s60pixelmetrics harvester utility app more robust There were some exceptional situations where the utility app caused either a memory leak, or outright crashed. Reviewed-by: TrustMe --- util/s60pixelmetrics/pm_mapperapp.cpp | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/util/s60pixelmetrics/pm_mapperapp.cpp b/util/s60pixelmetrics/pm_mapperapp.cpp index a88499d..d68a0b0 100644 --- a/util/s60pixelmetrics/pm_mapperapp.cpp +++ b/util/s60pixelmetrics/pm_mapperapp.cpp @@ -166,6 +166,7 @@ void CPixelMetricsMapperAppUi::HandleCommandL( TInt aCommand ) else bufferPtr.Append(_L("screen.")); ShowL( *buffer, last ); + CleanupStack::PopAndDestroy( buffer ); } break; case ECmdStatus: @@ -257,7 +258,7 @@ void CPixelMetricsMapperAppUi::HandleCommandL( TInt aCommand ) bufferPtr.Append(_L("Orientation cannot be changed.")); ShowL( *buffer, last ); bufferPtr.Zero(); - delete buffer; + CleanupStack::PopAndDestroy( buffer ); break; } #endif //__SERIES60_31__ @@ -278,7 +279,7 @@ void CPixelMetricsMapperAppUi::HandleCommandL( TInt aCommand ) bufferPtr.Append(_L("Orientation changed.")); ShowL( *buffer, last ); bufferPtr.Zero(); - delete buffer; + CleanupStack::PopAndDestroy( buffer ); break; } case ECmdStartCalculations: @@ -787,11 +788,14 @@ void CPixelMetricsMapperAppUi::CreateHeaderFileL() const CleanupStack::PopAndDestroy(); //sourceFile } - bufferLayoutHdr = bufferLayoutHdr.Left(bufferLayoutHdr.Length()-2); - bufferPMData = bufferPMData.Left(bufferPMData.Length()-2); - textFile.Write(bufferLayoutHdr); - textFile.Write(KCRLF); - textFile.Write(bufferPMData); + if (fileCount > 0) + { + bufferLayoutHdr = bufferLayoutHdr.Left(bufferLayoutHdr.Length()-2); + bufferPMData = bufferPMData.Left(bufferPMData.Length()-2); + textFile.Write(bufferLayoutHdr); + textFile.Write(KCRLF); + textFile.Write(bufferPMData); + } delete dirList; CleanupStack::PopAndDestroy(); //file -- cgit v0.12