Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ static void gpredict_sig_handler(int sig);
static gboolean tle_mon_task(gpointer data);
static void tle_mon_stop(void);
static gpointer update_tle_thread(gpointer data);
static gboolean reload_sats_idle_cb(gpointer data);
static void clean_tle(void);
static void clean_trsp(void);

Expand Down Expand Up @@ -557,19 +558,33 @@ static void tle_mon_stop()
/* if TLE update is running wait until it is finished */
while (tle_upd_running)
{
/* iterate the main loop so the reload idle callback can run */
g_main_context_iteration(NULL, FALSE);
g_usleep(1000);
}
}

/* Reload satellites on the main loop after a TLE update. */
static gboolean reload_sats_idle_cb(gpointer data)
{
(void)data;

mod_mgr_reload_sats();
tle_upd_running = FALSE;

return G_SOURCE_REMOVE;
}

/* Thread function which invokes TLE update */
static gpointer update_tle_thread(gpointer data)
{
(void)data;

tle_upd_running = TRUE;
tle_update_from_network(TRUE, NULL, NULL, NULL);
mod_mgr_reload_sats();
tle_upd_running = FALSE;

/* reloading touches GTK, so run it on the main thread, not here */
gdk_threads_add_idle(reload_sats_idle_cb, NULL);

return NULL;
}
Expand Down
Loading