glom r1537 - in branches/glom-1-6: . glom/utility_widgets/db_adddel



Author: murrayc
Date: Wed Apr  9 13:18:15 2008
New Revision: 1537
URL: http://svn.gnome.org/viewvc/glom?rev=1537&view=rev

Log:
2008-04-09  Murray Cumming  <murrayc murrayc com>

* glom/utility_widgets/db_adddel/db_adddel.cc
get_item_placeholder(), Glom.get_item_selected(),
on_cell_layout_button_clicked(), remove_item(),
on_treeview_cell_edited_bool(), on_treeview_cell_edited(),
on_treeview_button_press_event(), get_last_row(),
get_last_row, set_value_key(), get_is_placeholder_row,()
on_cell_button_clicked(): Check that the treemodel is not null before 
dereferencing it.
This fixes a crash when trying to add a record when there is no 
primary key.
Bug #527007.

Modified:
   branches/glom-1-6/ChangeLog
   branches/glom-1-6/glom/utility_widgets/db_adddel/db_adddel.cc

Modified: branches/glom-1-6/glom/utility_widgets/db_adddel/db_adddel.cc
==============================================================================
--- branches/glom-1-6/glom/utility_widgets/db_adddel/db_adddel.cc	(original)
+++ branches/glom-1-6/glom/utility_widgets/db_adddel/db_adddel.cc	Wed Apr  9 13:18:15 2008
@@ -357,7 +357,10 @@
 Gtk::TreeModel::iterator DbAddDel::get_item_placeholder()
 {
   //Get the existing placeholder row, or add one if necessary:
-  return m_refListStore->get_placeholder_row();
+  if(m_refListStore)
+    return m_refListStore->get_placeholder_row();
+  else
+   return Gtk::TreeModel::iterator();
 }
 
 Gnome::Gda::Value DbAddDel::get_value(const Gtk::TreeModel::iterator& iter, const sharedptr<const LayoutItem_Field>& layout_item)
@@ -408,7 +411,10 @@
      return refTreeSelection->get_selected();
   }
 
-  return m_refListStore->children().end();
+  if(m_refListStore)
+    return m_refListStore->children().end();
+  else
+    return Gtk::TreeModel::iterator();
 }
 
 
@@ -562,6 +568,9 @@
 
 void DbAddDel::on_cell_layout_button_clicked(const Gtk::TreeModel::Path& path, int model_column_index)
 {
+  if(!m_refListStore)
+    return;
+
   Gtk::TreeModel::iterator iter = m_refListStore->get_iter(path);
   if(iter)
   {
@@ -1276,7 +1285,7 @@
 
 void DbAddDel::remove_item(const Gtk::TreeModel::iterator& iter)
 {
-  if(iter)
+  if(iter && m_refListStore)
     m_refListStore->erase(iter);
 }
 
@@ -1336,6 +1345,9 @@
   if(path_string.empty())
     return;
 
+  if(!m_refListStore)
+    return;
+
   Gtk::TreePath path(path_string);
 
   //Get the row from the path:
@@ -1363,7 +1375,7 @@
     bool bIsAdd = false;
     bool bIsChange = false;
 
-    int iCount = m_refListStore->children().size();
+    const int iCount = m_refListStore->children().size();
     if(iCount)
     {
       if(get_allow_user_actions()) //If add is possible:
@@ -1416,6 +1428,9 @@
   if(path_string.empty())
     return;
 
+  if(!m_refListStore)
+    return;
+
   Gtk::TreePath path(path_string);
 
   //Get the row from the path:
@@ -1616,6 +1631,9 @@
     //Get the row:
     if(row_exists)
     {
+      if(!m_refListStore)
+        return;
+
       Gtk::TreeModel::iterator iterRow = m_refListStore->get_iter(path);
       if(iterRow)
       {
@@ -1815,12 +1833,18 @@
 
 Gtk::TreeModel::iterator DbAddDel::get_last_row() const
 {
-  return m_refListStore->get_last_row();
+  if(m_refListStore)
+    return m_refListStore->get_last_row();
+  else
+    return Gtk::TreeModel::iterator();
 }
 
 Gtk::TreeModel::iterator DbAddDel::get_last_row()
 {
-  return m_refListStore->get_last_row();
+  if(m_refListStore)
+    return m_refListStore->get_last_row();
+  else
+    return Gtk::TreeModel::iterator();
 }
 
 Gnome::Gda::Value DbAddDel::get_value_key(const Gtk::TreeModel::iterator& iter)
@@ -1831,7 +1855,7 @@
 
 void DbAddDel::set_value_key(const Gtk::TreeModel::iterator& iter, const Gnome::Gda::Value& value)
 {
-  if(iter)
+  if(iter && m_refListStore)
   {
     Gtk::TreeModel::Row row = *iter;
 
@@ -1858,6 +1882,9 @@
   if(!iter)
     return false;
 
+  if(!m_refListStore)
+    return false;
+
   if(iter == m_refListStore->children().end())
   {
     return false;
@@ -2009,6 +2036,9 @@
 
 void DbAddDel::on_cell_button_clicked(const Gtk::TreeModel::Path& path)
 {
+  if(!m_refListStore)
+    return;
+
   Gtk::TreeModel::iterator iter = m_refListStore->get_iter(path);
   if(iter)
   {



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