[glom] More not taking a shared_ptr<> when the function doesn't share ownership.



commit 897d0f5719128967ffe7cc51fae37ebedb1eb9c4
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Jul 29 17:49:04 2016 +0200

    More not taking a shared_ptr<> when the function doesn't share ownership.
    
    As suggested by:
    
    Bjarne Stroustrup: 2015: Writing Good C++14:
    video: https://www.youtube.com/watch?v=1OEu9C51K2A
    slide: 
https://github.com/isocpp/CppCoreGuidelines/blob/master/talks/Stroustrup%20-%20CppCon%202015%20keynote.pdf
    
    C++ Core Guidelines:
    "F.7: For general use, take T* or T& arguments rather than smart pointers":
    
https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#f7-for-general-use-take-t-or-t-arguments-rather-than-smart-pointers

 glom/base_db.cc                                    |   53 ++++++-------
 glom/base_db.h                                     |    6 +-
 glom/base_db_table_data.cc                         |   14 ++--
 glom/base_db_table_data.h                          |    2 +-
 glom/import_csv/dialog_import_csv_progress.cc      |    8 +-
 glom/import_csv/dialog_import_csv_progress.h       |    4 +-
 .../data_structure/layout/layoutitem_field.cc      |    8 +-
 .../data_structure/layout/layoutitem_field.h       |    2 +-
 glom/libglom/db_utils.cc                           |    6 +-
 glom/libglom/db_utils.h                            |    4 +-
 glom/libglom/layout_utils.cc                       |    4 +-
 glom/libglom/layout_utils.h                        |   12 ++--
 glom/mode_data/box_data.cc                         |    2 +-
 glom/mode_data/box_data_details.cc                 |   22 +++---
 glom/mode_data/box_data_details.h                  |    6 +-
 glom/mode_data/box_data_list.cc                    |    6 +-
 glom/mode_data/box_data_list.h                     |    6 +-
 glom/mode_data/box_data_list_related.cc            |    4 +-
 glom/mode_data/datawidget/cellcreation.cc          |    5 +-
 glom/mode_data/datawidget/cellrenderer_dblist.cc   |    2 +-
 glom/mode_data/datawidget/cellrenderer_dblist.h    |    2 +-
 glom/mode_data/datawidget/combo.cc                 |    2 +-
 glom/mode_data/datawidget/combo.h                  |    2 +-
 .../mode_data/datawidget/combo_as_radio_buttons.cc |    2 +-
 glom/mode_data/datawidget/combo_as_radio_buttons.h |    2 +-
 glom/mode_data/datawidget/combochoices.cc          |    2 +-
 glom/mode_data/datawidget/combochoices.h           |    2 +-
 .../datawidget/combochoiceswithtreemodel.cc        |    4 +-
 .../datawidget/combochoiceswithtreemodel.h         |    2 +-
 glom/mode_data/datawidget/datawidget.cc            |    2 +-
 glom/mode_data/db_adddel/db_adddel.cc              |   78 ++++++++-----------
 glom/mode_data/db_adddel/db_adddel.h               |   25 +++---
 glom/mode_data/flowtablewithfields.cc              |   34 ++++-----
 glom/mode_data/flowtablewithfields.h               |   20 +++---
 glom/mode_design/layout/dialog_choose_field.cc     |    2 +-
 tests/test_layout_item_field.cc                    |   70 +++++++++---------
 tests/test_selfhosting_new_then_choices.cc         |    2 +-
 37 files changed, 208 insertions(+), 221 deletions(-)
---
diff --git a/glom/base_db.cc b/glom/base_db.cc
index b708d78..b57afe3 100644
--- a/glom/base_db.cc
+++ b/glom/base_db.cc
@@ -58,26 +58,19 @@ namespace Glom
  */
 template
 <typename T_Container>
-auto find_if_layout_item_is_equal(T_Container& container, const typename T_Container::value_type& 
layout_item) -> decltype(container.begin())
+auto find_if_layout_item_is_equal(T_Container& container, const typename 
T_Container::value_type::element_type& layout_item) -> decltype(container.begin())
 {
+  // TODO: Try to capture layout_item in the lambda as const &.
   return Utils::find_if(container,
     [&layout_item](const typename T_Container::value_type& element)
     {
       //Assume that element is a shared_ptr<>.
 
-      if(!layout_item && !element)
-        return true;
+      if(!element)
+        return false; //layout_item cannot (should not) be null because it is a reference.
 
-      if(element && layout_item)
-      {
-        return layout_item->is_same_field(element);
-        //std::cout << "          debug: name1=" << layout_item->get_name() << ", name2=" << 
element->get_name() << ", result=" << result << std::endl;
-        //return result;
-      }
-      else
-        return false;
-    }
-  );
+        return layout_item.is_same_field(*element);
+    });
 }
 
 Base_DB::Base_DB()
@@ -678,7 +671,7 @@ void Base_DB::calculate_field(const LayoutFieldInRecord& field_in_record)
           layout_item->set_full_field_details(field);
 
           //show it:
-          set_entered_field_data(layout_item, calc_progress_refreshed.m_value ); //TODO: If this record is 
shown.
+          set_entered_field_data(*layout_item, calc_progress_refreshed.m_value ); //TODO: If this record is 
shown.
 
           //Add it to the database (even if it is not shown in the view)
           //Using true for the last parameter means we use existing calculations where possible,
@@ -703,13 +696,13 @@ Base_DB::type_map_fields Base_DB::get_record_field_values_for_calculation(const
   return DbUtils::get_record_field_values(document, table_name, primary_key, primary_key_value);
 }
 
-void Base_DB::set_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& /* field */, const 
Gnome::Gda::Value& /* value */)
+void Base_DB::set_entered_field_data(const LayoutItem_Field& /* field */, const Gnome::Gda::Value& /* value 
*/)
 {
   //Override this.
 }
 
 
-void Base_DB::set_entered_field_data(const Gtk::TreeModel::iterator& /* row */, const std::shared_ptr<const 
LayoutItem_Field>& /* field */, const Gnome::Gda::Value& /* value */)
+void Base_DB::set_entered_field_data(const Gtk::TreeModel::iterator& /* row */, const LayoutItem_Field& /* 
field */, const Gnome::Gda::Value& /* value */)
 {
   //Override this.
 }
@@ -897,25 +890,29 @@ void Base_DB::do_calculations(const LayoutFieldInRecord& field_changed, bool fir
 
   //Recalculate fields that are triggered by a change of this field's value, not including calculations that 
these calculations use.
 
-  for(const auto& field : get_calculated_fields(field_changed.m_table_name, field_changed.m_field))
+  const auto field_info_changed = field_changed.m_field;
+  if(field_info_changed)
   {
-    if(field)
-    {
-      //std::cout << "debug: recalcing field: " << field->get_name() << std::endl;
-      //TODO: What if the field is in another table?
-      LayoutFieldInRecord triggered_field(field, field_changed.m_table_name, field_changed.m_key, 
field_changed.m_key_value);
-      calculate_field(triggered_field); //And any dependencies.
+      for(const auto& field : get_calculated_fields(field_changed.m_table_name, *field_info_changed))
+      {
+        if(field)
+        {
+          //std::cout << "debug: recalcing field: " << field->get_name() << std::endl;
+          //TODO: What if the field is in another table?
+          LayoutFieldInRecord triggered_field(field, field_changed.m_table_name, field_changed.m_key, 
field_changed.m_key_value);
+          calculate_field(triggered_field); //And any dependencies.
 
-      //Calculate anything that depends on this.
-      do_calculations(triggered_field, false /* recurse, reusing m_FieldsCalculationInProgress */);
-    }
+          //Calculate anything that depends on this.
+          do_calculations(triggered_field, false /* recurse, reusing m_FieldsCalculationInProgress */);
+        }
+      }
   }
 
   if(first_calc_field)
     clear_fields_calculation_in_progress();
 }
 
-Base_DB::type_list_const_field_items Base_DB::get_calculated_fields(const Glib::ustring& table_name, const 
std::shared_ptr<const LayoutItem_Field>& field)
+Base_DB::type_list_const_field_items Base_DB::get_calculated_fields(const Glib::ustring& table_name, const 
LayoutItem_Field& field)
 {
   //std::cout << "debug: Base_DB::get_calculated_fields field=" << field->get_name() << std::endl;
 
@@ -1059,7 +1056,7 @@ void Base_DB::do_lookups(const LayoutFieldInRecord& field_in_record, const Gtk::
         LayoutFieldInRecord field_in_record_to_set(layout_item, field_in_record.m_table_name /* parent table 
*/, field_in_record.m_key, field_in_record.m_key_value);
 
         //Add it to the view:
-        set_entered_field_data(row, layout_item, value_converted);
+        set_entered_field_data(row, *layout_item, value_converted);
         //m_AddDel.set_value(row, layout_item, value_converted);
 
         //Add it to the database (even if it is not shown in the view)
diff --git a/glom/base_db.h b/glom/base_db.h
index 9249ff8..7f4b565 100644
--- a/glom/base_db.h
+++ b/glom/base_db.h
@@ -122,8 +122,8 @@ protected:
   std::shared_ptr<Field> get_field_primary_key_for_table(const Glib::ustring& table_name) const;
 
   //Methods to be overridden by derived classes:
-  virtual void set_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& field, const 
Gnome::Gda::Value&  value);
-  virtual void set_entered_field_data(const Gtk::TreeModel::iterator& row, const std::shared_ptr<const 
LayoutItem_Field>& field, const Gnome::Gda::Value& value);
+  virtual void set_entered_field_data(const LayoutItem_Field& field, const Gnome::Gda::Value&  value);
+  virtual void set_entered_field_data(const Gtk::TreeModel::iterator& row, const LayoutItem_Field& field, 
const Gnome::Gda::Value& value);
 
 
   class FieldInRecord
@@ -229,7 +229,7 @@ protected:
 
   /** Get the fields whose values should be recalculated when @a field_name changes.
    */
-  type_list_const_field_items get_calculated_fields(const Glib::ustring& table_name, const 
std::shared_ptr<const LayoutItem_Field>& field);
+  type_list_const_field_items get_calculated_fields(const Glib::ustring& table_name, const LayoutItem_Field& 
field);
 
   /** Get the fields used, if any, in the calculation of this field.
    */
diff --git a/glom/base_db_table_data.cc b/glom/base_db_table_data.cc
index 80092fb..b66e5e1 100644
--- a/glom/base_db_table_data.cc
+++ b/glom/base_db_table_data.cc
@@ -38,7 +38,7 @@ Base_DB_Table_Data::Base_DB_Table_Data()
 {
 }
 
-Gnome::Gda::Value Base_DB_Table_Data::get_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& 
/* field */) const
+Gnome::Gda::Value Base_DB_Table_Data::get_entered_field_data(const LayoutItem_Field& /* field */) const
 {
   //Override this to use Field::set_data() too.
 
@@ -114,7 +114,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
         else
         {
           if(use_entered_data)
-            value = get_entered_field_data(layout_item);
+            value = get_entered_field_data(*layout_item);
         }
 
         if(Conversions::value_is_empty(value)) //This deals with empty strings too.
@@ -196,7 +196,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
       for(const auto& layout_item : fieldsToAdd)
       {
         //TODO_Performance: We just set this with set_entered_field_data() above. Maybe we could just 
remember it.
-        const auto field_value = get_entered_field_data(layout_item);
+        const auto field_value = get_entered_field_data(*layout_item);
 
         const LayoutFieldInRecord field_in_record(layout_item, m_table_name, fieldPrimaryKey, 
primary_key_value);
 
@@ -247,7 +247,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const std::shared_ptr<cons
     dialog.run();
 
     //Clear the field again, discarding the entered data.
-    set_entered_field_data(layout_item_parent, Gnome::Gda::Value());
+    set_entered_field_data(*layout_item_parent, Gnome::Gda::Value());
 
     return false;
   }
@@ -269,7 +269,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const std::shared_ptr<cons
       dialog.run();
 
       //Clear the field again, discarding the entered data.
-      set_entered_field_data(layout_item_parent, Gnome::Gda::Value());
+      set_entered_field_data(*layout_item_parent, Gnome::Gda::Value());
 
       return false;
     }
@@ -301,7 +301,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const std::shared_ptr<cons
         item_from_key->set_name(relationship->get_from_field());
 
         //Show the new from key in the parent table's layout:
-        set_entered_field_data(item_from_key, primary_key_value);
+        set_entered_field_data(*item_from_key, primary_key_value);
 
         //Set it in the database too:
         auto document = get_document();
@@ -528,7 +528,7 @@ void Base_DB_Table_Data::refresh_related_fields(const LayoutFieldInRecord& field
             //std::cout << "debug: " << G_STRFUNC << ": value_as_string=" << value.to_string()  << std::endl;
 
             //m_AddDel.set_value(row, layout_item, value);
-            set_entered_field_data(row, layout_item, value);
+            set_entered_field_data(row, *layout_item, value);
             //g_warning("addedel size=%d", m_AddDel.get_count());
           }
 
diff --git a/glom/base_db_table_data.h b/glom/base_db_table_data.h
index 4a8f334..1228627 100644
--- a/glom/base_db_table_data.h
+++ b/glom/base_db_table_data.h
@@ -51,7 +51,7 @@ protected:
    */
   bool record_new(bool use_entered_data = true, const Gnome::Gda::Value& primary_key_value = 
Gnome::Gda::Value());
 
-  virtual Gnome::Gda::Value get_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& field) 
const;
+  virtual Gnome::Gda::Value get_entered_field_data(const LayoutItem_Field& field) const;
 
   //Gets the row being edited, for derived classes that have rows.
   virtual Gtk::TreeModel::iterator get_row_selected();
diff --git a/glom/import_csv/dialog_import_csv_progress.cc b/glom/import_csv/dialog_import_csv_progress.cc
index 84159ab..6d5b3da 100644
--- a/glom/import_csv/dialog_import_csv_progress.cc
+++ b/glom/import_csv/dialog_import_csv_progress.cc
@@ -258,18 +258,18 @@ void Dialog_Import_CSV_Progress::on_response(int /* response_id */)
   clear();
 }
 
-Gnome::Gda::Value Dialog_Import_CSV_Progress::get_entered_field_data(const std::shared_ptr<const 
LayoutItem_Field>& field) const
+Gnome::Gda::Value Dialog_Import_CSV_Progress::get_entered_field_data(const LayoutItem_Field& field) const
 {
-  const auto iter = m_current_row_values.find(field->get_name());
+  const auto iter = m_current_row_values.find(field.get_name());
   if(iter == m_current_row_values.end())
     return Gnome::Gda::Value();
 
   return iter->second;
 }
 
-void Dialog_Import_CSV_Progress::set_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& 
field, const Gnome::Gda::Value&  value)
+void Dialog_Import_CSV_Progress::set_entered_field_data(const LayoutItem_Field& field, const 
Gnome::Gda::Value&  value)
 {
-  m_current_row_values[field->get_name()] = value;
+  m_current_row_values[field.get_name()] = value;
 }
 
 std::shared_ptr<Field> Dialog_Import_CSV_Progress::get_field_primary_key() const
diff --git a/glom/import_csv/dialog_import_csv_progress.h b/glom/import_csv/dialog_import_csv_progress.h
index 214e11f..489593b 100644
--- a/glom/import_csv/dialog_import_csv_progress.h
+++ b/glom/import_csv/dialog_import_csv_progress.h
@@ -57,8 +57,8 @@ private:
 
   void on_response(int response_id) override; // From Gtk::Dialog
 
-  Gnome::Gda::Value get_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& field) const 
override; // from Base_DB_Table_Data
-  void set_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& 
 value) override; // from Base_DB
+  Gnome::Gda::Value get_entered_field_data(const LayoutItem_Field& field) const override; // from 
Base_DB_Table_Data
+  void set_entered_field_data(const LayoutItem_Field& field, const Gnome::Gda::Value&  value) override; // 
from Base_DB
 
   std::shared_ptr<Field> get_field_primary_key() const override; // from Base_DB_Table_Data
   Gnome::Gda::Value get_primary_key_value_selected() const override; // from Base_DB_Table_Data
diff --git a/glom/libglom/data_structure/layout/layoutitem_field.cc 
b/glom/libglom/data_structure/layout/layoutitem_field.cc
index afa94da..a2224d4 100644
--- a/glom/libglom/data_structure/layout/layoutitem_field.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_field.cc
@@ -334,16 +334,16 @@ void LayoutItem_Field::set_title_custom(const std::shared_ptr<CustomTitle>& titl
   m_title_custom = title;
 }
 
-bool LayoutItem_Field::is_same_field(const std::shared_ptr<const LayoutItem_Field>& field) const
+bool LayoutItem_Field::is_same_field(const LayoutItem_Field& field) const
 {
   //Don't use auto here because we really want to call
   //UsesRelationship::operator==(), not LayoutItem_Field::operator==().
   const UsesRelationship* uses_a = this;
-  const UsesRelationship* uses_b = &(*field);
+  const UsesRelationship* uses_b = &field; //TODO: Avoid this.
   if(!uses_a || !uses_b)
     return false; //Shouldn't happen.
-
-  return (get_name() == field->get_name()) &&
+ 
+  return (get_name() == field.get_name()) &&
          (*uses_a == *uses_b);
 }
 
diff --git a/glom/libglom/data_structure/layout/layoutitem_field.h 
b/glom/libglom/data_structure/layout/layoutitem_field.h
index 9feddd9..bcf6d48 100644
--- a/glom/libglom/data_structure/layout/layoutitem_field.h
+++ b/glom/libglom/data_structure/layout/layoutitem_field.h
@@ -140,7 +140,7 @@ public:
 
   /** Compare the name, relationship, and related_relationship.
    */
-  bool is_same_field(const std::shared_ptr<const LayoutItem_Field>& field) const;
+  bool is_same_field(const LayoutItem_Field& field) const;
 
 private:
 
diff --git a/glom/libglom/db_utils.cc b/glom/libglom/db_utils.cc
index b0532c5..b3ac45a 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -2376,13 +2376,13 @@ type_map_fields get_record_field_values(const std::shared_ptr<const Document>& d
 }
 
 
-type_list_values_with_second get_choice_values_all(const std::shared_ptr<const Document>& document, const 
std::shared_ptr<const LayoutItem_Field>& field)
+type_list_values_with_second get_choice_values_all(const std::shared_ptr<const Document>& document, const 
LayoutItem_Field& field)
 {
   return get_choice_values(document, field,
                            Gnome::Gda::Value() /* means get all with no WHERE clause */);
 }
 
-type_list_values_with_second get_choice_values(const std::shared_ptr<const Document>& document, const 
std::shared_ptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& foreign_key_value)
+type_list_values_with_second get_choice_values(const std::shared_ptr<const Document>& document, const 
LayoutItem_Field& field, const Gnome::Gda::Value& foreign_key_value)
 {
   //TODO: Reduce duplication between this and get_choice_values(field).
 
@@ -2397,7 +2397,7 @@ type_list_values_with_second get_choice_values(const std::shared_ptr<const Docum
   }
   */
 
-  const Formatting& format = field->get_formatting_used();
+  const Formatting& format = field.get_formatting_used();
   std::shared_ptr<const Relationship> choice_relationship;
   std::shared_ptr<const LayoutItem_Field> layout_choice_first;
   std::shared_ptr<const LayoutGroup> layout_choice_extra;
diff --git a/glom/libglom/db_utils.h b/glom/libglom/db_utils.h
index 84ccda6..8340686 100644
--- a/glom/libglom/db_utils.h
+++ b/glom/libglom/db_utils.h
@@ -230,9 +230,9 @@ void set_fake_connection();
 
 typedef std::vector<Gnome::Gda::Value> type_list_values;
 typedef std::vector< std::pair<Gnome::Gda::Value, type_list_values> > type_list_values_with_second; //TODO: 
Rename this now that we have more than just 1 extra field.
-type_list_values_with_second get_choice_values_all(const std::shared_ptr<const Document>& document, const 
std::shared_ptr<const LayoutItem_Field>& field);
+type_list_values_with_second get_choice_values_all(const std::shared_ptr<const Document>& document, const 
LayoutItem_Field& field);
 
-type_list_values_with_second get_choice_values(const std::shared_ptr<const Document>& document, const 
std::shared_ptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& foreign_key_value);
+type_list_values_with_second get_choice_values(const std::shared_ptr<const Document>& document, const 
LayoutItem_Field& field, const Gnome::Gda::Value& foreign_key_value);
 
 } //namespace DbUtils
 
diff --git a/glom/libglom/layout_utils.cc b/glom/libglom/layout_utils.cc
index 5c2b514..2f6f3d6 100644
--- a/glom/libglom/layout_utils.cc
+++ b/glom/libglom/layout_utils.cc
@@ -98,7 +98,7 @@ LayoutGroup::type_list_const_items Utils::get_layout_items_plus_primary_key(cons
   pk_layout_item->set_hidden();
   pk_layout_item->set_full_field_details(field_primary_key);
 
-  if(find_if_layout_item_field_is_same_field_exists(items, pk_layout_item))
+  if(find_if_layout_item_field_is_same_field_exists(items, *pk_layout_item))
     return items; //It is already in the list:
 
   LayoutGroup::type_list_const_items items_plus_pk = items;
@@ -126,7 +126,7 @@ LayoutGroup::type_list_items Utils::get_layout_items_plus_primary_key(const Layo
   pk_layout_item->set_hidden();
   pk_layout_item->set_full_field_details(field_primary_key);
 
-  if(find_if_layout_item_field_is_same_field_exists(items, pk_layout_item))
+  if(find_if_layout_item_field_is_same_field_exists(items, *pk_layout_item))
     return items; //It is already in the list:
 
   LayoutGroup::type_list_items items_plus_pk = items;
diff --git a/glom/libglom/layout_utils.h b/glom/libglom/layout_utils.h
index 27bf77e..f7a2f9a 100644
--- a/glom/libglom/layout_utils.h
+++ b/glom/libglom/layout_utils.h
@@ -67,16 +67,16 @@ type_vecConstLayoutFields get_table_fields_to_show_for_sequence(const std::share
  * This assumes that the element is a shared_ptr<>.
  */
 template
-        <typename T_Container>
-bool find_if_layout_item_field_is_same_field_exists(T_Container& container, const std::shared_ptr<const 
LayoutItem_Field>& layout_item)
+<typename T_Container>
+bool find_if_layout_item_field_is_same_field_exists(T_Container& container, const LayoutItem_Field& 
layout_item)
 {
   return Utils::find_if_exists(container,
-                               [&layout_item](const typename T_Container::value_type& element)
+                               [&layout_item](const auto& element)
                                {
                                  //Assume that element is a shared_ptr<>.
 
-                                 if(!layout_item && !element)
-                                   return true;
+                                 if(!element)
+                                   return false; //layout_item cannot (should not) be null because it's a 
reference.
 
                                  //Allow this to be used on a container of LayoutItems,
                                  //as well as just of LayoutItem_Fields.
@@ -84,7 +84,7 @@ bool find_if_layout_item_field_is_same_field_exists(T_Container& container, cons
                                  if(!element_field)
                                    return false;
 
-                                 return layout_item && layout_item->is_same_field(element_field);
+                                 return layout_item.is_same_field(*element_field);
                                }
   );
 }
diff --git a/glom/mode_data/box_data.cc b/glom/mode_data/box_data.cc
index 38366b4..fed70ed 100644
--- a/glom/mode_data/box_data.cc
+++ b/glom/mode_data/box_data.cc
@@ -101,7 +101,7 @@ Gnome::Gda::SqlExpr Box_Data::get_find_where_clause() const
   //Look at each field entry and build e.g. 'Name = "Bob"'
   for(const auto& item : m_FieldsShown)
   {
-    const auto data = get_entered_field_data(item);
+    const auto data = get_entered_field_data(*item);
 
     if(!Conversions::value_is_empty(data))
     {
diff --git a/glom/mode_data/box_data_details.cc b/glom/mode_data/box_data_details.cc
index 3a758db..77bafd6 100644
--- a/glom/mode_data/box_data_details.cc
+++ b/glom/mode_data/box_data_details.cc
@@ -307,7 +307,7 @@ bool Box_Data_Details::fill_from_database()
         bool index_primary_key_found = false;
         unsigned int index_primary_key = 0; //Arbitrary default.
         //g_warning("primary_key name = %s", m_field_primary_key->get_name().c_str());
-        if(!Utils::find_if_layout_item_field_is_same_field_exists(fieldsToGet, layout_item_pk))
+        if(!Utils::find_if_layout_item_field_is_same_field_exists(fieldsToGet, *layout_item_pk))
         {
           fieldsToGet.emplace_back(layout_item_pk);
           index_primary_key = fieldsToGet.size() - 1;
@@ -390,7 +390,7 @@ bool Box_Data_Details::fill_from_database()
                 value = Conversions::get_empty_value(layout_item->get_glom_type());
               }
 
-              m_FlowTable.set_field_value(layout_item, value);
+              m_FlowTable.set_field_value(*layout_item, value);
             }
           }
         }
@@ -494,17 +494,17 @@ void Box_Data_Details::on_button_nav_last()
     signal_nav_last().emit();
 }
 
-Gnome::Gda::Value Box_Data_Details::get_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& 
field) const
+Gnome::Gda::Value Box_Data_Details::get_entered_field_data(const LayoutItem_Field& field) const
 {
   return m_FlowTable.get_field_value(field);
 }
 
-void Box_Data_Details::set_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& field, const 
Gnome::Gda::Value& value)
+void Box_Data_Details::set_entered_field_data(const LayoutItem_Field& field, const Gnome::Gda::Value& value)
 {
   m_FlowTable.set_field_value(field, value);
 }
 
-void Box_Data_Details::set_entered_field_data(const Gtk::TreeModel::iterator& /* row */, const 
std::shared_ptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& value)
+void Box_Data_Details::set_entered_field_data(const Gtk::TreeModel::iterator& /* row */, const 
LayoutItem_Field& field, const Gnome::Gda::Value& value)
 {
   set_entered_field_data(field, value);
 }
@@ -748,7 +748,7 @@ void Box_Data_Details::on_flowtable_field_edited(const std::shared_ptr<const Lay
           auto layout_item = std::make_shared<LayoutItem_Field>();
           layout_item->set_full_field_details( document->get_field(relationship->get_from_table(), 
relationship->get_from_field()) );
 
-          primary_key_value = get_entered_field_data(layout_item);
+          primary_key_value = get_entered_field_data(*layout_item);
 
           //Note: This just uses an existing record if one already exists:
           Gnome::Gda::Value primary_key_value_used;
@@ -776,14 +776,14 @@ void Box_Data_Details::on_flowtable_field_edited(const std::shared_ptr<const Lay
     {
       //Revert to the value in the database:
       const auto value_old = get_field_value_in_database(field_in_record, window);
-      set_entered_field_data(layout_field, value_old);
+      set_entered_field_data(*layout_field, value_old);
 
       return;
     }
 
     //Set the value in all instances of this field in the layout (The field might be on the layout more than 
once):
     //We don't need to set the value in the layout_field itself, as this is where the value comes from.
-    m_FlowTable.set_other_field_value(layout_field, field_value);
+    m_FlowTable.set_other_field_value(*layout_field, field_value);
 
     //Update the field in the record (the record with this primary key):
 
@@ -808,7 +808,7 @@ void Box_Data_Details::on_flowtable_field_edited(const std::shared_ptr<const Lay
         //Update failed.
         //Replace with correct values.
         const auto value_old = get_field_value_in_database(field_in_record, window);
-        set_entered_field_data(layout_field, value_old);
+        set_entered_field_data(*layout_field, value_old);
       }
       else
       {
@@ -874,7 +874,7 @@ void Box_Data_Details::on_flowtable_field_edited(const std::shared_ptr<const Lay
         {
           //Revert to a blank value:
           const auto value_old = 
Conversions::get_empty_value(layout_field->get_full_field_details()->get_glom_type());
-          set_entered_field_data(layout_field, value_old);
+          set_entered_field_data(*layout_field, value_old);
         }
         else
         {
@@ -901,7 +901,7 @@ void Box_Data_Details::on_flowtable_field_choices_changed(const std::shared_ptr<
   if(m_ignore_signals)
     return;
 
-  m_FlowTable.update_choices(layout_field);
+  m_FlowTable.update_choices(*layout_field);
 }
 
 void Box_Data_Details::on_userlevel_changed(AppState::userlevels user_level)
diff --git a/glom/mode_data/box_data_details.h b/glom/mode_data/box_data_details.h
index 7d9f1d7..e10f75d 100644
--- a/glom/mode_data/box_data_details.h
+++ b/glom/mode_data/box_data_details.h
@@ -82,9 +82,9 @@ protected:
   void set_primary_key_value(const Gtk::TreeModel::iterator& row, const Gnome::Gda::Value& value) override;
   Gnome::Gda::Value get_primary_key_value(const Gtk::TreeModel::iterator& row) const override; //Actual 
primary key value of this record.
 
-  Gnome::Gda::Value get_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& field) const 
override;
-  void set_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& 
value) override;
-  void set_entered_field_data(const Gtk::TreeModel::iterator& row, const std::shared_ptr<const 
LayoutItem_Field>& field, const Gnome::Gda::Value& value) override;
+  Gnome::Gda::Value get_entered_field_data(const LayoutItem_Field& field) const override;
+  void set_entered_field_data(const LayoutItem_Field& field, const Gnome::Gda::Value& value) override;
+  void set_entered_field_data(const Gtk::TreeModel::iterator& row, const LayoutItem_Field& field, const 
Gnome::Gda::Value& value) override;
 
 
   bool fill_from_database() override;
diff --git a/glom/mode_data/box_data_list.cc b/glom/mode_data/box_data_list.cc
index 5f1da4f..2b61205 100644
--- a/glom/mode_data/box_data_list.cc
+++ b/glom/mode_data/box_data_list.cc
@@ -342,17 +342,17 @@ Gnome::Gda::Value Box_Data_List::get_primary_key_value_first() const
   return Gnome::Gda::Value();
 }
 
-Gnome::Gda::Value Box_Data_List::get_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& 
field) const
+Gnome::Gda::Value Box_Data_List::get_entered_field_data(const LayoutItem_Field& field) const
 {
   return m_AddDel.get_value_selected(field);
 }
 
-void Box_Data_List::set_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& field, const 
Gnome::Gda::Value& value)
+void Box_Data_List::set_entered_field_data(const LayoutItem_Field& field, const Gnome::Gda::Value& value)
 {
   m_AddDel.set_value_selected(field, value);
 }
 
-void Box_Data_List::set_entered_field_data(const Gtk::TreeModel::iterator& row, const std::shared_ptr<const 
LayoutItem_Field>& field, const Gnome::Gda::Value& value)
+void Box_Data_List::set_entered_field_data(const Gtk::TreeModel::iterator& row, const LayoutItem_Field& 
field, const Gnome::Gda::Value& value)
 {
   m_AddDel.set_value(row, field, value);
 }
diff --git a/glom/mode_data/box_data_list.h b/glom/mode_data/box_data_list.h
index 454f083..1ba572f 100644
--- a/glom/mode_data/box_data_list.h
+++ b/glom/mode_data/box_data_list.h
@@ -43,9 +43,9 @@ public:
   Gnome::Gda::Value get_primary_key_value_selected() const override;
   void set_primary_key_value(const Gtk::TreeModel::iterator& row, const Gnome::Gda::Value& value) override;
 
-  Gnome::Gda::Value get_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& field) const 
override;
-  void set_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& 
value) override;
-  void set_entered_field_data(const Gtk::TreeModel::iterator& row, const std::shared_ptr<const 
LayoutItem_Field>& field, const Gnome::Gda::Value& value) override;
+  Gnome::Gda::Value get_entered_field_data(const LayoutItem_Field& field) const override;
+  void set_entered_field_data(const LayoutItem_Field& field, const Gnome::Gda::Value& value) override;
+  void set_entered_field_data(const Gtk::TreeModel::iterator& row, const LayoutItem_Field& field, const 
Gnome::Gda::Value& value) override;
 
   Gtk::TreeModel::iterator get_row_selected() override;
 
diff --git a/glom/mode_data/box_data_list_related.cc b/glom/mode_data/box_data_list_related.cc
index 0aac3e0..5d28d05 100644
--- a/glom/mode_data/box_data_list_related.cc
+++ b/glom/mode_data/box_data_list_related.cc
@@ -277,7 +277,7 @@ void Box_Data_List_Related::on_adddel_record_added(const Gtk::TreeModel::iterato
     //m_key_field is the field in this table that must match another field in the parent table.
     auto layout_item = std::make_shared<LayoutItem_Field>();
     layout_item->set_full_field_details(m_key_field);
-    key_value = m_AddDel.get_value(row, layout_item);
+    key_value = m_AddDel.get_value(row, *layout_item);
   }
 
 
@@ -309,7 +309,7 @@ void Box_Data_List_Related::on_adddel_record_added(const Gtk::TreeModel::iterato
 
       //TODO: Although the to-field value is visible on the new related record, get_value() returns NULL so 
you can't immediately navigate to the new record:
       //std::cout << "debug: " << G_STRFUNC << ": setting field=" << layout_item->get_name() << 
"m_key_value=" << m_key_value.to_string() << std::endl;
-      m_AddDel.set_value(row, layout_item, m_key_value);
+      m_AddDel.set_value(row, *layout_item, m_key_value);
     }
     else
       std::cerr << G_STRFUNC << ": m_key_field is NULL\n";
diff --git a/glom/mode_data/datawidget/cellcreation.cc b/glom/mode_data/datawidget/cellcreation.cc
index f76bbf5..62c9d1f 100644
--- a/glom/mode_data/datawidget/cellcreation.cc
+++ b/glom/mode_data/datawidget/cellcreation.cc
@@ -60,6 +60,9 @@ static void apply_formatting(Gtk::CellRenderer* renderer, const std::shared_ptr<
     text_renderer->property_background() = bg;
 }
 
+//This really needs to take the layout_item as a std::shared_ptr<>,
+//because we might need to call set_layout_item(layout_item) on the newly-created cell.
+//TODO: And it should be non-const too.
 Gtk::CellRenderer* create_cell(const std::shared_ptr<const LayoutItem>& layout_item, const Glib::ustring& 
table_name, const std::shared_ptr<const Document>& document, guint fixed_cell_height)
 {
   Gtk::CellRenderer* cell = nullptr;
@@ -230,7 +233,7 @@ Gtk::CellRenderer* create_cell(const std::shared_ptr<const LayoutItem>& layout_i
         //TODO: Update this when the relationship's field value changes:
         if(choice_show_all) //Otherwise it must change whenever the relationships's ID value changes.
         {
-          pCellRendererDbList->set_choices_related(document, item_field, Gnome::Gda::Value() /* TODO: Makes 
no sense */);
+          pCellRendererDbList->set_choices_related(document, *item_field, Gnome::Gda::Value() /* TODO: Makes 
no sense */);
         }
       }
     }
diff --git a/glom/mode_data/datawidget/cellrenderer_dblist.cc 
b/glom/mode_data/datawidget/cellrenderer_dblist.cc
index e29c3ec..7de1cf5 100644
--- a/glom/mode_data/datawidget/cellrenderer_dblist.cc
+++ b/glom/mode_data/datawidget/cellrenderer_dblist.cc
@@ -48,7 +48,7 @@ void CellRendererDbList::set_choices_fixed(const Formatting::type_list_values& l
   //The other cells are added in on_editing_started().
 }
 
-void CellRendererDbList::set_choices_related(const std::shared_ptr<const Document>& document, const 
std::shared_ptr<const LayoutItem_Field>& layout_field, const Gnome::Gda::Value& foreign_key_value)
+void CellRendererDbList::set_choices_related(const std::shared_ptr<const Document>& document, const 
LayoutItem_Field& layout_field, const Gnome::Gda::Value& foreign_key_value)
 {
   ComboChoicesWithTreeModel::set_choices_related(document, layout_field, foreign_key_value);
 
diff --git a/glom/mode_data/datawidget/cellrenderer_dblist.h b/glom/mode_data/datawidget/cellrenderer_dblist.h
index 51d62f8..617594e 100644
--- a/glom/mode_data/datawidget/cellrenderer_dblist.h
+++ b/glom/mode_data/datawidget/cellrenderer_dblist.h
@@ -43,7 +43,7 @@ public:
   void set_choices_fixed(const Formatting::type_list_values& list_values, bool restricted = false) override;
 
   //This creates a db-based tree model, with appropriate cell renderers:
-  void set_choices_related(const std::shared_ptr<const Document>& document, const std::shared_ptr<const 
LayoutItem_Field>& layout_field, const Gnome::Gda::Value& foreign_key_value) override;
+  void set_choices_related(const std::shared_ptr<const Document>& document, const LayoutItem_Field& 
layout_field, const Gnome::Gda::Value& foreign_key_value) override;
 
   void set_restrict_values_to_list(bool val = true);
 
diff --git a/glom/mode_data/datawidget/combo.cc b/glom/mode_data/datawidget/combo.cc
index ff06a56..3f3d822 100644
--- a/glom/mode_data/datawidget/combo.cc
+++ b/glom/mode_data/datawidget/combo.cc
@@ -142,7 +142,7 @@ void ComboGlom::set_choices_fixed(const Formatting::type_list_values& list_value
   }
 }
 
-void ComboGlom::set_choices_related(const std::shared_ptr<const Document>& document, const 
std::shared_ptr<const LayoutItem_Field>& layout_field, const Gnome::Gda::Value& foreign_key_value)
+void ComboGlom::set_choices_related(const std::shared_ptr<const Document>& document, const LayoutItem_Field& 
layout_field, const Gnome::Gda::Value& foreign_key_value)
 {
   ComboChoicesWithTreeModel::set_choices_related(document, layout_field, foreign_key_value);
 
diff --git a/glom/mode_data/datawidget/combo.h b/glom/mode_data/datawidget/combo.h
index 566327c..fd64b3b 100644
--- a/glom/mode_data/datawidget/combo.h
+++ b/glom/mode_data/datawidget/combo.h
@@ -51,7 +51,7 @@ public:
   void set_choices_fixed(const Formatting::type_list_values& list_values, bool restricted = false) override;
 
   //This creates a db-based tree model, with appropriate cell renderers:
-  void set_choices_related(const std::shared_ptr<const Document>& document, const std::shared_ptr<const 
LayoutItem_Field>& layout_field, const Gnome::Gda::Value& foreign_key_value) override;
+  void set_choices_related(const std::shared_ptr<const Document>& document, const LayoutItem_Field& 
layout_field, const Gnome::Gda::Value& foreign_key_value) override;
 
   void set_read_only(bool read_only = true) override;
 
diff --git a/glom/mode_data/datawidget/combo_as_radio_buttons.cc 
b/glom/mode_data/datawidget/combo_as_radio_buttons.cc
index d007781..5b588c2 100644
--- a/glom/mode_data/datawidget/combo_as_radio_buttons.cc
+++ b/glom/mode_data/datawidget/combo_as_radio_buttons.cc
@@ -142,7 +142,7 @@ void ComboAsRadioButtons::set_choices_fixed(const Formatting::type_list_values&
   }
 }
 
-void ComboAsRadioButtons::set_choices_related(const std::shared_ptr<const Document>& document, const 
std::shared_ptr<const LayoutItem_Field>& layout_field, const Gnome::Gda::Value& foreign_key_value)
+void ComboAsRadioButtons::set_choices_related(const std::shared_ptr<const Document>& document, const 
LayoutItem_Field& layout_field, const Gnome::Gda::Value& foreign_key_value)
 {
   const auto list_values =
     DbUtils::get_choice_values(document, layout_field, foreign_key_value);
diff --git a/glom/mode_data/datawidget/combo_as_radio_buttons.h 
b/glom/mode_data/datawidget/combo_as_radio_buttons.h
index abd7afa..1f00bfd 100644
--- a/glom/mode_data/datawidget/combo_as_radio_buttons.h
+++ b/glom/mode_data/datawidget/combo_as_radio_buttons.h
@@ -52,7 +52,7 @@ public:
 
   void set_choices_fixed(const Formatting::type_list_values& list_values, bool restricted = false) override;
 
-  void set_choices_related(const std::shared_ptr<const Document>& document, const std::shared_ptr<const 
LayoutItem_Field>& layout_field, const Gnome::Gda::Value& foreign_key_value) override;
+  void set_choices_related(const std::shared_ptr<const Document>& document, const LayoutItem_Field& 
layout_field, const Gnome::Gda::Value& foreign_key_value) override;
 
   void set_read_only(bool read_only = true) override;
 
diff --git a/glom/mode_data/datawidget/combochoices.cc b/glom/mode_data/datawidget/combochoices.cc
index 5d976ae..f9b6726 100644
--- a/glom/mode_data/datawidget/combochoices.cc
+++ b/glom/mode_data/datawidget/combochoices.cc
@@ -58,7 +58,7 @@ bool ComboChoices::refresh_data_from_database_with_foreign_key(const std::shared
   return true;
 }
 
-void ComboChoices::set_choices_related(const std::shared_ptr<const Document>& /* document */, const 
std::shared_ptr<const LayoutItem_Field>& /* layout_field */, const Gnome::Gda::Value& /* foreign_key_value */)
+void ComboChoices::set_choices_related(const std::shared_ptr<const Document>& /* document */, const 
LayoutItem_Field& /* layout_field */, const Gnome::Gda::Value& /* foreign_key_value */)
 {
   /* TODO:
   type_list_values_with_second list_values;
diff --git a/glom/mode_data/datawidget/combochoices.h b/glom/mode_data/datawidget/combochoices.h
index 35626c0..3baf3f5 100644
--- a/glom/mode_data/datawidget/combochoices.h
+++ b/glom/mode_data/datawidget/combochoices.h
@@ -53,7 +53,7 @@ public:
    *
    * See also refresh_data_from_database_with_foreign_key().
    */
-  virtual void set_choices_related(const std::shared_ptr<const Document>& document, const 
std::shared_ptr<const LayoutItem_Field>& layout_field, const Gnome::Gda::Value& foreign_key_value) = 0;
+  virtual void set_choices_related(const std::shared_ptr<const Document>& document, const LayoutItem_Field& 
layout_field, const Gnome::Gda::Value& foreign_key_value) = 0;
 
   /** Update a choices widget's list of related choices if a relevant value in its parent table has changed.
    *
diff --git a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc 
b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
index 62bc226..74ba43d 100644
--- a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
+++ b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
@@ -229,7 +229,7 @@ void ComboChoicesWithTreeModel::set_choices_fixed(const Formatting::type_list_va
   //then sets up the view, using the model.
 }
 
-void ComboChoicesWithTreeModel::set_choices_related(const std::shared_ptr<const Document>& document, const 
std::shared_ptr<const LayoutItem_Field>& layout_field, const Gnome::Gda::Value& foreign_key_value)
+void ComboChoicesWithTreeModel::set_choices_related(const std::shared_ptr<const Document>& document, const 
LayoutItem_Field& layout_field, const Gnome::Gda::Value& foreign_key_value)
 {
   if(!document)
   {
@@ -237,7 +237,7 @@ void ComboChoicesWithTreeModel::set_choices_related(const std::shared_ptr<const
     return;
   }
 
-  const auto format = layout_field->get_formatting_used();
+  const auto format = layout_field.get_formatting_used();
   std::shared_ptr<const Relationship> choice_relationship;
   std::shared_ptr<const LayoutItem_Field> layout_choice_first;
   std::shared_ptr<const LayoutGroup> layout_choice_extra;
diff --git a/glom/mode_data/datawidget/combochoiceswithtreemodel.h 
b/glom/mode_data/datawidget/combochoiceswithtreemodel.h
index fe94ff2..e93dc7e 100644
--- a/glom/mode_data/datawidget/combochoiceswithtreemodel.h
+++ b/glom/mode_data/datawidget/combochoiceswithtreemodel.h
@@ -43,7 +43,7 @@ public:
   void set_choices_fixed(const Formatting::type_list_values& list_values, bool restricted = false) override;
 
   //This creates a db-based tree model, with appropriate cell renderers:
-  void set_choices_related(const std::shared_ptr<const Document>& document, const std::shared_ptr<const 
LayoutItem_Field>& layout_field, const Gnome::Gda::Value& foreign_key_value) override;
+  void set_choices_related(const std::shared_ptr<const Document>& document, const LayoutItem_Field& 
layout_field, const Gnome::Gda::Value& foreign_key_value) override;
 
 
   //Not named get_model(), to avoid clashing with ComboBox::get_model().
diff --git a/glom/mode_data/datawidget/datawidget.cc b/glom/mode_data/datawidget/datawidget.cc
index 52b7ae6..b7a5094 100644
--- a/glom/mode_data/datawidget/datawidget.cc
+++ b/glom/mode_data/datawidget/datawidget.cc
@@ -132,7 +132,7 @@ DataWidget::DataWidget(const std::shared_ptr<LayoutItem_Field>& field, const Gli
         combo = create_combo_widget_for_field(field);
         combo->set_layout_item( get_layout_item(), table_name);
 
-        combo->set_choices_related(document, field, Gnome::Gda::Value() /* no ID means show all related 
records */);
+        combo->set_choices_related(document, *field, Gnome::Gda::Value() /* no ID means show all related 
records */);
       }
       else
       {
diff --git a/glom/mode_data/db_adddel/db_adddel.cc b/glom/mode_data/db_adddel/db_adddel.cc
index edf1d85..c558094 100644
--- a/glom/mode_data/db_adddel/db_adddel.cc
+++ b/glom/mode_data/db_adddel/db_adddel.cc
@@ -326,7 +326,7 @@ Gtk::TreeModel::iterator DbAddDel::get_item_placeholder()
    return Gtk::TreeModel::iterator();
 }
 
-Gnome::Gda::Value DbAddDel::get_value(const Gtk::TreeModel::iterator& iter, const std::shared_ptr<const 
LayoutItem_Field>& layout_item) const
+Gnome::Gda::Value DbAddDel::get_value(const Gtk::TreeModel::iterator& iter, const LayoutItem_Field& 
layout_item) const
 {
   Gnome::Gda::Value value;
 
@@ -361,7 +361,7 @@ Gnome::Gda::Value DbAddDel::get_value_key_selected() const
     return Gnome::Gda::Value();
 }
 
-Gnome::Gda::Value DbAddDel::get_value_selected(const std::shared_ptr<const LayoutItem_Field>& layout_item) 
const
+Gnome::Gda::Value DbAddDel::get_value_selected(const LayoutItem_Field& layout_item) const
 {
   return get_value(get_item_selected(), layout_item);
 }
@@ -425,10 +425,10 @@ bool DbAddDel::select_item(const Gtk::TreeModel::iterator& iter, bool start_edit
       break;
   }
 
-  return select_item(iter, layout_item, start_editing);
+  return select_item(iter, *layout_item, start_editing);
 }
 
-bool DbAddDel::select_item(const Gtk::TreeModel::iterator& iter, const std::shared_ptr<const LayoutItem>& 
layout_item, bool start_editing)
+bool DbAddDel::select_item(const Gtk::TreeModel::iterator& iter, const LayoutItem& layout_item, bool 
start_editing)
 {
   if(!m_list_store)
     return false;
@@ -805,12 +805,12 @@ bool DbAddDel::refresh_from_database_blank()
   return true;
 }
 
-void DbAddDel::set_value(const Gtk::TreeModel::iterator& iter, const std::shared_ptr<const 
LayoutItem_Field>& layout_item, const Gnome::Gda::Value& value)
+void DbAddDel::set_value(const Gtk::TreeModel::iterator& iter, const LayoutItem_Field& layout_item, const 
Gnome::Gda::Value& value)
 {
   set_value(iter, layout_item, value, true /* including the specified field */);
 }
 
-void DbAddDel::set_value(const Gtk::TreeModel::iterator& iter, const std::shared_ptr<const 
LayoutItem_Field>& layout_item, const Gnome::Gda::Value& value, bool set_specified_field_layout)
+void DbAddDel::set_value(const Gtk::TreeModel::iterator& iter, const LayoutItem_Field& layout_item, const 
Gnome::Gda::Value& value, bool set_specified_field_layout)
 {
   //g_warning("DbAddDel::set_value begin");
 
@@ -847,7 +847,7 @@ void DbAddDel::set_value(const Gtk::TreeModel::iterator& iter, const std::shared
   //g_warning("DbAddDel::set_value end");
 }
 
-void DbAddDel::set_value_selected(const std::shared_ptr<const LayoutItem_Field>& layout_item, const 
Gnome::Gda::Value& value)
+void DbAddDel::set_value_selected(const LayoutItem_Field& layout_item, const Gnome::Gda::Value& value)
 {
   set_value(get_item_selected(), layout_item, value);
 }
@@ -884,7 +884,7 @@ void DbAddDel::refresh_cell_choices_data_from_database_with_foreign_key(guint mo
     return;
   }
 
-  cell->set_choices_related(get_document(), layout_field, foreign_key_value);
+  cell->set_choices_related(get_document(), *layout_field, foreign_key_value);
 }
 
 void DbAddDel::remove_all_columns()
@@ -940,15 +940,12 @@ FoundSet DbAddDel::get_found_set() const
   return m_found_set;
 }
 
-DbAddDel::type_list_indexes DbAddDel::get_data_model_column_index(const std::shared_ptr<const 
LayoutItem_Field>& layout_item_field, bool including_specified_field_layout) const
+DbAddDel::type_list_indexes DbAddDel::get_data_model_column_index(const LayoutItem_Field& layout_item_field, 
bool including_specified_field_layout) const
 {
   //TODO_Performance: Replace all this looping by a cache/map:
 
   type_list_indexes list_indexes;
 
-  if(!layout_item_field)
-    return list_indexes;
-
   guint data_model_column_index = 0;
   for(const auto& item : m_column_items)
   {
@@ -956,7 +953,7 @@ DbAddDel::type_list_indexes DbAddDel::get_data_model_column_index(const std::sha
     if(field)
     {
       if(field->is_same_field(layout_item_field)
-        && (including_specified_field_layout || field != layout_item_field))
+        && (including_specified_field_layout || *field != layout_item_field))
       {
         list_indexes.emplace_back(data_model_column_index);
       }
@@ -968,29 +965,23 @@ DbAddDel::type_list_indexes DbAddDel::get_data_model_column_index(const std::sha
   return list_indexes;
 }
 
-DbAddDel::type_list_indexes DbAddDel::get_column_index(const std::shared_ptr<const LayoutItem>& layout_item) 
const
+DbAddDel::type_list_indexes DbAddDel::get_column_index(const LayoutItem& layout_item) const
 {
   //TODO_Performance: Replace all this looping by a cache/map:
 
   type_list_indexes list_indexes;
 
-  if(!layout_item)
-  {
-    std::cerr << G_STRFUNC << ": layout_item was null.\n";
-    return list_indexes;
-  }
-
-  auto layout_item_field = std::dynamic_pointer_cast<const LayoutItem_Field>(layout_item);
+  auto layout_item_field = dynamic_cast<const LayoutItem_Field*>(&layout_item);
 
   guint i = 0;
   for(const auto& item : m_column_items)
   {
     const auto field = std::dynamic_pointer_cast<const LayoutItem_Field>(item); //TODO_Performance: This 
would be unnecessary if !layout_item_field
-    if(field && layout_item_field && field->is_same_field(layout_item_field))
+    if(field && layout_item_field && field->is_same_field(*layout_item_field))
     {
       list_indexes.emplace_back(i);
     }
-    else if(*(item) == *(layout_item))
+    else if(*(item) == layout_item)
     {
       list_indexes.emplace_back(i);
     }
@@ -1001,14 +992,11 @@ DbAddDel::type_list_indexes DbAddDel::get_column_index(const std::shared_ptr<con
   return list_indexes;
 }
 
-DbAddDel::type_list_indexes DbAddDel::get_choice_index(const std::shared_ptr<const LayoutItem_Field>& 
from_key)
+DbAddDel::type_list_indexes DbAddDel::get_choice_index(const LayoutItem_Field& from_key)
 {
   type_list_indexes result;
 
-  if(!from_key)
-    return result;
-
-  const auto from_key_name = from_key->get_name();
+  const auto from_key_name = from_key.get_name();
 
   guint index = 0;
   for(const auto& item : m_column_items)
@@ -2075,7 +2063,7 @@ bool DbAddDel::start_new_record()
 
   if(fieldToEdit)
   {
-    select_item(iter, fieldToEdit, true /* start_editing */);
+    select_item(iter, *fieldToEdit, true /* start_editing */);
   }
   else
   {
@@ -2129,8 +2117,8 @@ void DbAddDel::user_changed(const Gtk::TreeModel::iterator& row, guint col)
           if(primary_key_field)
           {
             //Get the value of the corresponding key in the current table (that identifies the record in the 
table that we will change)
-            auto layout_item = std::make_shared<LayoutItem_Field>();
-            layout_item->set_full_field_details( document->get_field(relationship->get_from_table(), 
relationship->get_from_field()) );
+            LayoutItem_Field layout_item;
+            layout_item.set_full_field_details( document->get_field(relationship->get_from_table(), 
relationship->get_from_field()) );
 
             primary_key_value = get_value_selected(layout_item);
 
@@ -2156,7 +2144,7 @@ void DbAddDel::user_changed(const Gtk::TreeModel::iterator& row, guint col)
       }
 
       //Update the field in the record (the record with this primary key):
-      const auto field_value = get_value(row, layout_field);
+      const auto field_value = get_value(row, *layout_field);
       //std::cout << "debug: " << G_STRFUNC << ": field_value = " << field_value.to_string() << std::endl;
       //const auto field = layout_field->m_field;
       //const Glib::ustring strFieldName = layout_field->get_name();
@@ -2168,7 +2156,7 @@ void DbAddDel::user_changed(const Gtk::TreeModel::iterator& row, guint col)
       {
         //Revert to the value in the database:
         const auto value_old = get_field_value_in_database(field_in_record, window);
-        set_entered_field_data(row, layout_field, value_old);
+        set_entered_field_data(row, *layout_field, value_old);
 
         return; //The value has been reverted to the value in the database.
       }
@@ -2180,12 +2168,12 @@ void DbAddDel::user_changed(const Gtk::TreeModel::iterator& row, guint col)
         //Update failed.
         //Replace with correct values.
         const auto value_old = get_field_value_in_database(field_in_record, window);
-        set_entered_field_data(row, layout_field, value_old);
+        set_entered_field_data(row, *layout_field, value_old);
       }
       else
       {
         //Display the same value in other instances of the same field:
-        set_value(row, layout_field, field_value, false /* don't set the actually-edited cell */);
+        set_value(row, *layout_field, field_value, false /* don't set the actually-edited cell */);
 
         signal_record_changed().emit();
       }
@@ -2199,7 +2187,7 @@ void DbAddDel::user_changed(const Gtk::TreeModel::iterator& row, guint col)
       {
         LayoutFieldInRecord field_in_record(layout_field, m_found_set.m_table_name /* parent */, 
primary_key_field, primary_key_value);
         const auto value_old = get_field_value_in_database(field_in_record, window);
-        set_entered_field_data(row, layout_field, value_old);
+        set_entered_field_data(row, *layout_field, value_old);
       }
     }
     catch(const std::exception& ex)
@@ -2211,7 +2199,7 @@ void DbAddDel::user_changed(const Gtk::TreeModel::iterator& row, guint col)
       {
         LayoutFieldInRecord field_in_record(layout_field, m_found_set.m_table_name /* parent */, 
primary_key_field, primary_key_value);
         const auto value_old = get_field_value_in_database(field_in_record, window);
-        set_entered_field_data(row, layout_field, value_old);
+        set_entered_field_data(row, *layout_field, value_old);
       }
     }
   }
@@ -2273,8 +2261,8 @@ void DbAddDel::user_added(const Gtk::TreeModel::iterator& row)
     //This only works when the primary key is already stored: primary_key_value = get_value_key(row);
     //primary_key_value = get_value_key_selected();
 
-    auto layout_field = std::make_shared<LayoutItem_Field>();
-    layout_field->set_full_field_details(primary_key_field);
+    LayoutItem_Field layout_field;
+    layout_field.set_full_field_details(primary_key_field);
     primary_key_value = get_value_selected(layout_field);
     std::cout << "DEBUG: get_value_key_selected(): " << primary_key_value.to_string() << std::endl;
   }
@@ -2299,7 +2287,7 @@ void DbAddDel::user_added(const Gtk::TreeModel::iterator& row)
   {
     //Revert to a blank value.
     primary_key_value = 
Conversions::get_empty_value(layout_field->get_full_field_details()->get_glom_type());
-    set_entered_field_data(row, layout_field, primary_key_value);
+    set_entered_field_data(row, *layout_field, primary_key_value);
     return;
   }
 
@@ -2321,8 +2309,8 @@ void DbAddDel::user_added(const Gtk::TreeModel::iterator& row)
   //If it's an auto-increment, then get the value and show it:
   if(primary_key_field->get_auto_increment())
   {
-    auto layout_item = std::make_shared<LayoutItem_Field>();
-    layout_item->set_full_field_details(primary_key_field);
+    LayoutItem_Field layout_item;
+    layout_item.set_full_field_details(primary_key_field);
     set_value(row, layout_item, primary_key_value);
   }
 
@@ -2350,18 +2338,18 @@ void DbAddDel::user_requested_delete(const Gtk::TreeModel::iterator& rowStart, c
 }
 
 //An override of the Base_DB method:
-void DbAddDel::set_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& field, const 
Gnome::Gda::Value& value)
+void DbAddDel::set_entered_field_data(const LayoutItem_Field& field, const Gnome::Gda::Value& value)
 {
   return set_value_selected(field, value);
 }
 
 //An override of the Base_DB method:
-void DbAddDel::set_entered_field_data(const Gtk::TreeModel::iterator& row, const std::shared_ptr<const 
LayoutItem_Field>& field, const Gnome::Gda::Value& value)
+void DbAddDel::set_entered_field_data(const Gtk::TreeModel::iterator& row, const LayoutItem_Field& field, 
const Gnome::Gda::Value& value)
 {
   return set_value(row, field, value);
 }
 
-Gnome::Gda::Value DbAddDel::get_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& field) 
const
+Gnome::Gda::Value DbAddDel::get_entered_field_data(const LayoutItem_Field& field) const
 {
   return get_value_selected(field);
 }
diff --git a/glom/mode_data/db_adddel/db_adddel.h b/glom/mode_data/db_adddel/db_adddel.h
index d5a5f83..72cb265 100644
--- a/glom/mode_data/db_adddel/db_adddel.h
+++ b/glom/mode_data/db_adddel/db_adddel.h
@@ -87,7 +87,7 @@ public:
 
   void remove_item(const Gtk::TreeModel::iterator& iter);
 
-  Gnome::Gda::Value get_value(const Gtk::TreeModel::iterator& iter, const std::shared_ptr<const 
LayoutItem_Field>& layout_item) const;
+  Gnome::Gda::Value get_value(const Gtk::TreeModel::iterator& iter, const LayoutItem_Field& layout_item) 
const;
 
   /** Get the row's hidden key
    */
@@ -100,7 +100,7 @@ public:
   /** @param col A value returned from add_column().
    * @result The value on the selected row.
    */
-  Gnome::Gda::Value get_value_selected(const std::shared_ptr<const LayoutItem_Field>& layout_item) const;
+  Gnome::Gda::Value get_value_selected(const LayoutItem_Field& layout_item) const;
   Gnome::Gda::Value get_value_key_selected() const;
 
   Gtk::TreeModel::iterator get_item_selected();
@@ -112,7 +112,7 @@ public:
    * @param start_editing Whether editing should start in the cell.
    * @result Whether the row was successfully selected.
    */
-  bool select_item(const Gtk::TreeModel::iterator& iter, const std::shared_ptr<const LayoutItem>& 
layout_item, bool start_editing = false);  //bool indicates success.
+  bool select_item(const Gtk::TreeModel::iterator& iter, const LayoutItem& layout_item, bool start_editing = 
false);  //bool indicates success.
   bool select_item(const Gtk::TreeModel::iterator& iter, bool start_editing = false);
 
   guint get_count() const;
@@ -122,13 +122,13 @@ public:
    * @param layout_item Describes the column(s) whose values should be changed.
    * @param value The new value.
    */
-  virtual void set_value(const Gtk::TreeModel::iterator& iter, const std::shared_ptr<const 
LayoutItem_Field>& layout_item, const Gnome::Gda::Value& value);
+  virtual void set_value(const Gtk::TreeModel::iterator& iter, const LayoutItem_Field& layout_item, const 
Gnome::Gda::Value& value);
 
   /**
    * @param col A value returned from add_column().
    * @param value The new value.
    */
-  virtual void set_value_selected(const std::shared_ptr<const LayoutItem_Field>& layout_item, const 
Gnome::Gda::Value& value);
+  virtual void set_value_selected(const LayoutItem_Field& layout_item, const Gnome::Gda::Value& value);
 
   bool get_is_first_row(const Gtk::TreeModel::iterator& iter) const;
 
@@ -267,12 +267,12 @@ public:
 
 private:
 
-  void set_value(const Gtk::TreeModel::iterator& iter, const std::shared_ptr<const LayoutItem_Field>& 
layout_item, const Gnome::Gda::Value& value, bool set_specified_field_layout);
+  void set_value(const Gtk::TreeModel::iterator& iter, const LayoutItem_Field& layout_item, const 
Gnome::Gda::Value& value, bool set_specified_field_layout);
 
   //Overrides of Base_DB/Base_DB_Table methods:
-  void set_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& 
value) override;
-  void set_entered_field_data(const Gtk::TreeModel::iterator& row, const std::shared_ptr<const 
LayoutItem_Field>& field, const Gnome::Gda::Value& value) override;
-  Gnome::Gda::Value get_entered_field_data(const std::shared_ptr<const LayoutItem_Field>& field) const 
override;
+  void set_entered_field_data(const LayoutItem_Field& field, const Gnome::Gda::Value& value) override;
+  void set_entered_field_data(const Gtk::TreeModel::iterator& row, const LayoutItem_Field& field, const 
Gnome::Gda::Value& value) override;
+  Gnome::Gda::Value get_entered_field_data(const LayoutItem_Field& field) const override;
   Gtk::TreeModel::iterator get_row_selected() override;
 
   //Implementations of pure virtual methods from Base_DB_Table_Data:
@@ -288,15 +288,16 @@ private:
 
   typedef std::list<guint> type_list_indexes;
   ///Return the column indexes of any columns that display this field.
-  type_list_indexes get_column_index(const std::shared_ptr<const LayoutItem>& layout_item) const;
+  type_list_indexes get_column_index(const LayoutItem& layout_item) const;
 
+  //TODO: Make this const?
   /// Get indexes of any columns with choices with !show_all relationships that have @a from_key as the 
from_key.
-  type_list_indexes get_choice_index(const std::shared_ptr<const LayoutItem_Field>& from_key);
+  type_list_indexes get_choice_index(const LayoutItem_Field& from_key);
 
   /** Return the query column index of any columns that display this field:
    * @param including_specified_field_layout If false, then don't return the actual layout item itself.
    */
-  type_list_indexes get_data_model_column_index(const std::shared_ptr<const LayoutItem_Field>& 
layout_item_field, bool including_specified_field_layout = true) const;
+  type_list_indexes get_data_model_column_index(const LayoutItem_Field& layout_item_field, bool 
including_specified_field_layout = true) const;
 
 protected:
   void setup_menu(Gtk::Widget* widget);
diff --git a/glom/mode_data/flowtablewithfields.cc b/glom/mode_data/flowtablewithfields.cc
index cea8416..3373985 100644
--- a/glom/mode_data/flowtablewithfields.cc
+++ b/glom/mode_data/flowtablewithfields.cc
@@ -106,9 +106,9 @@ void FlowTableWithFields::add_layout_item(const std::shared_ptr<LayoutItem>& ite
     if(field_details)
     {
       if(field_details->get_auto_increment())
-        set_field_editable(field, false);
+        set_field_editable(*field, false);
       else
-        set_field_editable(field, field->get_editable_and_allowed());
+        set_field_editable(*field, field->get_editable_and_allowed());
     }
   }
   else
@@ -672,12 +672,12 @@ void FlowTableWithFields::remove_field(const Glib::ustring& id)
   }
 }
 
-void FlowTableWithFields::set_field_value(const std::shared_ptr<const LayoutItem_Field>& field, const 
Gnome::Gda::Value& value)
+void FlowTableWithFields::set_field_value(const LayoutItem_Field& field, const Gnome::Gda::Value& value)
 {
   set_field_value(field, value, true);
 }
 
-void FlowTableWithFields::set_field_value(const std::shared_ptr<const LayoutItem_Field>& field, const 
Gnome::Gda::Value& value, bool set_specified_field_layout)
+void FlowTableWithFields::set_field_value(const LayoutItem_Field& field, const Gnome::Gda::Value& value, 
bool set_specified_field_layout)
 {
   //Set widgets which should show the value of this field:
   for(const auto& item : get_field(field, set_specified_field_layout))
@@ -710,12 +710,12 @@ void FlowTableWithFields::set_field_value(const std::shared_ptr<const LayoutItem
   }
 }
 
-void FlowTableWithFields::set_other_field_value(const std::shared_ptr<const LayoutItem_Field>& field, const 
Gnome::Gda::Value& value)
+void FlowTableWithFields::set_other_field_value(const LayoutItem_Field& field, const Gnome::Gda::Value& 
value)
 {
   set_field_value(field, value, false);
 }
 
-Gnome::Gda::Value FlowTableWithFields::get_field_value(const std::shared_ptr<const LayoutItem_Field>& field) 
const
+Gnome::Gda::Value FlowTableWithFields::get_field_value(const LayoutItem_Field& field) const
 {
   const auto list_widgets = get_field(field, true);
   for(const auto& list_widget : list_widgets)
@@ -733,7 +733,7 @@ Gnome::Gda::Value FlowTableWithFields::get_field_value(const std::shared_ptr<con
   return Gnome::Gda::Value(); //null.
 }
 
-void FlowTableWithFields::set_field_editable(const std::shared_ptr<const LayoutItem_Field>& field, bool 
editable)
+void FlowTableWithFields::set_field_editable(const LayoutItem_Field& field, bool editable)
 {
   for(const auto& item : get_field(field, true))
   {
@@ -745,7 +745,7 @@ void FlowTableWithFields::set_field_editable(const std::shared_ptr<const LayoutI
   }
 }
 
-void FlowTableWithFields::update_choices(const std::shared_ptr<const LayoutItem_Field>& field)
+void FlowTableWithFields::update_choices(const LayoutItem_Field& field)
 {
   for(const auto& item : get_field(field, true))
   {
@@ -772,11 +772,11 @@ void FlowTableWithFields::update_choices(const std::shared_ptr<const LayoutItem_
 }
 
 
-FlowTableWithFields::type_portals FlowTableWithFields::get_portals(const std::shared_ptr<const 
LayoutItem_Field>& from_key)
+FlowTableWithFields::type_portals FlowTableWithFields::get_portals(const LayoutItem_Field& from_key)
 {
   type_portals result;
 
-  const auto from_key_name = from_key->get_name();
+  const auto from_key_name = from_key.get_name();
 
   //Check the single-item widgets:
   for(const auto& pPortalUI : m_portals)
@@ -815,13 +815,11 @@ FlowTableWithFields::type_portals FlowTableWithFields::get_portals(const std::sh
   return result;
 }
 
-FlowTableWithFields::type_choice_widgets FlowTableWithFields::get_choice_widgets(const std::shared_ptr<const 
LayoutItem_Field>& from_key)
+FlowTableWithFields::type_choice_widgets FlowTableWithFields::get_choice_widgets(const LayoutItem_Field& 
from_key)
 {
   type_choice_widgets result;
-  if(!from_key)
-    return result;
 
-  const auto from_key_name = from_key->get_name();
+  const auto from_key_name = from_key.get_name();
 
   //Check the single-item widgets:
   for(const auto& the_pair : m_listFields)
@@ -876,11 +874,11 @@ namespace
   // Get the direct widgets represesenting a given layout item
   // from a flowtable, without considering subflowtables:
   template<typename InputIterator, typename OutputIterator>
-  static void get_direct_fields(InputIterator begin, InputIterator end, OutputIterator out, const 
std::shared_ptr<const LayoutItem_Field>& layout_item, bool include_item)
+  static void get_direct_fields(InputIterator begin, InputIterator end, OutputIterator out, const 
LayoutItem_Field& layout_item, bool include_item)
   {
     for(InputIterator iter = begin; iter != end; ++iter)
     {
-      if(iter->m_field->is_same_field(layout_item) && (include_item || iter->m_field != layout_item))
+      if(iter->m_field->is_same_field(layout_item) && (include_item || *(iter->m_field) != layout_item))
       {
         if(iter->m_checkbutton)
           *out++ = iter->m_checkbutton;
@@ -891,7 +889,7 @@ namespace
   }
 }
 
-FlowTableWithFields::type_list_const_widgets FlowTableWithFields::get_field(const std::shared_ptr<const 
LayoutItem_Field>& layout_item, bool include_item) const
+FlowTableWithFields::type_list_const_widgets FlowTableWithFields::get_field(const LayoutItem_Field& 
layout_item, bool include_item) const
 {
   type_list_const_widgets result;
 
@@ -914,7 +912,7 @@ FlowTableWithFields::type_list_const_widgets FlowTableWithFields::get_field(cons
   return result;
 }
 
-FlowTableWithFields::type_list_widgets FlowTableWithFields::get_field(const std::shared_ptr<const 
LayoutItem_Field>& layout_item, bool include_item)
+FlowTableWithFields::type_list_widgets FlowTableWithFields::get_field(const LayoutItem_Field& layout_item, 
bool include_item)
 {
   type_list_widgets result;
 
diff --git a/glom/mode_data/flowtablewithfields.h b/glom/mode_data/flowtablewithfields.h
index d22fecf..952e3b8 100644
--- a/glom/mode_data/flowtablewithfields.h
+++ b/glom/mode_data/flowtablewithfields.h
@@ -91,22 +91,22 @@ public:
    */
   void add_layout_group_or_derived(const std::shared_ptr<LayoutGroup>& group, bool with_indent = true);
 
-  void set_field_editable(const std::shared_ptr<const LayoutItem_Field>& field, bool editable = true);
+  void set_field_editable(const LayoutItem_Field& field, bool editable = true);
 
-  Gnome::Gda::Value get_field_value(const std::shared_ptr<const LayoutItem_Field>& field) const;
+  Gnome::Gda::Value get_field_value(const LayoutItem_Field& field) const;
 
   /** Set the displayed @a value in any instances of the specified @a field.
    */
-  void set_field_value(const std::shared_ptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& value);
+  void set_field_value(const LayoutItem_Field& field, const Gnome::Gda::Value& value);
 
   /** Set the displayed @a value in any instances of the field other than the specified @a layout_field.
    */
-  void set_other_field_value(const std::shared_ptr<const LayoutItem_Field>& layout_field, const 
Gnome::Gda::Value& value);
+  void set_other_field_value(const LayoutItem_Field& layout_field, const Gnome::Gda::Value& value);
 
   /** Refresh the list of related records in choice combo boxes,
    * in any instance of the specified field.
    */
-  void update_choices(const std::shared_ptr<const LayoutItem_Field>& field);
+  void update_choices(const LayoutItem_Field& field);
 
   typedef std::list<Gtk::Widget*> type_list_widgets;
   typedef std::list<const Gtk::Widget*> type_list_const_widgets;
@@ -178,23 +178,23 @@ public:
 
 private:
 
-  void set_field_value(const std::shared_ptr<const LayoutItem_Field>& field, const Gnome::Gda::Value& value, 
bool set_specified_field_layout);
+  void set_field_value(const LayoutItem_Field& field, const Gnome::Gda::Value& value, bool 
set_specified_field_layout);
 
   // If include_item is set, then the output list will contain field's widget,
   // otherwise not.
-  type_list_widgets get_field(const std::shared_ptr<const LayoutItem_Field>& field, bool include_item);
-  type_list_const_widgets get_field(const std::shared_ptr<const LayoutItem_Field>& field, bool include_item) 
const;
+  type_list_widgets get_field(const LayoutItem_Field& field, bool include_item);
+  type_list_const_widgets get_field(const LayoutItem_Field& field, bool include_item) const;
 
   typedef std::list<Box_Data_Portal*> type_portals;
 
   /// Get portals whose relationships have @a from_key as the from_key.
-  type_portals get_portals(const std::shared_ptr<const LayoutItem_Field>& from_key);
+  type_portals get_portals(const LayoutItem_Field& from_key);
 
 
   typedef std::list<DataWidgetChildren::ComboChoices*> type_choice_widgets;
 
   /// Get choice widgets with !show_all relationships that have @a from_key as the from_key.
-  type_choice_widgets get_choice_widgets(const std::shared_ptr<const LayoutItem_Field>& from_key);
+  type_choice_widgets get_choice_widgets(const LayoutItem_Field& from_key);
 
   /** Examine this flow table and all child flow tables, discovering which
    * has the most columns.
diff --git a/glom/mode_design/layout/dialog_choose_field.cc b/glom/mode_design/layout/dialog_choose_field.cc
index 799e758..c540bb0 100644
--- a/glom/mode_design/layout/dialog_choose_field.cc
+++ b/glom/mode_design/layout/dialog_choose_field.cc
@@ -256,7 +256,7 @@ Dialog_ChooseField::type_list_field_items Dialog_ChooseField::get_fields_chosen(
 
     // Start with the original LayoutItem_Field,
     // to preserve extra information such as Translations:
-    if(m_start_field && m_start_field->is_same_field(field))
+    if(m_start_field && m_start_field->is_same_field(*field))
       field = m_start_field;
     else
       field = std::make_shared<LayoutItem_Field>();
diff --git a/tests/test_layout_item_field.cc b/tests/test_layout_item_field.cc
index 330817d..17ff5c7 100644
--- a/tests/test_layout_item_field.cc
+++ b/tests/test_layout_item_field.cc
@@ -26,9 +26,9 @@
 static
 bool test_compare_empty_instances()
 {
-  auto layout_item1 = std::make_shared<Glom::LayoutItem_Field>();
-  auto layout_item2 = std::make_shared<Glom::LayoutItem_Field>();
-  if(!layout_item1->is_same_field(layout_item2))
+  Glom::LayoutItem_Field layout_item1;
+  Glom::LayoutItem_Field layout_item2;
+  if(!layout_item1.is_same_field(layout_item2))
   {
     std::cerr << G_STRFUNC << ": Glom::LayoutItem_Field::is_same_field() failed with empty instances.\n";
     return false;
@@ -40,11 +40,11 @@ bool test_compare_empty_instances()
 static
 bool test_compare_same_named_instances()
 {
-  auto layout_item1 = std::make_shared<Glom::LayoutItem_Field>();
-  auto layout_item2 = std::make_shared<Glom::LayoutItem_Field>();
-  layout_item1->set_name("one");
-  layout_item2->set_name("two");
-  if(layout_item1->is_same_field(layout_item2))
+  Glom::LayoutItem_Field layout_item1;
+  Glom::LayoutItem_Field layout_item2;
+  layout_item1.set_name("one");
+  layout_item2.set_name("two");
+  if(layout_item1.is_same_field(layout_item2))
   {
     std::cerr << G_STRFUNC << ": Glom::LayoutItem_Field::is_same_field() failed with named field 
instances.\n";
     return false;
@@ -56,12 +56,12 @@ bool test_compare_same_named_instances()
 static
 bool test_compare_same_named_instances_unrelated_differences()
 {
-  auto layout_item1 = std::make_shared<Glom::LayoutItem_Field>();
-  auto layout_item2 = std::make_shared<Glom::LayoutItem_Field>();
-  layout_item1->set_name("one");
-  layout_item2->set_name("one");
-  layout_item2->set_hidden(); //is_same_field() should ignore this.
-  if(!layout_item1->is_same_field(layout_item2))
+  Glom::LayoutItem_Field layout_item1;
+  Glom::LayoutItem_Field layout_item2;
+  layout_item1.set_name("one");
+  layout_item2.set_name("one");
+  layout_item2.set_hidden(); //is_same_field() should ignore this.
+  if(!layout_item1.is_same_field(layout_item2))
   {
     std::cerr << G_STRFUNC << ": Glom::LayoutItem_Field::is_same_field() failed with named field instances 
with unrelated differences.\n";
     return false;
@@ -74,27 +74,27 @@ bool test_compare_same_named_instances_unrelated_differences()
 static
 bool test_compare_same_named_instances_with_relationship()
 {
-  auto layout_item1 = std::make_shared<Glom::LayoutItem_Field>();
-  auto layout_item2 = std::make_shared<Glom::LayoutItem_Field>();
-  layout_item1->set_name("one");
-  layout_item2->set_name("one");
+  Glom::LayoutItem_Field layout_item1;
+  Glom::LayoutItem_Field layout_item2;
+  layout_item1.set_name("one");
+  layout_item2.set_name("one");
 
   auto relationship1 = std::make_shared<Glom::Relationship>();
   relationship1->set_name("relationship1");
-  layout_item1->set_relationship(relationship1);
+  layout_item1.set_relationship(relationship1);
 
   auto relationship2 = std::make_shared<Glom::Relationship>();
   relationship2->set_name("relationship2");
-  layout_item2->set_relationship(relationship2);
+  layout_item2.set_relationship(relationship2);
 
-  if(layout_item1->is_same_field(layout_item2))
+  if(layout_item1.is_same_field(layout_item2))
   {
     std::cerr << G_STRFUNC << ": Glom::LayoutItem_Field::is_same_field() failed with field instances with 
different relationships.\n";
     return false;
   }
 
-  layout_item2->set_relationship(relationship1);
-  if(!layout_item1->is_same_field(layout_item2))
+  layout_item2.set_relationship(relationship1);
+  if(!layout_item1.is_same_field(layout_item2))
   {
     std::cerr << G_STRFUNC << ": Glom::LayoutItem_Field::is_same_field() failed with field instances with 
same relationships.\n";
     return false;
@@ -106,21 +106,21 @@ bool test_compare_same_named_instances_with_relationship()
 static
 bool test_compare_same_named_instances_with_related_relationship()
 {
-  auto layout_item1 = std::make_shared<Glom::LayoutItem_Field>();
-  auto layout_item2 = std::make_shared<Glom::LayoutItem_Field>();
-  layout_item1->set_name("one");
-  layout_item2->set_name("one");
+  Glom::LayoutItem_Field layout_item1;
+  Glom::LayoutItem_Field layout_item2;
+  layout_item1.set_name("one");
+  layout_item2.set_name("one");
 
   auto relationship1 = std::make_shared<Glom::Relationship>();
   relationship1->set_name("relationship1");
-  layout_item1->set_relationship(relationship1);
-  layout_item2->set_relationship(relationship1);
+  layout_item1.set_relationship(relationship1);
+  layout_item2.set_relationship(relationship1);
 
   auto relationship_related1 = std::make_shared<Glom::Relationship>();
   relationship_related1->set_name("relationship_related1");
-  layout_item1->set_related_relationship(relationship_related1);
+  layout_item1.set_related_relationship(relationship_related1);
 
-  if(layout_item1->is_same_field(layout_item2))
+  if(layout_item1.is_same_field(layout_item2))
   {
     std::cerr << G_STRFUNC << ": Glom::LayoutItem_Field::is_same_field() failed with field instances with 
different (one unset) related relationships.\n";
     return false;
@@ -128,16 +128,16 @@ bool test_compare_same_named_instances_with_related_relationship()
 
   auto relationship_related2 = std::make_shared<Glom::Relationship>();
   relationship_related2->set_name("relationship_related2");
-  layout_item2->set_related_relationship(relationship_related2);
+  layout_item2.set_related_relationship(relationship_related2);
 
-  if(layout_item1->is_same_field(layout_item2))
+  if(layout_item1.is_same_field(layout_item2))
   {
     std::cerr << G_STRFUNC << ": Glom::LayoutItem_Field::is_same_field() failed with field instances with 
different related relationships.\n";
     return false;
   }
 
-  layout_item2->set_related_relationship(relationship_related1);
-  if(!layout_item1->is_same_field(layout_item2))
+  layout_item2.set_related_relationship(relationship_related1);
+  if(!layout_item1.is_same_field(layout_item2))
   {
     std::cerr << G_STRFUNC << ": Glom::LayoutItem_Field::is_same_field() failed with field instances with 
same related relationships.\n";
     return false;
diff --git a/tests/test_selfhosting_new_then_choices.cc b/tests/test_selfhosting_new_then_choices.cc
index 5f217b4..32cd485 100644
--- a/tests/test_selfhosting_new_then_choices.cc
+++ b/tests/test_selfhosting_new_then_choices.cc
@@ -54,7 +54,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   }
 
   const auto values_with_second =
-    Glom::DbUtils::get_choice_values_all(document, field_with_choice);
+    Glom::DbUtils::get_choice_values_all(document, *field_with_choice);
   if(values_with_second.size() != 3)
   {
     std::cerr << G_STRFUNC << ": Failure: There were an unexpected number of choices.\n";


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