[glom] Dialog_FieldsList: Fix a crash.



commit 03d6b080684b1a12de567eaa49a7c4ad5685d467
Author: Murray Cumming <murrayc murrayc com>
Date:   Tue Sep 7 15:49:16 2010 +0200

    Dialog_FieldsList: Fix a crash.
    
    	* glom/mode_design/layout/layout_item_dialogs/dialog_fieldslist.cc: get_fields():
      Do not overwrite the vector, fixing a crash.
      Looking at this code, I think we also ignore reordering of items, so we
      should fix that later.

 ChangeLog                                          |    9 +++++++++
 .../layout_item_dialogs/dialog_fieldslist.cc       |    9 ++++++---
 2 files changed, 15 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index d21f24b..dc80590 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,14 @@
 2010-09-07  Murray Cumming  <murrayc murrayc com>
 
+	Dialog_FieldsList: Fix a crash.
+
+	* glom/mode_design/layout/layout_item_dialogs/dialog_fieldslist.cc: get_fields():
+  Do not overwrite the vector, fixing a crash.
+  Looking at this code, I think we also ignore reordering of items, so we
+  should fix that later.
+
+2010-09-07  Murray Cumming  <murrayc murrayc com>
+
 	Add a --stop-auto-server-shutdown command-line option for debugging.
 
 	* glom/libglom/connectionpool.[h|cc]: Added set_auto_server_shutdown().
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_fieldslist.cc b/glom/mode_design/layout/layout_item_dialogs/dialog_fieldslist.cc
index 17c4f39..cdc0de1 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_fieldslist.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_fieldslist.cc
@@ -189,10 +189,12 @@ void Dialog_FieldsList::on_button_field_down()
 
 LayoutGroup::type_list_items Dialog_FieldsList::get_fields() const
 {
-  LayoutGroup::type_list_items result;
 
-  guint field_sequence = 1; //0 means no sequence
-  for(Gtk::TreeModel::iterator iterFields = m_model_fields->children().begin(); iterFields != m_model_fields->children().end(); ++iterFields)
+  const Gtk::TreeModel::Children children = m_model_fields->children();
+  LayoutGroup::type_list_items result(children.size());
+
+  guint field_sequence = 0;
+  for(Gtk::TreeModel::iterator iterFields = m_model_fields->children().begin(); iterFields != children.end(); ++iterFields)
   {
     Gtk::TreeModel::Row row = *iterFields;
 
@@ -202,6 +204,7 @@ LayoutGroup::type_list_items Dialog_FieldsList::get_fields() const
     {
       sharedptr<LayoutItem_Field> field_copy = glom_sharedptr_clone(item);
 
+      //TODO: This seems to overwrite the sequence set when the user reorders an item.
       result[field_sequence] = field_copy;
 
       ++field_sequence;



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