From 9e926f9a28e5a99abe27a06f8c33eb428ab555e2 Mon Sep 17 00:00:00 2001 From: Benjamin Otte Date: Tue, 27 Mar 2018 02:40:26 +0200 Subject: [PATCH] examples: Check for error when loading file People playing with those examples tend to mess up things, so it's really really unhelpful if we don't do error checking. --- examples/builder.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/builder.c b/examples/builder.c index a05646fdbe..3525a03a16 100644 --- a/examples/builder.c +++ b/examples/builder.c @@ -14,12 +14,18 @@ main (int argc, GtkBuilder *builder; GObject *window; GObject *button; + GError *error = NULL; gtk_init (&argc, &argv); /* Construct a GtkBuilder instance and load our UI description */ builder = gtk_builder_new (); - gtk_builder_add_from_file (builder, "builder.ui", NULL); + if (gtk_builder_add_from_file (builder, "builder.ui", &error) == 0) + { + g_printerr ("Error loading file: %s\n", error->message); + g_clear_error (&error); + return 1; + } /* Connect signal handlers to the constructed widgets. */ window = gtk_builder_get_object (builder, "window");