summaryrefslogtreecommitdiff
path: root/basic/source/basmgr/basicmanagerrepository.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-08-06 17:06:47 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-07 09:53:57 +0200
commitf4c387e97419be0a39b0df33e1bd9dee910f221c (patch)
tree8f5940f72a5f90dd416e762d12176f7e4920ce91 /basic/source/basmgr/basicmanagerrepository.cxx
parent04fe6b033bc5e3f9eaef6bf7e1f8214e83ec7ba7 (diff)
loplugin:useuniqueptr in ImplRepository
Change-Id: I664e16e4d61ed11df54bd161ad30c15fc41ce39b Reviewed-on: https://gerrit.libreoffice.org/58648 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'basic/source/basmgr/basicmanagerrepository.cxx')
-rw-r--r--basic/source/basmgr/basicmanagerrepository.cxx32
1 files changed, 15 insertions, 17 deletions
diff --git a/basic/source/basmgr/basicmanagerrepository.cxx b/basic/source/basmgr/basicmanagerrepository.cxx
index 41da1b1fa94f..1f110f9b77e3 100644
--- a/basic/source/basmgr/basicmanagerrepository.cxx
+++ b/basic/source/basmgr/basicmanagerrepository.cxx
@@ -63,7 +63,7 @@ namespace basic
using ::com::sun::star::lang::XComponent;
using ::com::sun::star::document::XEmbeddedScripts;
- typedef std::map< Reference< XInterface >, BasicManager*, ::comphelper::OInterfaceCompare< XInterface > > BasicManagerStore;
+ typedef std::map< Reference< XInterface >, std::unique_ptr<BasicManager>, ::comphelper::OInterfaceCompare< XInterface > > BasicManagerStore;
typedef std::vector< BasicManagerCreationListener* > CreationListeners;
@@ -100,7 +100,7 @@ namespace basic
@precond
our mutex is locked
*/
- BasicManager*&
+ std::unique_ptr<BasicManager>&
impl_getLocationForModel( const Reference< XModel >& _rxDocumentModel );
/** tests if there is a location set at which the BasicManager for the given model
@@ -124,7 +124,7 @@ namespace basic
the model whose BasicManager will be created. Must not be <NULL/>.
*/
bool impl_createManagerForModel(
- BasicManager*& _out_rpBasicManager,
+ std::unique_ptr<BasicManager>& _out_rpBasicManager,
const Reference< XModel >& _rxDocumentModel );
/** creates the application-wide BasicManager
@@ -229,11 +229,11 @@ namespace basic
thus a recursive call of this function will find and return it
without creating another instance.
*/
- BasicManager*& pBasicManager = impl_getLocationForModel( _rxDocumentModel );
+ std::unique_ptr<BasicManager>& pBasicManager = impl_getLocationForModel( _rxDocumentModel );
if (pBasicManager != nullptr)
- return pBasicManager;
+ return pBasicManager.get();
if (impl_createManagerForModel(pBasicManager, _rxDocumentModel))
- return pBasicManager;
+ return pBasicManager.get();
return nullptr;
}
@@ -364,12 +364,12 @@ namespace basic
return pAppBasic;
}
- BasicManager*& ImplRepository::impl_getLocationForModel( const Reference< XModel >& _rxDocumentModel )
+ std::unique_ptr<BasicManager>& ImplRepository::impl_getLocationForModel( const Reference< XModel >& _rxDocumentModel )
{
Reference< XInterface > xNormalized( _rxDocumentModel, UNO_QUERY );
DBG_ASSERT( _rxDocumentModel.is(), "ImplRepository::impl_getLocationForModel: invalid model!" );
- BasicManager*& location = m_aStore[ xNormalized ];
+ std::unique_ptr<BasicManager>& location = m_aStore[ xNormalized ];
return location;
}
@@ -406,7 +406,7 @@ namespace basic
}
}
- bool ImplRepository::impl_createManagerForModel( BasicManager*& _out_rpBasicManager, const Reference< XModel >& _rxDocumentModel )
+ bool ImplRepository::impl_createManagerForModel( std::unique_ptr<BasicManager>& _out_rpBasicManager, const Reference< XModel >& _rxDocumentModel )
{
StarBASIC* pAppBasic = impl_getDefaultAppBasicLibrary();
@@ -432,9 +432,9 @@ namespace basic
// Storage and BaseURL are only needed by binary documents!
tools::SvRef<SotStorage> xDummyStor = new SotStorage( OUString() );
- _out_rpBasicManager = new BasicManager( *xDummyStor, OUString() /* TODO/LATER: xStorage */,
+ _out_rpBasicManager.reset(new BasicManager( *xDummyStor, OUString() /* TODO/LATER: xStorage */,
pAppBasic,
- &aAppBasicDir, true );
+ &aAppBasicDir, true ));
if ( !_out_rpBasicManager->GetErrors().empty() )
{
// handle errors
@@ -445,8 +445,7 @@ namespace basic
if ( ErrorHandler::HandleError( rError.GetErrorId() ) == DialogMask::ButtonsCancel )
{
// user wants to break loading of BASIC-manager
- delete _out_rpBasicManager;
- _out_rpBasicManager = nullptr;
+ _out_rpBasicManager.reset();
xStorage.clear();
break;
}
@@ -460,7 +459,7 @@ namespace basic
// create new BASIC-manager
StarBASIC* pBasic = new StarBASIC( pAppBasic );
pBasic->SetFlag( SbxFlagBits::ExtSearch );
- _out_rpBasicManager = new BasicManager( pBasic, nullptr, true );
+ _out_rpBasicManager.reset(new BasicManager( pBasic, nullptr, true ));
}
// knit the containers with the BasicManager
@@ -543,14 +542,13 @@ namespace basic
{
OSL_PRECOND( _pos != m_aStore.end(), "ImplRepository::impl_removeFromRepository: invalid position!" );
- BasicManager* pManager = _pos->second;
+ std::unique_ptr<BasicManager> pManager = std::move(_pos->second);
// *first* remove from map (else Notify won't work properly)
m_aStore.erase( _pos );
// *then* delete the BasicManager
EndListening( *pManager );
- delete pManager;
}
@@ -590,7 +588,7 @@ namespace basic
++loop
)
{
- if ( loop->second == pManager )
+ if ( loop->second.get() == pManager )
{
// a BasicManager which is still in our repository is being deleted.
// That's bad, since by definition, we *own* all instances in our