GApplication: Assert that dbus_unregister was called before destruction

Invoking the dbus_unregister virtual method during destruction is
problematic. It would happen after a sub-class has dropped its
references to its instance objects, and it is surprising to be asked to
unexport exported D-Bus objects after that.

This problem was masked as a side-effect of commit 21b1c390a3.
Let's ensure that it doesn't regress by asserting that dbus_unregister
has happened before destruction.

Based on a patch by Giovanni Campagna.

https://bugzilla.gnome.org/show_bug.cgi?id=725950
This commit is contained in:
Debarshi Ray 2017-06-19 16:16:08 +02:00
parent be7c3ae611
commit c1ae1170fa

View File

@ -1242,11 +1242,24 @@ g_application_constructed (GObject *object)
}
}
static void
g_application_dispose (GObject *object)
{
GApplication *application = G_APPLICATION (object);
g_assert_null (application->priv->impl);
G_OBJECT_CLASS (g_application_parent_class)
->dispose (object);
}
static void
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);
@ -1254,9 +1267,6 @@ 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)
@ -1314,6 +1324,7 @@ g_application_class_init (GApplicationClass *class)
GObjectClass *object_class = G_OBJECT_CLASS (class);
object_class->constructed = g_application_constructed;
object_class->dispose = g_application_dispose;
object_class->finalize = g_application_finalize;
object_class->get_property = g_application_get_property;
object_class->set_property = g_application_set_property;