1
0
mirror of https://gitlab.gnome.org/GNOME/evince synced 2024-06-30 22:54:23 +00:00

Wait until all jobs finish before exit

Wait for all jobs before exiting main().
This allows clean execution of exit handlers.
Otherwise, the threads which executes the jobs could
access data already cleaned by exit handlers.

Fixes #1713
This commit is contained in:
Marek Kasik 2022-05-23 14:55:09 +02:00 committed by Marek Kašík
parent 5d9c3d620c
commit 88c8010564
4 changed files with 22 additions and 0 deletions

View File

@ -317,3 +317,20 @@ ev_job_scheduler_get_running_thread_job (void)
{
return g_atomic_pointer_get (&running_job);
}
/**
* ev_job_scheduler_wait:
*
* Synchronously waits until all jobs are done.
* Remember that main loop is not running already probably.
*/
void
ev_job_scheduler_wait (void)
{
ev_debug_message (DEBUG_JOBS, "Waiting for empty job list");
while (job_list != NULL)
g_usleep (100);
ev_debug_message (DEBUG_JOBS, "Job list is empty");
}

View File

@ -48,4 +48,7 @@ void ev_job_scheduler_update_job (EvJob *job,
EV_PUBLIC
EvJob *ev_job_scheduler_get_running_thread_job (void);
EV_PUBLIC
void ev_job_scheduler_wait (void);
G_END_DECLS

View File

@ -331,6 +331,7 @@ main (gint argc, gchar **argv)
if (print_settings_file)
ev_previewer_unlink_tempfile (print_settings_file);
ev_job_scheduler_wait ();
ev_shutdown ();
ev_stock_icons_shutdown ();

View File

@ -318,6 +318,7 @@ main (int argc, char *argv[])
status = g_application_run (G_APPLICATION (application), 0, NULL);
done:
ev_job_scheduler_wait ();
ev_shutdown ();
ev_stock_icons_shutdown ();