Kaydet (Commit) 1da9761c authored tarafından Noel Grandin's avatar Noel Grandin

loplugin:useuniqueptr in ImplHomMatrixTemplate

Change-Id: I31175a5110672e864b07d6b5508b8b04b14e66ee
Reviewed-on: https://gerrit.libreoffice.org/58484
Tested-by: Jenkins
Reviewed-by: 's avatarNoel Grandin <noel.grandin@collabora.co.uk>
üst 5934d4ab
...@@ -75,7 +75,7 @@ namespace basegfx ...@@ -75,7 +75,7 @@ namespace basegfx
template < sal_uInt16 RowSize > class ImplHomMatrixTemplate template < sal_uInt16 RowSize > class ImplHomMatrixTemplate
{ {
ImplMatLine< RowSize > maLine[RowSize - 1]; ImplMatLine< RowSize > maLine[RowSize - 1];
ImplMatLine< RowSize >* mpLine; std::unique_ptr<ImplMatLine< RowSize >> mutable mpLine;
public: public:
// Is last line used? // Is last line used?
...@@ -96,14 +96,12 @@ namespace basegfx ...@@ -96,14 +96,12 @@ namespace basegfx
} }
// reset last line, it equals default // reset last line, it equals default
delete const_cast<ImplHomMatrixTemplate< RowSize >*>(this)->mpLine; mpLine.reset();
const_cast<ImplHomMatrixTemplate< RowSize >*>(this)->mpLine = nullptr;
return true; return true;
} }
ImplHomMatrixTemplate() ImplHomMatrixTemplate()
: mpLine(nullptr)
{ {
// complete initialization with identity matrix, all lines // complete initialization with identity matrix, all lines
// were initialized with a trailing 1 followed by 0's. // were initialized with a trailing 1 followed by 0's.
...@@ -115,26 +113,22 @@ namespace basegfx ...@@ -115,26 +113,22 @@ namespace basegfx
} }
ImplHomMatrixTemplate(const ImplHomMatrixTemplate& rToBeCopied) ImplHomMatrixTemplate(const ImplHomMatrixTemplate& rToBeCopied)
: mpLine(nullptr) {
operator=(rToBeCopied);
}
ImplHomMatrixTemplate& operator=(const ImplHomMatrixTemplate& rToBeCopied)
{ {
// complete initialization using copy // complete initialization using copy
for(sal_uInt16 a(0); a < (RowSize - 1); a++) for(sal_uInt16 a(0); a < (RowSize - 1); a++)
{ {
memcpy(&maLine[a], &rToBeCopied.maLine[a], sizeof(ImplMatLine< RowSize >)); memcpy(&maLine[a], &rToBeCopied.maLine[a], sizeof(ImplMatLine< RowSize >));
} }
if(rToBeCopied.mpLine) if(rToBeCopied.mpLine)
{ {
mpLine = new ImplMatLine< RowSize >((RowSize - 1), rToBeCopied.mpLine); mpLine.reset( new ImplMatLine< RowSize >((RowSize - 1), rToBeCopied.mpLine.get()) );
}
}
~ImplHomMatrixTemplate()
{
if(mpLine)
{
delete mpLine;
} }
return *this;
} }
static sal_uInt16 getEdgeLength() { return RowSize; } static sal_uInt16 getEdgeLength() { return RowSize; }
...@@ -170,7 +164,7 @@ namespace basegfx ...@@ -170,7 +164,7 @@ namespace basegfx
if(!::basegfx::fTools::equal(fDefault, rValue)) 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); mpLine->set(nColumn, rValue);
} }
} }
...@@ -195,8 +189,7 @@ namespace basegfx ...@@ -195,8 +189,7 @@ namespace basegfx
if(!bNecessary) if(!bNecessary)
{ {
delete mpLine; mpLine.reset();
mpLine = nullptr;
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment