Kaydet (Commit) 30eb0839 authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in basic and framework

Change-Id: I409c9c572eb8f3d68c8a387844b43988b4ab5c32
Reviewed-on: https://gerrit.libreoffice.org/64949
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst d398e924
...@@ -1105,12 +1105,12 @@ void SbModule::Run( SbMethod* pMeth ) ...@@ -1105,12 +1105,12 @@ void SbModule::Run( SbMethod* pMeth )
SbModule* pOldMod = GetSbData()->pMod; SbModule* pOldMod = GetSbData()->pMod;
GetSbData()->pMod = this; GetSbData()->pMod = this;
SbiRuntime* pRt = new SbiRuntime( this, pMeth, pMeth->nStart ); std::unique_ptr<SbiRuntime> pRt(new SbiRuntime( this, pMeth, pMeth->nStart ));
pRt->pNext = GetSbData()->pInst->pRun; pRt->pNext = GetSbData()->pInst->pRun;
if( pRt->pNext ) if( pRt->pNext )
pRt->pNext->block(); pRt->pNext->block();
GetSbData()->pInst->pRun = pRt; GetSbData()->pInst->pRun = pRt.get();
if ( mbVBACompat ) if ( mbVBACompat )
{ {
GetSbData()->pInst->EnableCompatibility( true ); GetSbData()->pInst->EnableCompatibility( true );
...@@ -1144,7 +1144,7 @@ void SbModule::Run( SbMethod* pMeth ) ...@@ -1144,7 +1144,7 @@ void SbModule::Run( SbMethod* pMeth )
if( pRtNext && (pRt->GetDebugFlags() & BasicDebugFlags::Break) ) if( pRtNext && (pRt->GetDebugFlags() & BasicDebugFlags::Break) )
pRtNext->SetDebugFlags( BasicDebugFlags::Break ); pRtNext->SetDebugFlags( BasicDebugFlags::Break );
delete pRt; pRt.reset();
GetSbData()->pMod = pOldMod; GetSbData()->pMod = pOldMod;
if( bDelInst ) if( bDelInst )
{ {
...@@ -1223,14 +1223,14 @@ void SbModule::RunInit() ...@@ -1223,14 +1223,14 @@ void SbModule::RunInit()
SbModule* pOldMod = GetSbData()->pMod; SbModule* pOldMod = GetSbData()->pMod;
GetSbData()->pMod = this; GetSbData()->pMod = this;
// The init code starts always here // The init code starts always here
SbiRuntime* pRt = new SbiRuntime( this, nullptr, 0 ); std::unique_ptr<SbiRuntime> pRt(new SbiRuntime( this, nullptr, 0 ));
pRt->pNext = GetSbData()->pInst->pRun; pRt->pNext = GetSbData()->pInst->pRun;
GetSbData()->pInst->pRun = pRt; GetSbData()->pInst->pRun = pRt.get();
while( pRt->Step() ) {} while( pRt->Step() ) {}
GetSbData()->pInst->pRun = pRt->pNext; GetSbData()->pInst->pRun = pRt->pNext;
delete pRt; pRt.reset();
GetSbData()->pMod = pOldMod; GetSbData()->pMod = pOldMod;
pImage->bInit = true; pImage->bInit = true;
pImage->bFirstInit = false; pImage->bFirstInit = false;
......
...@@ -262,7 +262,7 @@ class AddonsOptions_Impl : public ConfigItem ...@@ -262,7 +262,7 @@ class AddonsOptions_Impl : public ConfigItem
void AppendPopupMenu( Sequence< PropertyValue >& aTargetPopupMenu, const Sequence< PropertyValue >& rSourcePopupMenu ); void AppendPopupMenu( Sequence< PropertyValue >& aTargetPopupMenu, const Sequence< PropertyValue >& rSourcePopupMenu );
bool ReadToolBarItem( const OUString& aToolBarItemNodeName, Sequence< PropertyValue >& aToolBarItem ); bool ReadToolBarItem( const OUString& aToolBarItemNodeName, Sequence< PropertyValue >& aToolBarItem );
bool ReadStatusBarItem( const OUString& aStatusbarItemNodeName, Sequence< PropertyValue >& aStatusbarItem ); bool ReadStatusBarItem( const OUString& aStatusbarItemNodeName, Sequence< PropertyValue >& aStatusbarItem );
ImageEntry* ReadImageData( const OUString& aImagesNodeName ); std::unique_ptr<ImageEntry> ReadImageData( const OUString& aImagesNodeName );
void ReadAndAssociateImages( const OUString& aURL, const OUString& aImageId ); void ReadAndAssociateImages( const OUString& aURL, const OUString& aImageId );
Image ReadImageFromURL( const OUString& aURL ); Image ReadImageFromURL( const OUString& aURL );
bool HasAssociatedImages( const OUString& aURL ); bool HasAssociatedImages( const OUString& aURL );
...@@ -746,12 +746,11 @@ void AddonsOptions_Impl::ReadImages( ImageManager& aImageManager ) ...@@ -746,12 +746,11 @@ void AddonsOptions_Impl::ReadImages( ImageManager& aImageManager )
OUString aImagesUserDefinedItemNode = aBuf.makeStringAndClear(); OUString aImagesUserDefinedItemNode = aBuf.makeStringAndClear();
// Read a user-defined images data // Read a user-defined images data
ImageEntry* pImageEntry = ReadImageData( aImagesUserDefinedItemNode ); std::unique_ptr<ImageEntry> pImageEntry = ReadImageData( aImagesUserDefinedItemNode );
if ( pImageEntry ) if ( pImageEntry )
{ {
// Successfully read a user-defined images item, put it into our image manager // Successfully read a user-defined images item, put it into our image manager
aImageManager.emplace( aURL, *pImageEntry ); aImageManager.emplace( aURL, std::move(*pImageEntry) );
delete pImageEntry; // We have the ownership of the pointer
} }
} }
} }
...@@ -1328,14 +1327,14 @@ void AddonsOptions_Impl::ReadAndAssociateImages( const OUString& aURL, const OUS ...@@ -1328,14 +1327,14 @@ void AddonsOptions_Impl::ReadAndAssociateImages( const OUString& aURL, const OUS
m_aImageManager.emplace( aURL, aImageEntry ); m_aImageManager.emplace( aURL, aImageEntry );
} }
AddonsOptions_Impl::ImageEntry* AddonsOptions_Impl::ReadImageData( const OUString& aImagesNodeName ) std::unique_ptr<AddonsOptions_Impl::ImageEntry> AddonsOptions_Impl::ReadImageData( const OUString& aImagesNodeName )
{ {
Sequence< OUString > aImageDataNodeNames = GetPropertyNamesImages( aImagesNodeName ); Sequence< OUString > aImageDataNodeNames = GetPropertyNamesImages( aImagesNodeName );
Sequence< Any > aPropertyData; Sequence< Any > aPropertyData;
Sequence< sal_Int8 > aImageDataSeq; Sequence< sal_Int8 > aImageDataSeq;
OUString aImageURL; OUString aImageURL;
ImageEntry* pEntry = nullptr; std::unique_ptr<ImageEntry> pEntry;
// It is possible to use both forms (embedded image data and URLs to external bitmap files) at the // It is possible to use both forms (embedded image data and URLs to external bitmap files) at the
// same time. Embedded image data has a higher priority. // same time. Embedded image data has a higher priority.
...@@ -1351,14 +1350,14 @@ AddonsOptions_Impl::ImageEntry* AddonsOptions_Impl::ReadImageData( const OUStrin ...@@ -1351,14 +1350,14 @@ AddonsOptions_Impl::ImageEntry* AddonsOptions_Impl::ReadImageData( const OUStrin
( CreateImageFromSequence( aImage, aImageDataSeq ) ) ) ( CreateImageFromSequence( aImage, aImageDataSeq ) ) )
{ {
if ( !pEntry ) if ( !pEntry )
pEntry = new ImageEntry; pEntry.reset(new ImageEntry);
pEntry->addImage(i == OFFSET_IMAGES_SMALL ? IMGSIZE_SMALL : IMGSIZE_BIG, aImage, ""); pEntry->addImage(i == OFFSET_IMAGES_SMALL ? IMGSIZE_SMALL : IMGSIZE_BIG, aImage, "");
} }
} }
else else
{ {
if(!pEntry) if(!pEntry)
pEntry = new ImageEntry(); pEntry.reset(new ImageEntry());
// Retrieve image data from a external bitmap file. Make sure that embedded image data // Retrieve image data from a external bitmap file. Make sure that embedded image data
// has a higher priority. // has a higher priority.
......
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