From 91250e91d6b49a65ada2ab8a9b405f4b9506b541 Mon Sep 17 00:00:00 2001 From: Marcus Lundblad Date: Tue, 13 Sep 2022 23:08:33 +0200 Subject: [PATCH 1/3] file-data-source: Read content bytes into the correct object Store the file byte contents into the task data structure. The bytes were actually stored in a local bytes object, resulting in null being passed to the renderer. --- lib/maps-file-data-source.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/lib/maps-file-data-source.c b/lib/maps-file-data-source.c index 2e326f58..40a3f91b 100644 --- a/lib/maps-file-data-source.c +++ b/lib/maps-file-data-source.c @@ -470,15 +470,14 @@ on_file_load (GObject *source_object, FillTileData *data = g_task_get_task_data (task); char *contents; gsize length; - GBytes *bytes; g_file_load_contents_finish (data->file, res, &contents, &length, NULL, NULL); if (contents != NULL) { - bytes = g_bytes_new_take (contents, length); + data->bytes = g_bytes_new_take (contents, length); g_signal_emit_by_name (data->self, "received-data", data->x, data->y, data->z, data->bytes); - g_task_return_pointer (task, g_steal_pointer (&bytes), (GDestroyNotify)g_bytes_unref); + g_task_return_pointer (task, g_steal_pointer (&data->bytes), (GDestroyNotify)g_bytes_unref); } } -- GitLab From 5e1a68a3bb0a62f2d31793e0c82c150238b0a719 Mon Sep 17 00:00:00 2001 From: Marcus Lundblad Date: Tue, 13 Sep 2022 23:11:18 +0200 Subject: [PATCH 2/3] mapView: Fix initializing local tile data source Remove reference to non-existing variable "renderer". Use the correct zoom level properties from the file data source. --- src/mapView.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/mapView.js b/src/mapView.js index 1bc55289..14b11538 100644 --- a/src/mapView.js +++ b/src/mapView.js @@ -446,9 +446,7 @@ export class MapView extends Gtk.Overlay { Application.settings.set('map-type', mapType); } else { let source = new GnomeMaps.FileDataSource({ - path: Utils.getBufferText(Application.application.local_tile_path), - renderer: renderer, - tile_size: Application.application.local_tile_size || 512 + path: Utils.getBufferText(Application.application.local_tile_path) }); try { source.prepare(); @@ -456,8 +454,8 @@ export class MapView extends Gtk.Overlay { mapSource = new Shumate.RasterRenderer({ id: 'local', name: 'local', - min_zoom_level: source.min_zoom_level, - max_zoom_level: source.max_zoom_level, + min_zoom_level: source.min_zoom, + max_zoom_level: source.max_zoom, tile_size: Application.application.local_tile_size ?? 512, projection: Shumate.MapProjection.MERCATOR, data_source: source }); @@ -465,6 +463,7 @@ export class MapView extends Gtk.Overlay { this.setMapType(MapView.MapType.STREET); Application.application.local_tile_path = false; Utils.showDialog(e.message, Gtk.MessageType.ERROR, this._mainWindow); + return; } } -- GitLab From 188170c881107475b3e7bfc0f3400686ec4065e1 Mon Sep 17 00:00:00 2001 From: Marcus Lundblad Date: Tue, 13 Sep 2022 23:15:16 +0200 Subject: [PATCH 3/3] application: Fix setting startup flag with --local Use the correct static reference to Application when setting the normal startup flag when using local tiles. --- src/application.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/application.js b/src/application.js index 5e217201..41fb76b3 100644 --- a/src/application.js +++ b/src/application.js @@ -305,7 +305,7 @@ export class Application extends Adw.Application { if (options.contains('local')) { let variant = options.lookup_value('local', null); this.local_tile_path = variant.deep_unpack(); - normalStartup = false; + Application.normalStartup = false; if (options.contains('local-tile-size')) { variant = options.lookup_value('local-tile-size', null); this.local_tile_size = variant.deep_unpack(); -- GitLab