Kaydet (Commit) 8374bbe5 authored tarafından Takeshi Abe's avatar Takeshi Abe

Avoid possible memory leaks in case of exceptions

Change-Id: I7878d425cea773338799fb784c25039e6b923e47
üst 7a85ec95
......@@ -36,6 +36,7 @@
#include <svx/itemwin.hxx>
#include <svx/dialmgr.hxx>
#include "helpid.hrc"
#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::util;
......@@ -317,9 +318,9 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
}
aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
XGradientEntry* pEntry = new XGradientEntry(mpGradientItem->GetGradientValue(), aTmpStr);
boost::scoped_ptr<XGradientEntry> pEntry(new XGradientEntry(mpGradientItem->GetGradientValue(), aTmpStr));
XGradientList aGradientList( "", ""/*TODO?*/ );
aGradientList.Insert( pEntry );
aGradientList.Insert( pEntry.get() );
aGradientList.SetDirty( false );
const Bitmap aBmp = aGradientList.GetUiBitmap( 0 );
......@@ -330,7 +331,6 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
}
aGradientList.Remove( 0 );
delete pEntry;
}
}
else
......@@ -363,9 +363,9 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
}
aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
XHatchEntry* pEntry = new XHatchEntry(mpHatchItem->GetHatchValue(), aTmpStr);
boost::scoped_ptr<XHatchEntry> pEntry(new XHatchEntry(mpHatchItem->GetHatchValue(), aTmpStr));
XHatchList aHatchList( "", ""/*TODO?*/ );
aHatchList.Insert( pEntry );
aHatchList.Insert( pEntry.get() );
aHatchList.SetDirty( false );
const Bitmap aBmp = aHatchList.GetUiBitmap( 0 );
......@@ -376,7 +376,6 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
}
aHatchList.Remove( 0 );
delete pEntry;
}
}
else
......@@ -409,16 +408,15 @@ void SvxFillToolBoxControl::Update(const SfxPoolItem* pState)
}
aTmpStr = TMP_STR_BEGIN + aString + TMP_STR_END;
XBitmapEntry* pEntry = new XBitmapEntry(mpBitmapItem->GetGraphicObject(), aTmpStr);
boost::scoped_ptr<XBitmapEntry> pEntry(new XBitmapEntry(mpBitmapItem->GetGraphicObject(), aTmpStr));
XBitmapListRef xBitmapList =
XPropertyList::CreatePropertyList(XBITMAP_LIST,
OUString("TmpList"), ""/*TODO?*/)->AsBitmapList();
xBitmapList->Insert( pEntry );
xBitmapList->Insert( pEntry.get() );
xBitmapList->SetDirty( false );
mpFillAttrLB->Fill( xBitmapList );
mpFillAttrLB->SelectEntryPos(mpFillAttrLB->GetEntryCount() - 1);
xBitmapList->Remove( 0 );
delete pEntry;
}
}
else
......
......@@ -52,6 +52,7 @@
#include "fontworkgallery.hrc"
#include <algorithm>
#include <boost/scoped_ptr.hpp>
#include "helpid.hrc"
......@@ -202,10 +203,10 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
if( nItemId > 0 )
{
FmFormModel* pModel = new FmFormModel();
boost::scoped_ptr<FmFormModel> pModel(new FmFormModel());
pModel->GetItemPool().FreezeIdRanges();
if( GalleryExplorer::GetSdrObj( mnThemeId, nItemId-1, pModel ) )
if( GalleryExplorer::GetSdrObj( mnThemeId, nItemId-1, pModel.get() ) )
{
SdrPage* pPage = pModel->GetPage(0);
if( pPage && pPage->GetObjCount() )
......@@ -237,8 +238,6 @@ void FontWorkGalleryDialog::insertSelectedFontwork()
}
}
}
delete pModel;
}
}
......
......@@ -34,6 +34,7 @@
#include <svx/itemwin.hxx>
#include <svx/dialmgr.hxx>
#include <svx/unoapi.hxx>
#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star::uno;
using namespace ::com::sun::star::beans;
......@@ -356,27 +357,27 @@ SvxLineEndWindow::~SvxLineEndWindow()
IMPL_LINK_NOARG(SvxLineEndWindow, SelectHdl)
{
XLineEndItem* pLineEndItem = NULL;
XLineStartItem* pLineStartItem = NULL;
boost::scoped_ptr<XLineEndItem> pLineEndItem;
boost::scoped_ptr<XLineStartItem> pLineStartItem;
sal_uInt16 nId = aLineEndSet.GetSelectItemId();
if( nId == 1 )
{
pLineStartItem = new XLineStartItem();
pLineStartItem.reset(new XLineStartItem());
}
else if( nId == 2 )
{
pLineEndItem = new XLineEndItem();
pLineEndItem.reset(new XLineEndItem());
}
else if( nId % 2 ) // beginning of line
{
XLineEndEntry* pEntry = pLineEndList->GetLineEnd( ( nId - 1 ) / 2 - 1 );
pLineStartItem = new XLineStartItem( pEntry->GetName(), pEntry->GetLineEnd() );
pLineStartItem.reset(new XLineStartItem( pEntry->GetName(), pEntry->GetLineEnd() ));
}
else // end of line
{
XLineEndEntry* pEntry = pLineEndList->GetLineEnd( nId / 2 - 2 );
pLineEndItem = new XLineEndItem( pEntry->GetName(), pEntry->GetLineEnd() );
pLineEndItem.reset(new XLineEndItem( pEntry->GetName(), pEntry->GetLineEnd() ));
}
if ( IsInPopupMode() )
......@@ -407,9 +408,6 @@ IMPL_LINK_NOARG(SvxLineEndWindow, SelectHdl)
OUString( ".uno:LineEndStyle" ),
aArgs );
delete pLineEndItem;
delete pLineStartItem;
return 0;
}
......
......@@ -66,7 +66,7 @@
#include <svx/svdoutl.hxx>
#include <editeng/flditem.hxx>
#include "boost/scoped_ptr.hpp"
#include <boost/scoped_ptr.hpp>
#include <UnoGraphicExporter.hxx>
......@@ -439,7 +439,7 @@ VirtualDevice* GraphicExporter::CreatePageVDev( SdrPage* pPage, sal_uIntPtr nWid
if(bSuccess)
{
SdrView* pView = new SdrView(mpDoc, pVDev);
boost::scoped_ptr<SdrView> pView(new SdrView(mpDoc, pVDev));
pView->SetPageVisible( false );
pView->SetBordVisible( false );
pView->SetGridVisible( false );
......@@ -451,7 +451,6 @@ VirtualDevice* GraphicExporter::CreatePageVDev( SdrPage* pPage, sal_uIntPtr nWid
ImplExportCheckVisisbilityRedirector aRedirector( mpCurrentPage );
pView->CompleteRedraw(pVDev, aRegion, &aRedirector);
delete pView;
}
else
{
......@@ -713,14 +712,13 @@ bool GraphicExporter::GetGraphic( ExportSettings& rSettings, Graphic& aGraphic,
}
VirtualDevice* pVDev = CreatePageVDev( pPage, nWidthPix, nHeightPix );
boost::scoped_ptr<VirtualDevice> pVDev(CreatePageVDev( pPage, nWidthPix, nHeightPix ));
if( pVDev )
{
aGraphic = pVDev->GetBitmap( Point(), pVDev->GetOutputSize() );
aGraphic.SetPrefMapMode( aMap );
aGraphic.SetPrefSize( aSize );
delete pVDev;
}
}
// create a metafile to export a vector format
......
......@@ -30,6 +30,7 @@
#include <vcl/svapp.hxx>
#include "svx/unoapi.hxx"
#include <boost/scoped_ptr.hpp>
using namespace ::com::sun::star;
using namespace ::rtl;
......@@ -87,11 +88,10 @@ void SAL_CALL SvxUnoNameItemTable::ImplInsertByName( const OUString& aName, cons
SfxItemSet* mpInSet = new SfxItemSet( *mpModelPool, mnWhich, mnWhich );
maItemSetVector.push_back( mpInSet );
NameOrIndex* pNewItem = createItem();
boost::scoped_ptr<NameOrIndex> pNewItem(createItem());
pNewItem->SetName( aName );
pNewItem->PutValue( aElement, mnMemberId );
mpInSet->Put( *pNewItem, mnWhich );
delete pNewItem;
}
// XNameContainer
......
......@@ -94,6 +94,7 @@
#include "svx/extrud3d.hxx"
#include <boost/bind.hpp>
#include <boost/scoped_ptr.hpp>
#include <vcl/wmf.hxx>
using namespace ::osl;
......@@ -685,7 +686,7 @@ uno::Any SvxShape::GetBitmap( bool bMetaFile /* = false */ ) const
SdrModel* pModel = mpObj->GetModel();
SdrPage* pPage = mpObj->GetPage();
E3dView* pView = new E3dView( pModel, &aVDev );
boost::scoped_ptr<E3dView> pView(new E3dView( pModel, &aVDev ));
pView->hideMarkHandles();
SdrPageView* pPageView = pView->ShowSdrPage(pPage);
......@@ -717,7 +718,6 @@ uno::Any SvxShape::GetBitmap( bool bMetaFile /* = false */ ) const
}
pView->UnmarkAll();
delete pView;
return aAny;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment