GApplication: add chain-up checks

Make sure ::startup and ::shutdown are being chained up.
This commit is contained in:
Ryan Lortie 2011-09-14 14:00:08 -04:00
parent 15b1c1bf4f
commit 01f9479438

View File

@ -157,6 +157,8 @@ struct _GApplicationPrivate
guint is_registered : 1;
guint is_remote : 1;
guint did_startup : 1;
guint did_shutdown : 1;
GHashTable *remote_actions; /* string -> RemoteActionInfo */
GApplicationImpl *impl;
@ -207,11 +209,13 @@ g_application_real_after_emit (GApplication *application,
static void
g_application_real_startup (GApplication *application)
{
application->priv->did_startup = TRUE;
}
static void
g_application_real_shutdown (GApplication *application)
{
application->priv->did_shutdown = TRUE;
}
static void
@ -1041,7 +1045,14 @@ g_application_register (GApplication *application,
g_object_notify (G_OBJECT (application), "is-registered");
if (!application->priv->is_remote)
{
g_signal_emit (application, g_application_signals[SIGNAL_STARTUP], 0);
if (!application->priv->did_startup)
g_critical ("GApplication subclass '%s' failed to chain up on"
" ::startup (from start of override function)",
G_OBJECT_TYPE_NAME (application));
}
}
return TRUE;
@ -1343,9 +1354,16 @@ g_application_run (GApplication *application,
status = 0;
}
if (application->priv->is_registered)
if (!application->priv->is_remote)
{
g_signal_emit (application, g_application_signals[SIGNAL_SHUTDOWN], 0);
if (!application->priv->did_shutdown)
g_critical ("GApplication subclass '%s' failed to chain up on"
" ::shutdown (from end of override function)",
G_OBJECT_TYPE_NAME (application));
}
if (application->priv->impl)
g_application_impl_flush (application->priv->impl);