mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-11-10 03:16:17 +01:00
GApplication: Use a WARNING if dbus_unregister is called by destructor
Unlike g_application_register, there is no public API to unregister the
GApplication from D-Bus. Therefore, if the GApplication is set up
manually without using g_application_run, then neither can the
GApplicationImpl be destroyed nor can dbus_unregister be called before
destruction.
This is fine as long as no sub-class has implemented dbus_unregister.
If they have, their method method will be called after destruction, and
they should be prepared to deal with the consequences.
As long as there is no public API for unregistering, let's demote the
assertion to a WARNING. Bravehearts who don't use g_application_run
can continue to implement dbus_unregister, but they would have been
adequately notified.
This reverts commit c1ae1170fa
.
https://bugzilla.gnome.org/show_bug.cgi?id=725950
This commit is contained in:
parent
df06dc6550
commit
b51a0e7c63
@ -1247,10 +1247,21 @@ g_application_dispose (GObject *object)
|
||||
{
|
||||
GApplication *application = G_APPLICATION (object);
|
||||
|
||||
g_assert_null (application->priv->impl);
|
||||
if (application->priv->impl != NULL &&
|
||||
G_APPLICATION_GET_CLASS (application)->dbus_unregister != g_application_real_dbus_unregister)
|
||||
{
|
||||
static gboolean warned;
|
||||
|
||||
G_OBJECT_CLASS (g_application_parent_class)
|
||||
->dispose (object);
|
||||
if (!warned)
|
||||
{
|
||||
g_warning ("Your application did not unregister from D-Bus before destruction. "
|
||||
"Consider using g_application_run().");
|
||||
}
|
||||
|
||||
warned = TRUE;
|
||||
}
|
||||
|
||||
G_OBJECT_CLASS (g_application_parent_class)->dispose (object);
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1258,8 +1269,6 @@ g_application_finalize (GObject *object)
|
||||
{
|
||||
GApplication *application = G_APPLICATION (object);
|
||||
|
||||
g_assert_null (application->priv->impl);
|
||||
|
||||
g_slist_free_full (application->priv->option_groups, (GDestroyNotify) g_option_group_unref);
|
||||
if (application->priv->main_options)
|
||||
g_option_group_unref (application->priv->main_options);
|
||||
@ -1267,6 +1276,9 @@ g_application_finalize (GObject *object)
|
||||
g_hash_table_unref (application->priv->packed_options);
|
||||
|
||||
g_slist_free_full (application->priv->option_strings, g_free);
|
||||
|
||||
if (application->priv->impl)
|
||||
g_application_impl_destroy (application->priv->impl);
|
||||
g_free (application->priv->id);
|
||||
|
||||
if (g_application_get_default () == application)
|
||||
|
Loading…
Reference in New Issue
Block a user