[gtkmm/gtkmm-2-14] Gtk::Builder: Fix a crash when the widget is not found.



commit 953847b9c6eb5baa98955c1cb2d43366814b628a
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Jul 23 19:17:33 2009 +0200

    Gtk::Builder: Fix a crash when the widget is not found.
    
    * gtk/src/builder.ccg: get_widget_checked(): Prevent a crash if the widget
    was not found by GtkBuilder.
    Bug #589267 (Alexander Shaduri)

 ChangeLog           |    8 ++++++++
 gtk/src/builder.ccg |    6 ++++++
 2 files changed, 14 insertions(+), 0 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index b31d78a..c95d0b0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2009-07-23  Murray Cumming  <murrayc murrayc com>
+
+	Gtk::Builder: Fix a crash when the widget is not found.
+	
+	* gtk/src/builder.ccg: get_widget_checked(): Prevent a crash if the widget 
+	was not found by GtkBuilder.
+	Bug #589267 (Alexander Shaduri)
+
 2.14.4:
 
 2009-06-19  Murray Cumming  <murrayc murrayc com>
diff --git a/gtk/src/builder.ccg b/gtk/src/builder.ccg
index 616aef5..afd258a 100644
--- a/gtk/src/builder.ccg
+++ b/gtk/src/builder.ccg
@@ -311,6 +311,12 @@ Gtk::Widget* Builder::get_widget_checked(const Glib::ustring& name, GType type)
 {
   // Get the widget from the GtkBuilder file.
   GtkWidget *cobject = get_cwidget(name);
+  if(!cobject)
+  {
+    g_critical("gtkmm: Gtk::Buidler: widget `%s' was not found in the GtkBuilder file, or the specified part of it.", 
+      name.c_str());
+    return 0;
+  }
 
   // Check if it has the correct type.
   if(!g_type_is_a(G_OBJECT_TYPE(cobject), type))



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]