diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-26 09:41:14 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2017-06-27 08:42:36 +0200 |
commit | 513ac8eb79e45de332d7ddab5b27c70578b904f1 (patch) | |
tree | 46f35b236d75651eb612a088e2cdfd48aa85a21c /svtools | |
parent | 72b706d7def9e4805e35f3174170dad422b2e7f8 (diff) |
loplugin:useuniqueptr in various
extending it to find places we can use std::unique_ptr on arrays
Change-Id: I9feb1d12d738d6931e752ecb6dd51cbc1540c81b
Reviewed-on: https://gerrit.libreoffice.org/39255
Tested-by: Jenkins <ci@libreoffice.org>
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/control/ctrltool.cxx | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/svtools/source/control/ctrltool.cxx b/svtools/source/control/ctrltool.cxx index c4ab3de8dbcf..1586caf4959d 100644 --- a/svtools/source/control/ctrltool.cxx +++ b/svtools/source/control/ctrltool.cxx @@ -338,7 +338,6 @@ FontList::FontList(OutputDevice* pDevice, OutputDevice* pDevice2) // initialise variables mpDev = pDevice; mpDev2 = pDevice2; - mpSizeAry = nullptr; // store style names maLight = SvtResId(STR_SVT_STYLE_LIGHT); @@ -368,9 +367,6 @@ FontList::FontList(OutputDevice* pDevice, OutputDevice* pDevice2) FontList::~FontList() { - // delete SizeArray if required - delete[] mpSizeAry; - // delete FontMetrics ImplFontListFontMetric *pTemp, *pInfo; for (auto const& it : m_Entries) @@ -748,11 +744,7 @@ const FontMetric& FontList::GetFontMetric( sal_Handle hFontMetric ) const sal_IntPtr* FontList::GetSizeAry( const FontMetric& rInfo ) const { // first delete Size-Array - if ( mpSizeAry ) - { - delete[] const_cast<FontList*>(this)->mpSizeAry; - const_cast<FontList*>(this)->mpSizeAry = nullptr; - } + mpSizeAry.reset(); // use standard sizes if no name if ( rInfo.GetFamilyName().isEmpty() ) @@ -775,21 +767,21 @@ const sal_IntPtr* FontList::GetSizeAry( const FontMetric& rInfo ) const int nRealCount = 0; long nOldHeight = 0; - const_cast<FontList*>(this)->mpSizeAry = new sal_IntPtr[nDevSizeCount+1]; + mpSizeAry.reset(new sal_IntPtr[nDevSizeCount+1] ); for (int i = 0; i < nDevSizeCount; ++i) { Size aSize = pDevice->GetDevFontSize( rInfo, i ); if ( aSize.Height() != nOldHeight ) { nOldHeight = aSize.Height(); - const_cast<FontList*>(this)->mpSizeAry[nRealCount] = nOldHeight; + mpSizeAry[nRealCount] = nOldHeight; nRealCount++; } } - const_cast<FontList*>(this)->mpSizeAry[nRealCount] = 0; + mpSizeAry[nRealCount] = 0; pDevice->SetMapMode( aOldMapMode ); - return mpSizeAry; + return mpSizeAry.get(); } struct ImplFSNameItem |