summaryrefslogtreecommitdiff
path: root/UnoControls/source/controls/progressmonitor.cxx
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-04-12 15:39:25 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-04-16 08:22:07 +0200
commit2e0cf814671e99a1d1a902a5828768c620c4674c (patch)
tree59de8b1025745214c56c64bb83deaec34dfb96f6 /UnoControls/source/controls/progressmonitor.cxx
parent2d2906da813362d83bc6a7d7093eefcc9566dbb1 (diff)
loplugin:useuniqueptr in ProgressMonitor
Change-Id: Ic66e49037c04501a2c39a69f3f8a2a03cb10b5fc Reviewed-on: https://gerrit.libreoffice.org/52884 Tested-by: Jenkins <ci@libreoffice.org> Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'UnoControls/source/controls/progressmonitor.cxx')
-rw-r--r--UnoControls/source/controls/progressmonitor.cxx38
1 files changed, 15 insertions, 23 deletions
diff --git a/UnoControls/source/controls/progressmonitor.cxx b/UnoControls/source/controls/progressmonitor.cxx
index 4d513ee26b2f..b43afd5d6e73 100644
--- a/UnoControls/source/controls/progressmonitor.cxx
+++ b/UnoControls/source/controls/progressmonitor.cxx
@@ -197,7 +197,7 @@ void SAL_CALL ProgressMonitor::addText(
}
// Else ... take memory for new item ...
- IMPL_TextlistItem* pTextItem = new IMPL_TextlistItem;
+ std::unique_ptr<IMPL_TextlistItem> pTextItem(new IMPL_TextlistItem);
// Set values ...
pTextItem->sTopic = rTopic;
@@ -209,11 +209,11 @@ void SAL_CALL ProgressMonitor::addText(
// ... and insert it in right list.
if ( bbeforeProgress )
{
- maTextlist_Top.push_back( pTextItem );
+ maTextlist_Top.push_back( std::move(pTextItem) );
}
else
{
- maTextlist_Bottom.push_back( pTextItem );
+ maTextlist_Bottom.push_back( std::move(pTextItem) );
}
// ... update window
@@ -239,15 +239,17 @@ void SAL_CALL ProgressMonitor::removeText ( const OUString& rTopic, sal_Bool bbe
// ... delete item from right list ...
if ( bbeforeProgress )
{
- vector< IMPL_TextlistItem* >::iterator
- itr = find( maTextlist_Top.begin(), maTextlist_Top.end(), pSearchItem );
+ auto itr = std::find_if( maTextlist_Top.begin(), maTextlist_Top.end(),
+ [&] (std::unique_ptr<IMPL_TextlistItem> const &p)
+ { return p.get() == pSearchItem; } );
if (itr != maTextlist_Top.end())
maTextlist_Top.erase(itr);
}
else
{
- vector< IMPL_TextlistItem* >::iterator
- itr = find( maTextlist_Bottom.begin(), maTextlist_Bottom.end(), pSearchItem );
+ auto itr = std::find_if( maTextlist_Bottom.begin(), maTextlist_Bottom.end(),
+ [&] (std::unique_ptr<IMPL_TextlistItem> const &p)
+ { return p.get() == pSearchItem; } );
if (itr != maTextlist_Bottom.end())
maTextlist_Bottom.erase(itr);
}
@@ -723,7 +725,7 @@ void ProgressMonitor::impl_rebuildFixedText ()
// Collect all topics from list and format text.
// "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!!
- for (IMPL_TextlistItem* pSearchItem : maTextlist_Top)
+ for (auto const & pSearchItem : maTextlist_Top)
{
aCollectString += pSearchItem->sTopic + "\n";
}
@@ -738,7 +740,7 @@ void ProgressMonitor::impl_rebuildFixedText ()
// Collect all topics from list and format text.
// "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!!
- for (IMPL_TextlistItem* pSearchItem : maTextlist_Top)
+ for (auto const & pSearchItem : maTextlist_Top)
{
aCollectString += pSearchItem->sText + "\n";
}
@@ -755,7 +757,7 @@ void ProgressMonitor::impl_rebuildFixedText ()
// Collect all topics from list and format text.
// "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!!
- for (IMPL_TextlistItem* pSearchItem : maTextlist_Bottom)
+ for (auto const & pSearchItem : maTextlist_Bottom)
{
aCollectString += pSearchItem->sTopic + "\n";
}
@@ -770,7 +772,7 @@ void ProgressMonitor::impl_rebuildFixedText ()
// Collect all topics from list and format text.
// "\n" MUST BE at the end of line!!! => Else ... topic and his text are not in the same line!!!
- for (IMPL_TextlistItem* pSearchItem : maTextlist_Bottom)
+ for (auto const & pSearchItem : maTextlist_Bottom)
{
aCollectString += pSearchItem->sText + "\n";
}
@@ -786,17 +788,7 @@ void ProgressMonitor::impl_cleanMemory ()
MutexGuard aGuard ( m_aMutex );
// Delete all of lists.
-
- for (IMPL_TextlistItem* pSearchItem : maTextlist_Top)
- {
- delete pSearchItem;
- }
maTextlist_Top.clear();
-
- for (IMPL_TextlistItem* pSearchItem : maTextlist_Bottom)
- {
- delete pSearchItem;
- }
maTextlist_Bottom.clear();
}
@@ -804,7 +796,7 @@ void ProgressMonitor::impl_cleanMemory ()
IMPL_TextlistItem* ProgressMonitor::impl_searchTopic ( const OUString& rTopic, bool bbeforeProgress )
{
// Get right textlist for following operations.
- ::std::vector< IMPL_TextlistItem* >* pTextList;
+ ::std::vector< std::unique_ptr<IMPL_TextlistItem> >* pTextList;
// Ready for multithreading
ClearableMutexGuard aGuard ( m_aMutex );
@@ -827,7 +819,7 @@ IMPL_TextlistItem* ProgressMonitor::impl_searchTopic ( const OUString& rTopic, b
for ( nPosition = 0; nPosition < nCount; ++nPosition )
{
- IMPL_TextlistItem* pSearchItem = pTextList->at( nPosition );
+ auto pSearchItem = pTextList->at( nPosition ).get();
if ( pSearchItem->sTopic == rTopic )
{