[Libreoffice-commits] core.git: starmath/inc starmath/source

Noel Grandin noel.grandin at collabora.co.uk
Fri Mar 16 07:25:14 UTC 2018


 starmath/inc/dialog.hxx    |    8 ++++----
 starmath/source/dialog.cxx |   15 +++++----------
 2 files changed, 9 insertions(+), 14 deletions(-)

New commits:
commit a47baea83f761937f5b8b5ed0ee142d3e04386d4
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Thu Mar 15 11:57:18 2018 +0200

    loplugin:useuniqueptr in SmCategoryDesc
    
    Change-Id: I4a6be3c84fb7c64b5f72499e5393e44f02514201
    Reviewed-on: https://gerrit.libreoffice.org/51334
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/starmath/inc/dialog.hxx b/starmath/inc/dialog.hxx
index 7de61cf8b7dd..6b71b2791a6c 100644
--- a/starmath/inc/dialog.hxx
+++ b/starmath/inc/dialog.hxx
@@ -179,8 +179,8 @@ public:
 class SmCategoryDesc
 {
     OUString Name;
-    OUString  *Strings[4];
-    Image *Graphics[4];    /* regular bitmaps */
+    OUString Strings[4];
+    std::unique_ptr<Image> Graphics[4];    /* regular bitmaps */
     sal_uInt16 Minimum[4];
     sal_uInt16 Maximum[4];
     sal_uInt16 Value[4];
@@ -190,7 +190,7 @@ public:
     ~SmCategoryDesc();
 
     const OUString& GetName() const                 { return Name; }
-    const OUString* GetString(sal_uInt16 Index) const   { return Strings[Index];  }
+    const OUString& GetString(sal_uInt16 Index) const   { return Strings[Index];  }
     sal_uInt16          GetMinimum(sal_uInt16 Index)        { return Minimum[Index]; }
     sal_uInt16          GetMaximum(sal_uInt16 Index)        { return Maximum[Index]; }
     sal_uInt16          GetValue(sal_uInt16 Index) const    { return Value[Index]; }
@@ -198,7 +198,7 @@ public:
 
     const Image *  GetGraphic(sal_uInt16 Index) const
     {
-        return Graphics[Index];
+        return Graphics[Index].get();
     }
 };
 
diff --git a/starmath/source/dialog.cxx b/starmath/source/dialog.cxx
index beb269afdc62..7c9024596cff 100644
--- a/starmath/source/dialog.cxx
+++ b/starmath/source/dialog.cxx
@@ -650,14 +650,14 @@ SmCategoryDesc::SmCategoryDesc(VclBuilderContainer& rBuilder, sal_uInt16 nCatego
 
         if (pLabel)
         {
-            Strings  [i] = new OUString(pLabel->GetText());
+            Strings[i] = pLabel->GetText();
             FixedImage* pImage = rBuilder.get<FixedImage>(OString::number(nCategoryIdx)+"image"+OString::number(i+1));
-            Graphics [i] = new Image(pImage->GetImage());
+            Graphics[i].reset(new Image(pImage->GetImage()));
         }
         else
         {
-            Strings  [i] = nullptr;
-            Graphics [i] = nullptr;
+            Strings[i].clear();
+            Graphics[i].reset();
         }
 
         const FieldMinMax& rMinMax = pMinMaxData[ nCategoryIdx-1 ][i];
@@ -668,11 +668,6 @@ SmCategoryDesc::SmCategoryDesc(VclBuilderContainer& rBuilder, sal_uInt16 nCatego
 
 SmCategoryDesc::~SmCategoryDesc()
 {
-    for (int i = 0; i < 4; ++i)
-    {
-        delete Strings  [i];
-        delete Graphics [i];
-    }
 }
 
 /**************************************************************************/
@@ -829,7 +824,7 @@ void SmDistanceDialog::SetCategory(sal_uInt16 nCategory)
         if (bActive)
         {
             pCat = Categories[nCategory];
-            pFT->SetText(*pCat->GetString(i));
+            pFT->SetText(pCat->GetString(i));
 
             pMF->SetMin(pCat->GetMinimum(i));
             pMF->SetMax(pCat->GetMaximum(i));


More information about the Libreoffice-commits mailing list