diff options
author | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-12 15:11:48 +0200 |
---|---|---|
committer | Noel Grandin <noel.grandin@collabora.co.uk> | 2018-12-13 11:32:56 +0100 |
commit | b586bfcff288151082f7d247b392c5640ae5c951 (patch) | |
tree | cf87d67397c5c53469ca350f12b0b40e1660efdf /chart2/source/controller | |
parent | e71f44f4dc847c75b874d514888d0675ccb00496 (diff) |
use unique_ptr in checkForUniqueItem
fixing a memory leak in chart2
Change-Id: Idddb6a46b1bde5c1a11148c03bbdaac20ac78e13
Reviewed-on: https://gerrit.libreoffice.org/65031
Tested-by: Jenkins
Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'chart2/source/controller')
-rw-r--r-- | chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx | 8 | ||||
-rw-r--r-- | chart2/source/controller/sidebar/ChartAreaPanel.cxx | 5 |
2 files changed, 6 insertions, 7 deletions
diff --git a/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx b/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx index 494aee798ac9..fa7a0d319b04 100644 --- a/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx +++ b/chart2/source/controller/itemsetwrapper/GraphicPropertyItemConverter.cxx @@ -297,7 +297,7 @@ void GraphicPropertyItemConverter::FillSpecialItem( // translate model name to UI-name for predefined entries, so // that the correct entry is chosen in the list of UI-names - XLineDashItem* pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel ); + std::unique_ptr<XLineDashItem> pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel ); if(pItemToPut) rOutItemSet.Put( *pItemToPut ); @@ -323,7 +323,7 @@ void GraphicPropertyItemConverter::FillSpecialItem( // translate model name to UI-name for predefined entries, so // that the correct entry is chosen in the list of UI-names - XFillGradientItem* pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel ); + std::unique_ptr<XFillGradientItem> pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel ); if(pItemToPut) rOutItemSet.Put( *pItemToPut ); @@ -349,7 +349,7 @@ void GraphicPropertyItemConverter::FillSpecialItem( // translate model name to UI-name for predefined entries, so // that the correct entry is chosen in the list of UI-names - XFillHatchItem* pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel ); + std::unique_ptr<XFillHatchItem> pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel ); if(pItemToPut) rOutItemSet.Put( *pItemToPut ); @@ -370,7 +370,7 @@ void GraphicPropertyItemConverter::FillSpecialItem( // translate model name to UI-name for predefined entries, so // that the correct entry is chosen in the list of UI-names - XFillBitmapItem* pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel ); + std::unique_ptr<XFillBitmapItem> pItemToPut = aItem.checkForUniqueItem( & m_rDrawModel ); if(pItemToPut) rOutItemSet.Put( *pItemToPut ); diff --git a/chart2/source/controller/sidebar/ChartAreaPanel.cxx b/chart2/source/controller/sidebar/ChartAreaPanel.cxx index 023d14127922..0dd4d3e2de5c 100644 --- a/chart2/source/controller/sidebar/ChartAreaPanel.cxx +++ b/chart2/source/controller/sidebar/ChartAreaPanel.cxx @@ -458,7 +458,7 @@ void ChartAreaPanel::updateData() xPropSet->getPropertyValue("FillBitmapName") >>= aBitmapName; GraphicObject aBitmap = getXBitmapFromName(mxModel, aBitmapName); XFillBitmapItem aBitmapItem(aBitmapName, aBitmap); - XFillBitmapItem* pBitmapItem = nullptr; + std::unique_ptr<XFillBitmapItem> pBitmapItem; DrawModelWrapper* pModelWrapper = nullptr; try { @@ -471,8 +471,7 @@ void ChartAreaPanel::updateData() catch (...) { } - updateFillBitmap(false, true, pBitmapItem ? pBitmapItem : &aBitmapItem); - delete pBitmapItem; + updateFillBitmap(false, true, pBitmapItem ? pBitmapItem.get() : &aBitmapItem); } if (xInfo->hasPropertyByName("FillTransparenceGradientName")) |