[glom/glom-1-14] Fix a possible crash when showing choices.



commit 48e6747f4f80eaaac7db116cf45efeb0eaca841c
Author: Murray Cumming <murrayc murrayc com>
Date:   Sat May 1 19:34:00 2010 +0200

    Fix a possible crash when showing choices.
    
    	* glom/mode_data/datawidget/combo.cc: set_text(): Don't show a warning if
    	"" is not found because it's OK to use that to clear the combo.
    	* glom/mode_data/datawidget/combochoiceswithtreemodel.cc:
    	set_choices_with_second(): Don't dereference a null smartpointer, avoiding
    	a crash with one .glom file that I tried.

 ChangeLog                                          |   10 ++++++++++
 glom/mode_data/datawidget/combo.cc                 |    8 ++++++--
 .../datawidget/combochoiceswithtreemodel.cc        |    2 +-
 3 files changed, 17 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 15d2e8b..638deaa 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,15 @@
 2010-05-01  Murray Cumming  <murrayc murrayc com>
 
+	Fix a possible crash when showing choices.
+
+	* glom/mode_data/datawidget/combo.cc: set_text(): Don't show a warning if 
+	"" is not found because it's OK to use that to clear the combo.
+	* glom/mode_data/datawidget/combochoiceswithtreemodel.cc: 
+	set_choices_with_second(): Don't dereference a null smartpointer, avoiding 
+	a crash with one .glom file that I tried.
+
+2010-05-01  Murray Cumming  <murrayc murrayc com>
+
 	Python Glom API documentation improvement.
 	
 	* glom/python_embed/python_module/py_glom_module.cc: Turn off auto-writing 
diff --git a/glom/mode_data/datawidget/combo.cc b/glom/mode_data/datawidget/combo.cc
index 3d1ab94..49ec46e 100644
--- a/glom/mode_data/datawidget/combo.cc
+++ b/glom/mode_data/datawidget/combo.cc
@@ -199,8 +199,12 @@ void ComboGlom::set_text(const Glib::ustring& text)
     }
   }
 
-  g_warning("ComboGlom::set_text(): no item found for: %s", text.c_str());
-
+  //It's OK to pass "" to this method to unset any items:
+  if(!text.empty())
+  {
+    g_warning("ComboGlom::set_text(): no item found for: %s", text.c_str());
+  }
+  
   //Not found, so mark it as blank:
   #ifndef GLOM_ENABLE_MAEMO
   unset_active();
diff --git a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
index 7a81cc4..09cba5f 100644
--- a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
+++ b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
@@ -69,7 +69,7 @@ void ComboChoicesWithTreeModel::set_choices_with_second(const type_list_values_w
     {
       row[m_Columns.m_col_first] = Conversions::get_text_for_gda_value(layout_item->get_glom_type(), iter->first, layout_item->get_formatting_used().m_numeric_format);
 
-      if(m_with_second)
+      if(m_with_second && m_layoutitem_second)
       {
         row[m_Columns.m_col_second] = Conversions::get_text_for_gda_value(m_layoutitem_second->get_glom_type(), iter->second, m_layoutitem_second->get_formatting_used().m_numeric_format);
       }



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