mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-12 23:05:31 +00:00
application: Shut down graceful on SIGTERM/SIGINT
This will allow cleaning up after ourselves, e.g. closing the record DB. Fixes: #508
This commit is contained in:
parent
e1f0b83d25
commit
19f8ac390b
2 changed files with 22 additions and 1 deletions
|
@ -45,6 +45,7 @@
|
||||||
|
|
||||||
#include <call-ui.h>
|
#include <call-ui.h>
|
||||||
#include <glib/gi18n.h>
|
#include <glib/gi18n.h>
|
||||||
|
#include <glib-unix.h>
|
||||||
#include <handy.h>
|
#include <handy.h>
|
||||||
#include <libcallaudio.h>
|
#include <libcallaudio.h>
|
||||||
|
|
||||||
|
@ -69,6 +70,8 @@ struct _CallsApplication {
|
||||||
CallsDBusManager *dbus_manager;
|
CallsDBusManager *dbus_manager;
|
||||||
|
|
||||||
char *uri;
|
char *uri;
|
||||||
|
guint id_sigterm;
|
||||||
|
guint id_sigint;
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (CallsApplication, calls_application, GTK_TYPE_APPLICATION);
|
G_DEFINE_TYPE (CallsApplication, calls_application, GTK_TYPE_APPLICATION);
|
||||||
|
@ -76,6 +79,15 @@ G_DEFINE_TYPE (CallsApplication, calls_application, GTK_TYPE_APPLICATION);
|
||||||
|
|
||||||
static void start_proper (CallsApplication *self);
|
static void start_proper (CallsApplication *self);
|
||||||
|
|
||||||
|
static gboolean
|
||||||
|
on_int_or_term_signal (CallsApplication *self)
|
||||||
|
{
|
||||||
|
g_debug ("Received SIGTERM/SIGINT, shutting down gracefully");
|
||||||
|
|
||||||
|
g_application_quit (G_APPLICATION (self));
|
||||||
|
|
||||||
|
return G_SOURCE_REMOVE;
|
||||||
|
}
|
||||||
|
|
||||||
static gboolean
|
static gboolean
|
||||||
cmd_verbose_cb (const char *option_name,
|
cmd_verbose_cb (const char *option_name,
|
||||||
|
@ -659,6 +671,9 @@ finalize (GObject *object)
|
||||||
{
|
{
|
||||||
CallsApplication *self = (CallsApplication *) object;
|
CallsApplication *self = (CallsApplication *) object;
|
||||||
|
|
||||||
|
g_clear_handle_id (&self->id_sigterm, g_source_remove);
|
||||||
|
g_clear_handle_id (&self->id_sigint, g_source_remove);
|
||||||
|
|
||||||
g_clear_object (&self->call_window);
|
g_clear_object (&self->call_window);
|
||||||
g_clear_object (&self->main_window);
|
g_clear_object (&self->main_window);
|
||||||
g_clear_object (&self->record_store);
|
g_clear_object (&self->record_store);
|
||||||
|
@ -731,6 +746,12 @@ calls_application_init (CallsApplication *self)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
self->id_sigterm = g_unix_signal_add (SIGTERM, G_SOURCE_FUNC (on_int_or_term_signal), self);
|
||||||
|
g_source_set_name_by_id (self->id_sigterm, "signal: SIGTERM handler");
|
||||||
|
|
||||||
|
self->id_sigint = g_unix_signal_add (SIGINT, G_SOURCE_FUNC (on_int_or_term_signal), self);
|
||||||
|
g_source_set_name_by_id (self->id_sigint, "signal: SIGINT handler");
|
||||||
|
|
||||||
g_application_add_main_option_entries (G_APPLICATION (self), options);
|
g_application_add_main_option_entries (G_APPLICATION (self), options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -666,7 +666,6 @@ dispose (GObject *object)
|
||||||
g_list_store_remove_all (G_LIST_STORE (self));
|
g_list_store_remove_all (G_LIST_STORE (self));
|
||||||
|
|
||||||
g_clear_object (&self->repository);
|
g_clear_object (&self->repository);
|
||||||
close_adapter (self);
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (calls_record_store_parent_class)->dispose (object);
|
G_OBJECT_CLASS (calls_record_store_parent_class)->dispose (object);
|
||||||
}
|
}
|
||||||
|
@ -678,6 +677,7 @@ finalize (GObject *object)
|
||||||
CallsRecordStore *self = CALLS_RECORD_STORE (object);
|
CallsRecordStore *self = CALLS_RECORD_STORE (object);
|
||||||
|
|
||||||
g_free (self->filename);
|
g_free (self->filename);
|
||||||
|
close_adapter (self);
|
||||||
|
|
||||||
G_OBJECT_CLASS (calls_record_store_parent_class)->finalize (object);
|
G_OBJECT_CLASS (calls_record_store_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue