[gnome-maps] Fix warnings about using Uint8Array.toString()
- From: Marcus Lundblad <mlundblad src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-maps] Fix warnings about using Uint8Array.toString()
- Date: Wed, 28 Nov 2018 20:45:52 +0000 (UTC)
commit 95f28f0d514eeeeff7aefedd41db4716ffbbd0ce
Author: James Westman <flyingpimonster flyingpimonster net>
Date: Wed Nov 28 12:56:36 2018 -0600
Fix warnings about using Uint8Array.toString()
A couple instances of this warning were especially problematic because
they showed up when running `gnome-maps --help`.
scripts/extractPoiTypesFromID.js | 3 ++-
src/geoJSONShapeLayer.js | 3 ++-
src/osmTypes.js | 5 +++--
src/placeStore.js | 3 ++-
src/service.js | 3 ++-
5 files changed, 11 insertions(+), 6 deletions(-)
---
diff --git a/scripts/extractPoiTypesFromID.js b/scripts/extractPoiTypesFromID.js
index 10689f0..b115553 100755
--- a/scripts/extractPoiTypesFromID.js
+++ b/scripts/extractPoiTypesFromID.js
@@ -30,6 +30,7 @@
*/
const Gio = imports.gi.Gio;
+const ByteArray = imports.byteArray;
const PRESETS_PATH = 'data/presets/presets';
const LOCALES_PATH = 'dist/locales';
@@ -82,7 +83,7 @@ function processTypes(basePath) {
function processLocale(dirPath, fileName) {
let file = Gio.File.new_for_path(dirPath + '/' + fileName);
let [status, buffer] = file.load_contents(null);
- let object = JSON.parse(buffer);
+ let object = JSON.parse(ByteArray.toString(buffer));
let lang = fileName.substring(0, fileName.indexOf('.json'));
for (let type in OUTPUT) {
diff --git a/src/geoJSONShapeLayer.js b/src/geoJSONShapeLayer.js
index 46dcc47..d06fe94 100644
--- a/src/geoJSONShapeLayer.js
+++ b/src/geoJSONShapeLayer.js
@@ -18,6 +18,7 @@
*/
const GObject = imports.gi.GObject;
+const ByteArray = imports.byteArray;
const GeoJSONSource = imports.geoJSONSource;
const ShapeLayer = imports.shapeLayer;
@@ -44,7 +45,7 @@ class GeoJSONShapeLayer extends ShapeLayer.ShapeLayer {
}
_parseContent() {
- this._mapSource.parse(JSON.parse(this._fileContents));
+ this._mapSource.parse(JSON.parse(ByteArray.toString(this._fileContents)));
}
});
diff --git a/src/osmTypes.js b/src/osmTypes.js
index 40980c6..8e95530 100644
--- a/src/osmTypes.js
+++ b/src/osmTypes.js
@@ -21,6 +21,7 @@
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
+const ByteArray = imports.byteArray;
const Utils = imports.utils;
@@ -29,7 +30,7 @@ const _NUM_RECENT_TYPES = 10;
const _file = Gio.file_new_for_uri('resource://org/gnome/Maps/osm-types.json');
const [_status, _buffer] = _file.load_contents(null);
-const OSM_TYPE_MAP = JSON.parse(_buffer);
+const OSM_TYPE_MAP = JSON.parse(ByteArray.toString(_buffer));
/* Lists the OSM tags we base our notion of location types on */
var OSM_TYPE_TAGS = ['aeroway', 'amenity', 'leisure', 'office', 'place', 'shop', 'tourism' ];
@@ -128,7 +129,7 @@ var RecentTypesStore = class RecentTypesStore {
return;
}
- this._recentTypes = JSON.parse(buffer);
+ this._recentTypes = JSON.parse(ByteArray.toString(buffer));
}
_save() {
diff --git a/src/placeStore.js b/src/placeStore.js
index 7b3abc7..7c240ae 100644
--- a/src/placeStore.js
+++ b/src/placeStore.js
@@ -22,6 +22,7 @@ const GObject = imports.gi.GObject;
const GdkPixbuf = imports.gi.GdkPixbuf;
const Geocode = imports.gi.GeocodeGlib;
const Gtk = imports.gi.Gtk;
+const ByteArray = imports.byteArray;
const ContactPlace = imports.contactPlace;
const Place = imports.place;
@@ -165,7 +166,7 @@ class PlaceStore extends Gtk.ListStore {
if (buffer === null)
return;
try {
- let jsonArray = JSON.parse(buffer);
+ let jsonArray = JSON.parse(ByteArray.toString(buffer));
jsonArray.forEach(({ place, type, added }) => {
// We expect exception to be thrown in this line when parsing
// gnome-maps 3.14 or below place stores since the "place"
diff --git a/src/service.js b/src/service.js
index cf0654c..c1f5413 100644
--- a/src/service.js
+++ b/src/service.js
@@ -22,6 +22,7 @@
const Gio = imports.gi.Gio;
const GLib = imports.gi.GLib;
const Soup = imports.gi.Soup;
+const ByteArray = imports.byteArray;
const Utils = imports.utils;
@@ -36,7 +37,7 @@ function _getServiceFromFile(filename) {
log('Failed to open service file: ' + filename);
System.exit(1);
}
- _service = JSON.parse(data);
+ _service = JSON.parse(ByteArray.toString(data));
return _service;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]