Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
nagelt
ogs
Commits
8eb8a180
Commit
8eb8a180
authored
Aug 06, 2015
by
Lars Bilke
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #798 from rinkk/GmlReaderMemoryFix
[Fix] correctly deleting pointers in GmlInterface
parents
eaaa53c6
57150b21
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
71 additions
and
15 deletions
+71
-15
FileIO/XmlIO/Qt/XmlGmlInterface.cpp
FileIO/XmlIO/Qt/XmlGmlInterface.cpp
+53
-15
FileIO/XmlIO/Qt/XmlGmlInterface.h
FileIO/XmlIO/Qt/XmlGmlInterface.h
+18
-0
No files found.
FileIO/XmlIO/Qt/XmlGmlInterface.cpp
View file @
8eb8a180
...
...
@@ -35,6 +35,15 @@ int XmlGmlInterface::readFile(const QString &fileName)
if
(
XMLQtInterface
::
readFile
(
fileName
)
==
0
)
return
0
;
QDomDocument
doc
(
"OGS-GLI-DOM"
);
doc
.
setContent
(
_fileData
);
QDomElement
docElement
=
doc
.
documentElement
();
//OpenGeoSysGLI
if
(
docElement
.
nodeName
().
compare
(
"OpenGeoSysGLI"
))
{
ERR
(
"XmlGmlInterface::readFile() - Unexpected XML root."
);
return
0
;
}
std
::
string
gliName
(
"[NN]"
);
std
::
vector
<
GeoLib
::
Point
*>*
points
=
new
std
::
vector
<
GeoLib
::
Point
*>
;
...
...
@@ -45,17 +54,7 @@ int XmlGmlInterface::readFile(const QString &fileName)
std
::
map
<
std
::
string
,
std
::
size_t
>*
ply_names
=
new
std
::
map
<
std
::
string
,
std
::
size_t
>
;
std
::
map
<
std
::
string
,
std
::
size_t
>*
sfc_names
=
new
std
::
map
<
std
::
string
,
std
::
size_t
>
;
QDomDocument
doc
(
"OGS-GLI-DOM"
);
doc
.
setContent
(
_fileData
);
QDomElement
docElement
=
doc
.
documentElement
();
//OpenGeoSysGLI
if
(
docElement
.
nodeName
().
compare
(
"OpenGeoSysGLI"
))
{
ERR
(
"XmlGmlInterface::readFile() - Unexpected XML root."
);
return
0
;
}
QDomNodeList
geoTypes
=
docElement
.
childNodes
();
for
(
int
i
=
0
;
i
<
geoTypes
.
count
();
i
++
)
{
const
QDomNode
type_node
(
geoTypes
.
at
(
i
));
...
...
@@ -64,6 +63,7 @@ int XmlGmlInterface::readFile(const QString &fileName)
if
(
type_node
.
toElement
().
text
().
isEmpty
())
{
ERR
(
"XmlGmlInterface::readFile(): <name>-tag is empty."
)
deleteGeometry
(
points
,
polylines
,
surfaces
,
pnt_names
,
ply_names
,
sfc_names
);
return
0
;
}
else
...
...
@@ -81,9 +81,14 @@ int XmlGmlInterface::readFile(const QString &fileName)
_geo_objs
.
getPointVecObj
(
gliName
)
->
getIDMap
(),
sfc_names
);
}
if
(
!
polylines
->
empty
())
if
(
polylines
->
empty
())
deletePolylines
(
polylines
,
ply_names
);
else
_geo_objs
.
addPolylineVec
(
polylines
,
gliName
,
ply_names
);
if
(
!
surfaces
->
empty
())
if
(
surfaces
->
empty
())
deleteSurfaces
(
surfaces
,
sfc_names
);
else
_geo_objs
.
addSurfaceVec
(
surfaces
,
gliName
,
sfc_names
);
return
1
;
}
...
...
@@ -113,7 +118,7 @@ void XmlGmlInterface::readPoints(const QDomNode &pointsRoot, std::vector<GeoLib:
if
(
pnt_names
->
empty
())
{
delete
pnt_names
;
pnt_names
=
NULL
;
pnt_names
=
nullptr
;
}
}
...
...
@@ -159,7 +164,7 @@ void XmlGmlInterface::readPolylines(const QDomNode &polylinesRoot,
if
(
ply_names
->
empty
())
{
delete
ply_names
;
ply_names
=
NULL
;
ply_names
=
nullptr
;
}
}
...
...
@@ -195,10 +200,43 @@ void XmlGmlInterface::readSurfaces(const QDomNode &surfacesRoot,
if
(
sfc_names
->
empty
())
{
delete
sfc_names
;
sfc_names
=
NULL
;
sfc_names
=
nullptr
;
}
}
void
XmlGmlInterface
::
deleteGeometry
(
std
::
vector
<
GeoLib
::
Point
*>*
points
,
std
::
vector
<
GeoLib
::
Polyline
*>*
polylines
,
std
::
vector
<
GeoLib
::
Surface
*>*
surfaces
,
std
::
map
<
std
::
string
,
std
::
size_t
>*
pnt_names
,
std
::
map
<
std
::
string
,
std
::
size_t
>*
ply_names
,
std
::
map
<
std
::
string
,
std
::
size_t
>*
sfc_names
)
const
{
for
(
GeoLib
::
Point
*
point
:
*
points
)
delete
point
;
delete
points
;
delete
pnt_names
;
deletePolylines
(
polylines
,
ply_names
);
deleteSurfaces
(
surfaces
,
sfc_names
);
}
void
XmlGmlInterface
::
deletePolylines
(
std
::
vector
<
GeoLib
::
Polyline
*>*
polylines
,
std
::
map
<
std
::
string
,
std
::
size_t
>*
ply_names
)
const
{
for
(
GeoLib
::
Polyline
*
line
:
*
polylines
)
delete
line
;
delete
polylines
;
delete
ply_names
;
}
void
XmlGmlInterface
::
deleteSurfaces
(
std
::
vector
<
GeoLib
::
Surface
*>*
surfaces
,
std
::
map
<
std
::
string
,
std
::
size_t
>*
sfc_names
)
const
{
for
(
GeoLib
::
Surface
*
line
:
*
surfaces
)
delete
line
;
delete
surfaces
;
delete
sfc_names
;
}
bool
XmlGmlInterface
::
write
()
{
if
(
this
->
_exportName
.
empty
())
...
...
FileIO/XmlIO/Qt/XmlGmlInterface.h
View file @
8eb8a180
...
...
@@ -15,6 +15,8 @@
#ifndef XMLGMLINTERFACE_H
#define XMLGMLINTERFACE_H
#include <QString>
#include "../XMLInterface.h"
#include "XMLQtInterface.h"
...
...
@@ -61,6 +63,22 @@ private:
const
std
::
vector
<
std
::
size_t
>
&
pnt_id_map
,
std
::
map
<
std
::
string
,
std
::
size_t
>*
&
sfc_names
);
/// Deletes all geometry data structures
void
deleteGeometry
(
std
::
vector
<
GeoLib
::
Point
*>*
points
,
std
::
vector
<
GeoLib
::
Polyline
*>*
polylines
,
std
::
vector
<
GeoLib
::
Surface
*>*
surfaces
,
std
::
map
<
std
::
string
,
std
::
size_t
>*
pnt_names
,
std
::
map
<
std
::
string
,
std
::
size_t
>*
ply_names
,
std
::
map
<
std
::
string
,
std
::
size_t
>*
sfc_names
)
const
;
/// Cleans up polylines-vector as well as its content if necessary
void
deletePolylines
(
std
::
vector
<
GeoLib
::
Polyline
*>*
polylines
,
std
::
map
<
std
::
string
,
std
::
size_t
>*
ply_names
)
const
;
/// Cleans up surfaces-vector as well as its content if necessary
void
deleteSurfaces
(
std
::
vector
<
GeoLib
::
Surface
*>*
surfaces
,
std
::
map
<
std
::
string
,
std
::
size_t
>*
sfc_names
)
const
;
GeoLib
::
GEOObjects
&
_geo_objs
;
std
::
map
<
std
::
size_t
,
std
::
size_t
>
_idx_map
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment