[Libreoffice-commits] libvisio.git: 2 commits - src/lib
David Tardon
dtardon at redhat.com
Mon Apr 17 11:23:42 UTC 2017
src/lib/VSDXMLParserBase.cpp | 16 ++++------------
src/lib/VSDXMLParserBase.h | 3 ++-
2 files changed, 6 insertions(+), 13 deletions(-)
New commits:
commit ed6c411a41b66e2320835a68570eeb21eda4a207
Author: David Tardon <dtardon at redhat.com>
Date: Mon Apr 17 13:20:49 2017 +0200
use std::unique_ptr to manage current stencil
Change-Id: I62385c2e6a930186fe9469dbd609052f8cfb5a33
diff --git a/src/lib/VSDXMLParserBase.cpp b/src/lib/VSDXMLParserBase.cpp
index 917990d..76fa5b3 100644
--- a/src/lib/VSDXMLParserBase.cpp
+++ b/src/lib/VSDXMLParserBase.cpp
@@ -7,7 +7,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
-#include <memory>
#include <string.h>
#include <libxml/xmlIO.h>
#include <libxml/xmlstring.h>
@@ -24,7 +23,7 @@
using std::shared_ptr;
libvisio::VSDXMLParserBase::VSDXMLParserBase()
- : m_collector(), m_stencils(), m_currentStencil(0), m_shape(),
+ : m_collector(), m_stencils(), m_currentStencil(), m_shape(),
m_isStencilStarted(false), m_currentStencilID(MINUS_ONE),
m_extractStencils(false), m_isInStyles(false), m_currentLevel(0),
m_currentShapeLevel(0), m_colours(), m_fieldList(), m_shapeList(),
@@ -38,8 +37,6 @@ libvisio::VSDXMLParserBase::VSDXMLParserBase()
libvisio::VSDXMLParserBase::~VSDXMLParserBase()
{
- if (m_currentStencil)
- delete m_currentStencil;
}
// Common functions
@@ -1700,9 +1697,7 @@ void libvisio::VSDXMLParserBase::readStencil(xmlTextReaderPtr reader)
}
else
m_currentStencilID = MINUS_ONE;
- if (m_currentStencil)
- delete m_currentStencil;
- m_currentStencil = new VSDStencil();
+ m_currentStencil.reset(new VSDStencil());
}
void libvisio::VSDXMLParserBase::readForeignData(xmlTextReaderPtr reader)
@@ -1928,11 +1923,8 @@ void libvisio::VSDXMLParserBase::handleMasterEnd(xmlTextReaderPtr /* reader */)
else
{
if (m_currentStencil)
- {
m_stencils.addStencil(m_currentStencilID, *m_currentStencil);
- delete m_currentStencil;
- }
- m_currentStencil = 0;
+ m_currentStencil.reset();
m_currentStencilID = MINUS_ONE;
}
}
diff --git a/src/lib/VSDXMLParserBase.h b/src/lib/VSDXMLParserBase.h
index d53946c..ab8521d 100644
--- a/src/lib/VSDXMLParserBase.h
+++ b/src/lib/VSDXMLParserBase.h
@@ -11,6 +11,7 @@
#define __VSDXMLPARSERBASE_H__
#include <map>
+#include <memory>
#include <stack>
#include <string>
#include <boost/optional.hpp>
@@ -38,7 +39,7 @@ protected:
// Protected data
VSDCollector *m_collector;
VSDStencils m_stencils;
- VSDStencil *m_currentStencil;
+ std::unique_ptr<VSDStencil> m_currentStencil;
VSDShape m_shape;
bool m_isStencilStarted;
unsigned m_currentStencilID;
commit 06cd52a14cb5d342637e7d6673e5f68ea38638f5
Author: David Tardon <dtardon at redhat.com>
Date: Mon Apr 17 13:18:53 2017 +0200
ofz: check if there is a stencil before using it
Change-Id: Ib1fa347e007e84a2909449bf0a3bb73a55ca4d4f
diff --git a/src/lib/VSDXMLParserBase.cpp b/src/lib/VSDXMLParserBase.cpp
index d5a1005..917990d 100644
--- a/src/lib/VSDXMLParserBase.cpp
+++ b/src/lib/VSDXMLParserBase.cpp
@@ -954,7 +954,7 @@ void libvisio::VSDXMLParserBase::readShape(xmlTextReaderPtr reader)
m_shape.clear();
m_shape.m_textFormat = VSD_TEXT_UTF8;
- if (m_isStencilStarted)
+ if (m_isStencilStarted && m_currentStencil)
m_currentStencil->setFirstShape(id);
const VSDStencil *tmpStencil = m_stencils.getStencil(masterPage);
More information about the Libreoffice-commits
mailing list