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



commit 87645a0cc97e8bc145c6777a4751f8aa23f71903
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 3ade2a5..9cccb22 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.17.2:
 
 2009-07-13  Murray Cumming  <murrayc murrayc com>
diff --git a/gtk/src/builder.ccg b/gtk/src/builder.ccg
index 19d6174..0e4f2c4 100644
--- a/gtk/src/builder.ccg
+++ b/gtk/src/builder.ccg
@@ -278,6 +278,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]