summaryrefslogtreecommitdiff
path: root/UnoControls
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
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')
-rw-r--r--UnoControls/source/base/basecontainercontrol.cxx2
-rw-r--r--UnoControls/source/controls/progressmonitor.cxx38
-rw-r--r--UnoControls/source/inc/progressmonitor.hxx5
3 files changed, 18 insertions, 27 deletions
diff --git a/UnoControls/source/base/basecontainercontrol.cxx b/UnoControls/source/base/basecontainercontrol.cxx
index 499bf34e6bd9..cbc476731078 100644
--- a/UnoControls/source/base/basecontainercontrol.cxx
+++ b/UnoControls/source/base/basecontainercontrol.cxx
@@ -167,8 +167,6 @@ void SAL_CALL BaseContainerControl::dispose()
// remove controls
Sequence< Reference< XControl > > seqCtrls = getControls();
- for ( auto & i : maControlInfoList )
- delete i;
maControlInfoList.clear();
for ( Reference< XControl > const & control : seqCtrls )
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 )
{
diff --git a/UnoControls/source/inc/progressmonitor.hxx b/UnoControls/source/inc/progressmonitor.hxx
index 5ab211eaa0ef..e31cdab1de1c 100644
--- a/UnoControls/source/inc/progressmonitor.hxx
+++ b/UnoControls/source/inc/progressmonitor.hxx
@@ -60,6 +60,7 @@
#include <rtl/ref.hxx>
#include <vector>
+#include <memory>
#include <basecontainercontrol.hxx>
@@ -276,11 +277,11 @@ private:
// private variables
private:
- ::std::vector < IMPL_TextlistItem* > maTextlist_Top; // Elements before progress
+ ::std::vector < std::unique_ptr<IMPL_TextlistItem> > maTextlist_Top; // Elements before progress
css::uno::Reference< css::awt::XFixedText > m_xTopic_Top; // (used, if parameter "beforeProgress"=true in "addText, updateText, removeText")
css::uno::Reference< css::awt::XFixedText > m_xText_Top;
- ::std::vector < IMPL_TextlistItem* > maTextlist_Bottom; // Elements below of progress
+ ::std::vector < std::unique_ptr<IMPL_TextlistItem> > maTextlist_Bottom; // Elements below of progress
css::uno::Reference< css::awt::XFixedText > m_xTopic_Bottom; // (used, if parameter "beforeProgress"=false in "addText, updateText, removeText")
css::uno::Reference< css::awt::XFixedText > m_xText_Bottom;