-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
20 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,8 +3,13 @@ | |
* SPDX-FileCopyrightText: 2020-2022 Louis Brauer <[email protected]> | ||
*/ | ||
|
||
// StationStore can store and retrieve a collection of stations | ||
// in a JSON file | ||
/** | ||
StationStore | ||
Store and retrieve a collection of stations in a JSON file | ||
Uses libgee for data structures. | ||
*/ | ||
|
||
using Gee; | ||
|
||
|
@@ -63,9 +68,18 @@ public class StationStore : Object { | |
warning (@"store: unable to load data, does it exist? $(e.message)"); | ||
} | ||
|
||
Json.Node node = parser.get_root (); | ||
Json.Array array = node.get_array (); | ||
array.foreach_element ((a, i, elem) => { | ||
Json.Node? node = parser.get_root (); | ||
|
||
if ( node == null ) | ||
{ | ||
debug ("store: unable to load data, root is null"); | ||
return; // FIXME What should be done when root node is null? | ||
} | ||
|
||
debug ("store: root is not null"); | ||
|
||
Json.Array array = node.get_array (); // Json-CRITICAL **: 21:02:51.821: json_node_get_array: assertion 'JSON_NODE_IS_VALID (node)' failed | ||
array.foreach_element ((a, i, elem) => { // json_array_foreach_element: assertion 'array != NULL' failed | ||
Station station = Json.gobject_deserialize (typeof (Station), elem) as Station; | ||
// TODO This should probably not be here but in | ||
// DirectoryController | ||
|
@@ -130,4 +144,4 @@ public class StationStore : Object { | |
} | ||
} | ||
|
||
} | ||
} |