summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-08-02 12:44:49 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-08-03 09:00:42 +0200
commit1da9761c72e0893ee01abacb341435a1539a1f93 (patch)
tree394d7971801808dc4d828dfd3a0ec369f50dcaed
parent5934d4ab724c96f69ef0d5b0c76d770c1f615960 (diff)
loplugin:useuniqueptr in ImplHomMatrixTemplate
Change-Id: I31175a5110672e864b07d6b5508b8b04b14e66ee Reviewed-on: https://gerrit.libreoffice.org/58484 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
-rw-r--r--basegfx/source/inc/hommatrixtemplate.hxx29
1 files changed, 11 insertions, 18 deletions
diff --git a/basegfx/source/inc/hommatrixtemplate.hxx b/basegfx/source/inc/hommatrixtemplate.hxx
index 4e00fdf2119c..b7106f6fb22d 100644
--- a/basegfx/source/inc/hommatrixtemplate.hxx
+++ b/basegfx/source/inc/hommatrixtemplate.hxx
@@ -75,7 +75,7 @@ namespace basegfx
template < sal_uInt16 RowSize > class ImplHomMatrixTemplate
{
ImplMatLine< RowSize > maLine[RowSize - 1];
- ImplMatLine< RowSize >* mpLine;
+ std::unique_ptr<ImplMatLine< RowSize >> mutable mpLine;
public:
// Is last line used?
@@ -96,14 +96,12 @@ namespace basegfx
}
// reset last line, it equals default
- delete const_cast<ImplHomMatrixTemplate< RowSize >*>(this)->mpLine;
- const_cast<ImplHomMatrixTemplate< RowSize >*>(this)->mpLine = nullptr;
+ mpLine.reset();
return true;
}
ImplHomMatrixTemplate()
- : mpLine(nullptr)
{
// complete initialization with identity matrix, all lines
// were initialized with a trailing 1 followed by 0's.
@@ -115,26 +113,22 @@ namespace basegfx
}
ImplHomMatrixTemplate(const ImplHomMatrixTemplate& rToBeCopied)
- : mpLine(nullptr)
+ {
+ operator=(rToBeCopied);
+ }
+
+ ImplHomMatrixTemplate& operator=(const ImplHomMatrixTemplate& rToBeCopied)
{
// complete initialization using copy
for(sal_uInt16 a(0); a < (RowSize - 1); a++)
{
memcpy(&maLine[a], &rToBeCopied.maLine[a], sizeof(ImplMatLine< RowSize >));
}
-
if(rToBeCopied.mpLine)
{
- mpLine = new ImplMatLine< RowSize >((RowSize - 1), rToBeCopied.mpLine);
- }
- }
-
- ~ImplHomMatrixTemplate()
- {
- if(mpLine)
- {
- delete mpLine;
+ mpLine.reset( new ImplMatLine< RowSize >((RowSize - 1), rToBeCopied.mpLine.get()) );
}
+ return *this;
}
static sal_uInt16 getEdgeLength() { return RowSize; }
@@ -170,7 +164,7 @@ namespace basegfx
if(!::basegfx::fTools::equal(fDefault, rValue))
{
- mpLine = new ImplMatLine< RowSize >((RowSize - 1), nullptr);
+ mpLine.reset(new ImplMatLine< RowSize >((RowSize - 1), nullptr));
mpLine->set(nColumn, rValue);
}
}
@@ -195,8 +189,7 @@ namespace basegfx
if(!bNecessary)
{
- delete mpLine;
- mpLine = nullptr;
+ mpLine.reset();
}
}
}