[glom] Fix some warnings about invalid field types with choices.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glom] Fix some warnings about invalid field types with choices.
- Date: Fri, 4 Nov 2011 09:36:28 +0000 (UTC)
commit 9a9f148e1203e52d0e48315c96de335e21efa0a3
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Nov 4 10:36:11 2011 +0100
Fix some warnings about invalid field types with choices.
* glom/mode_data/datawidget/combochoiceswithtreemodel.cc:
set_choices_related(): Set full field details on the
layout_choice_extra fields, to avoid invalid field types,
and stderr warnings about them.
ChangeLog | 9 +++++++++
.../datawidget/combochoiceswithtreemodel.cc | 18 +++++++++++++++---
glom/mode_data/datawidget/treemodel_db.cc | 3 +++
3 files changed, 27 insertions(+), 3 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 9461d4f..b2543cb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+2011-11-04 Murray Cumming <murrayc murrayc com>
+
+ Fix some warnings about invalid field types with choices.
+
+ * glom/mode_data/datawidget/combochoiceswithtreemodel.cc:
+ set_choices_related(): Set full field details on the
+ layout_choice_extra fields, to avoid invalid field types,
+ and stderr warnings about them.
+
2011-11-03 Murray Cumming <murrayc murrayc com>
Updated examples screenshots.
diff --git a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
index 09d0766..61248c3 100644
--- a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
+++ b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
@@ -236,17 +236,29 @@ void ComboChoicesWithTreeModel::set_choices_fixed(const FieldFormatting::type_li
void ComboChoicesWithTreeModel::set_choices_related(const Document* document, const sharedptr<const LayoutItem_Field>& layout_field, const Gnome::Gda::Value& foreign_key_value)
{
+ if(!document)
+ {
+ std::cerr << G_STRFUNC << ": document is null." << std::endl;
+ return;
+ }
+
const FieldFormatting& format = layout_field->get_formatting_used();
sharedptr<const Relationship> choice_relationship;
sharedptr<const LayoutItem_Field> layout_choice_first;
sharedptr<const LayoutGroup> layout_choice_extra;
bool choice_show_all = false;
format.get_choices_related(choice_relationship, layout_choice_first, layout_choice_extra, choice_show_all);
+ if(layout_choice_first->get_glom_type() == Field::TYPE_INVALID)
+ std::cerr << G_STRFUNC << ": layout_choice_first has invalid type. field name: " << layout_choice_first->get_name() << std::endl;
+
+ //Set full field details, cloning the group to avoid the constness:
+ sharedptr<LayoutGroup> layout_choice_extra_full = glom_sharedptr_clone(layout_choice_extra);
+ document->fill_layout_field_details(choice_relationship->get_to_table(), layout_choice_extra_full);
//Get the list of fields to show:
- LayoutGroup::type_list_const_items extra_fields;
- if(layout_choice_extra)
- extra_fields = layout_choice_extra->get_items_recursive();
+ LayoutGroup::type_list_items extra_fields;
+ if(layout_choice_extra_full)
+ extra_fields = layout_choice_extra_full->get_items_recursive();
LayoutGroup::type_list_const_items layout_items;
layout_items.push_back(layout_choice_first);
diff --git a/glom/mode_data/datawidget/treemodel_db.cc b/glom/mode_data/datawidget/treemodel_db.cc
index 4369391..0696335 100644
--- a/glom/mode_data/datawidget/treemodel_db.cc
+++ b/glom/mode_data/datawidget/treemodel_db.cc
@@ -208,6 +208,9 @@ DbTreeModel::DbTreeModel(const FoundSet& found_set, const type_vec_const_layout_
sharedptr<const LayoutItem_Field> item_field = sharedptr<const LayoutItem_Field>::cast_dynamic(*iter);
if(item_field)
{
+ if(item_field->get_glom_type() == Field::TYPE_INVALID)
+ std::cerr << G_STRFUNC << ": field has invalid type. field name: " << item_field->get_name() << std::endl;
+
m_column_fields.push_back(item_field);
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]