diff options
author | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-07-12 15:44:36 +0300 |
---|---|---|
committer | Thiago Marcos P. Santos <thiago@mapbox.com> | 2016-07-12 16:04:20 +0300 |
commit | 86cebd4ccae1d0c5702ad75f1b0fb0d634bb8680 (patch) | |
tree | 2bc9262589b1f47abb0cbdacbce0be13f6b60e89 /platform/qt/src/qt_geojson.hpp | |
parent | e197540f9a6a48311eac4d8033fc0abb92b41d16 (diff) | |
download | qtlocation-mapboxgl-86cebd4ccae1d0c5702ad75f1b0fb0d634bb8680.tar.gz |
[core] Report conversion errors using std::string
char* increases the risk of pointing to a invalid reference. Qt had
to use a static variable as retainer to workaround.
Diffstat (limited to 'platform/qt/src/qt_geojson.hpp')
-rw-r--r-- | platform/qt/src/qt_geojson.hpp | 10 |
1 files changed, 2 insertions, 8 deletions
diff --git a/platform/qt/src/qt_geojson.hpp b/platform/qt/src/qt_geojson.hpp index ff7ee2eada..fd2b689fed 100644 --- a/platform/qt/src/qt_geojson.hpp +++ b/platform/qt/src/qt_geojson.hpp @@ -29,22 +29,16 @@ Result<GeoJSON> convertGeoJSON(const QVariant& value) { d.Parse<0>(value.toByteArray().constData()); } - // Needed to keep the error message alive - // when we go out of this scope. - static std::string error; - if (d.HasParseError()) { std::stringstream message; message << d.GetErrorOffset() << " - " << rapidjson::GetParseError_En(d.GetParseError()); - error = message.str(); - return Error { error.c_str() }; + return Error { message.str() }; } conversion::Result<GeoJSON> geoJSON = conversion::convertGeoJSON<JSValue>(d); if (!geoJSON) { - error = geoJSON.error().message; - return Error { error.c_str() }; + return Error { geoJSON.error().message }; } return geoJSON; |