1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2025-01-23 20:15:32 +00:00

application: Shut down cleanly when application quits

Previously the application was only properly shut down
when it received SIGTERM/SIGINT.
This commit is contained in:
Evangelos Ribeiro Tzaras 2023-01-16 09:04:24 +01:00
parent 0c004b5204
commit ac6aff798d

View file

@ -72,6 +72,7 @@ struct _CallsApplication {
char *uri; char *uri;
guint id_sigterm; guint id_sigterm;
guint id_sigint; guint id_sigint;
gboolean shutdown;
}; };
G_DEFINE_TYPE (CallsApplication, calls_application, GTK_TYPE_APPLICATION); G_DEFINE_TYPE (CallsApplication, calls_application, GTK_TYPE_APPLICATION);
@ -83,14 +84,22 @@ static void start_proper (CallsApplication *self);
static void static void
quit_calls (CallsApplication *self) quit_calls (CallsApplication *self)
{ {
g_assert (CALLS_IS_APPLICATION (self));
if (self->shutdown)
return;
gtk_application_remove_window (GTK_APPLICATION (self), GTK_WINDOW (self->main_window)); gtk_application_remove_window (GTK_APPLICATION (self), GTK_WINDOW (self->main_window));
gtk_application_remove_window (GTK_APPLICATION (self), GTK_WINDOW (self->call_window)); gtk_application_remove_window (GTK_APPLICATION (self), GTK_WINDOW (self->call_window));
}
self->shutdown = TRUE;
}
static gboolean static gboolean
on_int_or_term_signal (CallsApplication *self) on_int_or_term_signal (CallsApplication *self)
{ {
g_assert (CALLS_IS_APPLICATION (self));
g_debug ("Received SIGTERM/SIGINT, shutting down gracefully"); g_debug ("Received SIGTERM/SIGINT, shutting down gracefully");
self->id_sigint = 0; self->id_sigint = 0;
@ -553,6 +562,8 @@ calls_application_command_line (GApplication *application,
static void static void
app_shutdown (GApplication *application) app_shutdown (GApplication *application)
{ {
quit_calls (CALLS_APPLICATION (application));
cui_uninit (); cui_uninit ();
G_APPLICATION_CLASS (calls_application_parent_class)->shutdown (application); G_APPLICATION_CLASS (calls_application_parent_class)->shutdown (application);