Kaydet (Commit) 904263cd authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in TaskManager::UnqPathData

Change-Id: I6b6e7b59113fcae8dfafa4ed8586b87d2c82489e
Reviewed-on: https://gerrit.libreoffice.org/49092Tested-by: 's avatarJenkins <ci@libreoffice.org>
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst ee4a456d
...@@ -71,46 +71,13 @@ using namespace com::sun::star::ucb; ...@@ -71,46 +71,13 @@ using namespace com::sun::star::ucb;
#define THROW_WHERE "" #define THROW_WHERE ""
#endif #endif
TaskManager::UnqPathData::UnqPathData() TaskManager::UnqPathData::UnqPathData() = default;
: properties( nullptr ),
notifier( nullptr ),
xS( nullptr ),
xC( nullptr ),
xA( nullptr )
{
// empty
}
TaskManager::UnqPathData::UnqPathData( const UnqPathData& a )
: properties( a.properties ),
notifier( a.notifier ),
xS( a.xS ),
xC( a.xC ),
xA( a.xA )
{
}
TaskManager::UnqPathData::UnqPathData(TaskManager::UnqPathData&&) = default;
TaskManager::UnqPathData& TaskManager::UnqPathData::operator=( UnqPathData& a )
{
properties = a.properties;
notifier = a.notifier;
xS = a.xS;
xC = a.xC;
xA = a.xA;
a.properties = nullptr;
a.notifier = nullptr;
a.xS = nullptr;
a.xC = nullptr;
a.xA = nullptr;
return *this;
}
TaskManager::UnqPathData::~UnqPathData() TaskManager::UnqPathData::~UnqPathData()
{ {
delete properties;
delete notifier;
} }
TaskManager::MyProperty::MyProperty( const OUString& thePropertyName ) TaskManager::MyProperty::MyProperty( const OUString& thePropertyName )
...@@ -533,10 +500,10 @@ TaskManager::registerNotifier( const OUString& aUnqPath, Notifier* pNotifier ) ...@@ -533,10 +500,10 @@ TaskManager::registerNotifier( const OUString& aUnqPath, Notifier* pNotifier )
osl::MutexGuard aGuard( m_aMutex ); osl::MutexGuard aGuard( m_aMutex );
ContentMap::iterator it = ContentMap::iterator it =
m_aContent.emplace( aUnqPath,UnqPathData() ).first; m_aContent.emplace( aUnqPath, UnqPathData() ).first;
if( ! it->second.notifier ) if( ! it->second.notifier )
it->second.notifier = new NotifierList; it->second.notifier.reset( new NotifierList );
std::vector< Notifier* >& nlist = *( it->second.notifier ); std::vector< Notifier* >& nlist = *( it->second.notifier );
...@@ -2245,7 +2212,7 @@ void ...@@ -2245,7 +2212,7 @@ void
TaskManager::load( const ContentMap::iterator& it, bool create ) TaskManager::load( const ContentMap::iterator& it, bool create )
{ {
if( ! it->second.properties ) if( ! it->second.properties )
it->second.properties = new PropertySet; it->second.properties.reset( new PropertySet );
if( ( ! it->second.xS.is() || if( ( ! it->second.xS.is() ||
! it->second.xC.is() || ! it->second.xC.is() ||
...@@ -2772,14 +2739,11 @@ TaskManager::getContentExchangedEventListeners( const OUString& aOldPrefix, ...@@ -2772,14 +2739,11 @@ TaskManager::getContentExchangedEventListeners( const OUString& aOldPrefix,
aNewName,UnqPathData() ).first; aNewName,UnqPathData() ).first;
// copy Ownership also // copy Ownership also
delete itnew->second.properties; itnew->second.properties = std::move(itold->second.properties);
itnew->second.properties = itold->second.properties;
itold->second.properties = nullptr;
// copy existing list // copy existing list
std::vector< Notifier* >* copyList = itnew->second.notifier; std::unique_ptr<std::vector< Notifier* >> copyList = std::move(itnew->second.notifier);
itnew->second.notifier = itold->second.notifier; itnew->second.notifier = std::move(itold->second.notifier);
itold->second.notifier = nullptr;
m_aContent.erase( itold ); m_aContent.erase( itold );
...@@ -2805,7 +2769,6 @@ TaskManager::getContentExchangedEventListeners( const OUString& aOldPrefix, ...@@ -2805,7 +2769,6 @@ TaskManager::getContentExchangedEventListeners( const OUString& aOldPrefix,
++copyIt; ++copyIt;
} }
} }
delete copyList;
} }
} }
} }
...@@ -2903,8 +2866,7 @@ TaskManager::erasePersistentSet( const OUString& aUnqPath, ...@@ -2903,8 +2866,7 @@ TaskManager::erasePersistentSet( const OUString& aUnqPath,
it->second.xC = nullptr; it->second.xC = nullptr;
it->second.xA = nullptr; it->second.xA = nullptr;
delete it->second.properties; it->second.properties.reset();
it->second.properties = nullptr;
} }
} }
......
...@@ -230,12 +230,11 @@ namespace fileaccess ...@@ -230,12 +230,11 @@ namespace fileaccess
{ {
public: public:
UnqPathData(); UnqPathData();
UnqPathData(UnqPathData&&);
~UnqPathData(); ~UnqPathData();
UnqPathData( const UnqPathData& );
UnqPathData& operator=( UnqPathData& );
PropertySet* properties; std::unique_ptr<PropertySet> properties;
NotifierList* notifier; std::unique_ptr<NotifierList> notifier;
// Three views on the PersistentPropertySet // Three views on the PersistentPropertySet
css::uno::Reference< css::ucb::XPersistentPropertySet > xS; css::uno::Reference< css::ucb::XPersistentPropertySet > xS;
......
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