summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEmmanuele Bassi <ebassi@gnome.org>2015-10-01 18:58:32 +0100
committerEmmanuele Bassi <ebassi@gnome.org>2015-10-01 19:24:12 +0100
commit707a071c660438235b45ecb66a5610590594b9cb (patch)
tree48f4f593a406b86b5598cac9f5a5feabf323d792
parent42b02d9d01cc7b3cf4282550e93bef8363408eea (diff)
downloadgtk+-707a071c660438235b45ecb66a5610590594b9cb.tar.gz
app: Warn when trying to add windows on an inert instance
Application windows can only be added after the application has been started. https://bugzilla.gnome.org/show_bug.cgi?id=755954
-rw-r--r--gtk/gtkapplication.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/gtk/gtkapplication.c b/gtk/gtkapplication.c
index ba7ef7b49e..0edfe925e2 100644
--- a/gtk/gtkapplication.c
+++ b/gtk/gtkapplication.c
@@ -1020,6 +1020,10 @@ gtk_application_new (const gchar *application_id,
*
* Adds a window to @application.
*
+ * This call can only happen after the @application has started;
+ * typically, you should add new application windows in response
+ * to the emission of the #GApplication::activate signal.
+ *
* This call is equivalent to setting the #GtkWindow:application
* property of @window to @application.
*
@@ -1027,7 +1031,7 @@ gtk_application_new (const gchar *application_id,
* will remain until the window is destroyed, but you can explicitly
* remove it with gtk_application_remove_window().
*
- * GTK+ will keep the application running as long as it has
+ * GTK+ will keep the @application running as long as it has
* any windows.
*
* Since: 3.0
@@ -1038,6 +1042,13 @@ gtk_application_add_window (GtkApplication *application,
{
g_return_if_fail (GTK_IS_APPLICATION (application));
+ if (!g_application_get_is_registered (G_APPLICATION (application)))
+ {
+ g_critical ("New application windows must be added after the "
+ "GApplication::startup signal has been emitted.");
+ return;
+ }
+
if (!g_list_find (application->priv->windows, window))
g_signal_emit (application,
gtk_application_signals[WINDOW_ADDED], 0, window);