Skip to content

Commit

Permalink
More robust geocluelayer recording.
Browse files Browse the repository at this point in the history
Always (re)create track if necessary, since it could have been removed via an empty operation
  • Loading branch information
rnorris committed Jan 18, 2025
1 parent 221bb79 commit 5411694
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/vikgeocluelayer.c
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,7 @@ static void geoclue_empty_cb ( menu_array_layer values )
_("Are you sure you want to delete geoclue data?"),
NULL ) )
return;
vgl->track = NULL;
vik_trw_layer_delete_all_waypoints ( vgl->trw );
vik_trw_layer_delete_all_tracks ( vgl->trw );
}
Expand Down Expand Up @@ -593,6 +594,16 @@ notify_location ( GClueSimple *simple,
update_all = FALSE;
}

// Create track if necessary
if ( vgl->record && vgl->track == NULL ) {
VikTrwLayer *vtl = vgl->trw;
vgl->track = vik_track_new();
vgl->track->has_color = TRUE;
gchar *name = make_track_name ( vtl );
vik_trw_layer_add_track ( vtl, name, vgl->track );
g_free ( name );
}

vgl->trkpt = vgl->record ? create_trackpoint ( vgl, vgl->coord, location ) : NULL;
vgl->first_trackpoint = FALSE;

Expand Down Expand Up @@ -657,14 +668,6 @@ on_simple_ready ( GObject *source_object,
libgeoclue_print_location ( location );
}

if ( vgl->record ) {
VikTrwLayer *vtl = vgl->trw;
vgl->track = vik_track_new();
gchar *name = make_track_name ( vtl );
vik_trw_layer_add_track ( vtl, name, vgl->track );
g_free ( name );
}

vgl->first_trackpoint = TRUE;

notify_location ( vgl->simple, NULL, vgl );
Expand Down

0 comments on commit 5411694

Please sign in to comment.