[glom] C++11: Use auto for shared_ptr<>.



commit 37a00864fc3fa2f96b75ebb83f97a61628592df2
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Jan 7 11:39:46 2016 +0100

    C++11: Use auto for shared_ptr<>.

 glom/appwindow.cc                                  |    8 +-
 glom/base_db.cc                                    |   68 ++++----
 glom/base_db_table_data.cc                         |   18 +-
 glom/box_reports.cc                                |    4 +-
 glom/frame_glom.cc                                 |   34 ++--
 glom/import_csv/dialog_import_csv_progress.cc      |    2 +-
 glom/libglom/connectionpool.cc                     |    6 +-
 glom/libglom/data_structure/layout/formatting.cc   |    2 +-
 glom/libglom/data_structure/layout/layoutgroup.cc  |   12 +-
 .../layout/layoutitem_calendarportal.cc            |    2 +-
 .../data_structure/layout/layoutitem_field.cc      |    2 +-
 .../data_structure/layout/layoutitem_portal.cc     |   12 +-
 .../data_structure/layout/usesrelationship.cc      |    2 +-
 glom/libglom/db_utils.cc                           |   16 +-
 glom/libglom/document/document.cc                  |  160 ++++++++++----------
 glom/libglom/example_document_load.cc              |    2 +-
 glom/libglom/privs.cc                              |    2 +-
 glom/libglom/python_embed/py_glom_record.cc        |    2 +-
 glom/libglom/python_embed/py_glom_related.cc       |    4 +-
 glom/libglom/python_embed/py_glom_relatedrecord.cc |    8 +-
 glom/libglom/report_builder.cc                     |   52 +++---
 glom/libglom/spawn_with_feedback.cc                |    2 +-
 glom/libglom/translations_po.cc                    |    2 +-
 glom/libglom/utils.cc                              |   18 +-
 glom/mode_data/box_data.cc                         |   12 +-
 glom/mode_data/box_data_calendar_related.cc        |   34 ++--
 glom/mode_data/box_data_details.cc                 |   22 ++--
 glom/mode_data/box_data_list.cc                    |    6 +-
 glom/mode_data/box_data_list_related.cc            |   14 +-
 glom/mode_data/box_data_manyrecords.cc             |    2 +-
 glom/mode_data/box_data_portal.cc                  |   12 +-
 glom/mode_data/buttonglom.cc                       |    2 +-
 glom/mode_data/datawidget/cellcreation.cc          |   12 +-
 glom/mode_data/datawidget/cellrenderer_dblist.cc   |    6 +-
 glom/mode_data/datawidget/combo.cc                 |    6 +-
 .../mode_data/datawidget/combo_as_radio_buttons.cc |   12 +-
 glom/mode_data/datawidget/combochoices.cc          |    6 +-
 .../datawidget/combochoiceswithtreemodel.cc        |   16 +-
 glom/mode_data/datawidget/datawidget.cc            |   18 +-
 glom/mode_data/datawidget/entry.cc                 |    8 +-
 glom/mode_data/datawidget/label.cc                 |    2 +-
 glom/mode_data/datawidget/treemodel_db.cc          |    4 +-
 .../datawidget/treemodel_db_withextratext.cc       |    2 +-
 glom/mode_data/db_adddel/db_adddel.cc              |   64 ++++----
 glom/mode_data/flowtablewithfields.cc              |   62 ++++----
 glom/mode_data/notebook_data.cc                    |    4 +-
 glom/mode_design/box_db_table_relationships.cc     |    8 +-
 glom/mode_design/dialog_database_preferences.cc    |    2 +-
 glom/mode_design/fields/box_db_table_definition.cc |   20 ++--
 .../mode_design/fields/dialog_defaultformatting.cc |    4 +-
 glom/mode_design/fields/dialog_fieldcalculation.cc |    8 +-
 glom/mode_design/fields/dialog_fielddefinition.cc  |   10 +-
 glom/mode_design/layout/combobox_fields.cc         |    4 +-
 glom/mode_design/layout/dialog_choose_field.cc     |    8 +-
 .../layout/dialog_layout_calendar_related.cc       |   20 ++--
 glom/mode_design/layout/dialog_layout_details.cc   |  130 ++++++++--------
 glom/mode_design/layout/dialog_layout_export.cc    |    6 +-
 .../layout/dialog_layout_list_related.cc           |   22 ++--
 .../layout/layout_item_dialogs/box_formatting.cc   |   10 +-
 .../layout_item_dialogs/dialog_buttonscript.cc     |    4 +-
 .../layout_item_dialogs/dialog_field_layout.cc     |    4 +-
 .../layout_item_dialogs/dialog_field_summary.cc    |    4 +-
 .../layout_item_dialogs/dialog_fieldslist.cc       |    6 +-
 .../layout/layout_item_dialogs/dialog_group_by.cc  |    4 +-
 .../layout_item_dialogs/dialog_imageobject.cc      |    2 +-
 .../layout/layout_item_dialogs/dialog_line.cc      |    2 +-
 .../layout_item_dialogs/dialog_sortfields.cc       |    6 +-
 .../layout_item_dialogs/dialog_textobject.cc       |    2 +-
 glom/mode_design/layout/treestore_layout.cc        |    4 +-
 .../mode_design/print_layouts/box_print_layouts.cc |    6 +-
 .../print_layouts/window_print_layout_edit.cc      |   38 +++---
 .../report_layout/dialog_layout_report.cc          |   42 +++---
 .../report_layout/treestore_report_layout.cc       |    2 +-
 glom/mode_design/users/dialog_groups_list.cc       |    2 +-
 glom/navigation/box_tables.cc                      |    6 +-
 glom/print_layout/canvas_layout_item.cc            |   16 +-
 glom/print_layout/canvas_print_layout.cc           |   66 ++++----
 glom/print_layout/print_layout_utils.cc            |   18 +-
 glom/utility_widgets/imageglom.cc                  |    2 +-
 glom/utility_widgets/layoutwidgetmenu.cc           |    2 +-
 glom/utility_widgets/layoutwidgetutils.cc          |    2 +-
 glom/utility_widgets/notebooklabelglom.cc          |    2 +-
 .../python/test_python_execute_func_with_record.cc |    2 +-
 ..._python_execute_func_with_record_field_types.cc |    4 +-
 tests/test_document_load.cc                        |   20 ++--
 tests/test_document_load_and_change.cc             |    6 +-
 tests/test_document_load_image.cc                  |    2 +-
 tests/test_document_load_translations.cc           |   18 +-
 tests/test_fake_connection.cc                      |    6 +-
 tests/test_field_file_format.cc                    |    2 +-
 ...t_selfhosting_new_from_example_defaultvalues.cc |    2 +-
 tests/test_selfhosting_new_from_example_float.cc   |    6 +-
 tests/test_selfhosting_new_then_change_columns.cc  |    6 +-
 tests/test_selfhosting_new_then_choices.cc         |    2 +-
 tests/test_selfhosting_new_then_image.cc           |    6 +-
 tests/test_selfhosting_new_then_lookup.cc          |   10 +-
 tests/test_selfhosting_new_then_report.cc          |    2 +-
 tests/test_selfhosting_new_then_report_summary.cc  |    2 +-
 tests/test_selfhosting_sqlinjection.cc             |   24 ++--
 tests/test_selfhosting_utils.cc                    |   14 +-
 tests/test_utils.cc                                |    2 +-
 tests/translations_po/test_document_import_po.cc   |    4 +-
 102 files changed, 700 insertions(+), 700 deletions(-)
---
diff --git a/glom/appwindow.cc b/glom/appwindow.cc
index eaf570b..2174f80 100644
--- a/glom/appwindow.cc
+++ b/glom/appwindow.cc
@@ -1118,7 +1118,7 @@ bool AppWindow::on_document_load()
   {
     Glib::ustring error_message; //TODO: Check this and tell the user.
     auto connection_pool = ConnectionPool::get_instance();
-    std::shared_ptr<SharedConnection> sharedconnection = connection_pool->connect();
+    auto sharedconnection = connection_pool->connect();
     AppPythonUICallbacks callbacks;
     glom_execute_python_function_implementation(script,
       type_map_fields(), //only used when there is a current table and record.
@@ -1262,7 +1262,7 @@ void AppWindow::update_userlevel_ui()
   {
     if(ConnectionPool::get_instance_is_ready())
     {
-      std::shared_ptr<SharedConnection> connection = ConnectionPool::get_and_connect();
+      auto connection = ConnectionPool::get_and_connect();
       if(connection && 
!connection->get_gda_connection()->supports_feature(Gnome::Gda::CONNECTION_FEATURE_USERS))
         m_action_developer_users->set_enabled(false);
     }
@@ -1514,7 +1514,7 @@ bool AppWindow::recreate_database_from_example(bool& user_cancelled)
   try
   {
     connection_pool->set_ready_to_connect(); //This has succeeded already.
-    std::shared_ptr<SharedConnection> sharedconnection = connection_pool->connect();
+    auto sharedconnection = connection_pool->connect();
     std::cerr << G_STRFUNC << ": Failed because database exists already." << std::endl;
 
     return false; //Connection to the database succeeded, because no exception was thrown. so the database 
exists already.
@@ -1658,7 +1658,7 @@ bool AppWindow::recreate_database_from_backup(const std::string& backup_data_fil
   try
   {
     connection_pool->set_ready_to_connect(); //This has succeeded already.
-    std::shared_ptr<SharedConnection> sharedconnection = connection_pool->connect();
+    auto sharedconnection = connection_pool->connect();
     std::cerr << G_STRFUNC << ": Failed because database exists already." << std::endl;
 
     return false; //Connection to the database succeeded, because no exception was thrown. so the database 
exists already.
diff --git a/glom/base_db.cc b/glom/base_db.cc
index b978417..703a522 100644
--- a/glom/base_db.cc
+++ b/glom/base_db.cc
@@ -219,7 +219,7 @@ namespace
   // Check primary key and uniqueness constraints when changing a column
   std::shared_ptr<Field> check_field_change_constraints(const std::shared_ptr<const Field>& field_old, const 
std::shared_ptr<const Field>& field)
   {
-    std::shared_ptr<Field> result = glom_sharedptr_clone(field);
+    auto result = glom_sharedptr_clone(field);
     bool primary_key_was_unset = false;
     if(field_old->get_primary_key() != field->get_primary_key())
     {
@@ -256,7 +256,7 @@ namespace
 std::shared_ptr<Field> Base_DB::change_column(const Glib::ustring& table_name, const std::shared_ptr<const 
Field>& field_old, const std::shared_ptr<const Field>& field, Gtk::Window* parent_window) const
 {
   auto connection_pool = ConnectionPool::get_instance();
-  std::shared_ptr<Field> result = check_field_change_constraints(field_old, field);
+  auto result = check_field_change_constraints(field_old, field);
 
   //TODO: change_column() doesn't throw any exception.
   try
@@ -453,7 +453,7 @@ std::shared_ptr<LayoutItem_Field> Base_DB::offer_field_formatting(const std::sha
 
 std::shared_ptr<LayoutItem_Text> Base_DB::offer_textobject(const std::shared_ptr<LayoutItem_Text>& 
start_textobject, Gtk::Window* transient_for, bool show_title)
 {
-  std::shared_ptr<LayoutItem_Text> result = start_textobject;
+  auto result = start_textobject;
 
   Dialog_TextObject* dialog = nullptr;
   Utils::get_glade_widget_derived_with_warning(dialog);
@@ -479,7 +479,7 @@ std::shared_ptr<LayoutItem_Text> Base_DB::offer_textobject(const std::shared_ptr
 
 std::shared_ptr<LayoutItem_Image> Base_DB::offer_imageobject(const std::shared_ptr<LayoutItem_Image>& 
start_imageobject, Gtk::Window* transient_for, bool show_title)
 {
-  std::shared_ptr<LayoutItem_Image> result = start_imageobject;
+  auto result = start_imageobject;
 
   Dialog_ImageObject* dialog = nullptr;
   Utils::get_glade_widget_derived_with_warning(dialog);
@@ -585,7 +585,7 @@ void Base_DB::get_table_fields_to_show_for_sequence_add_group(const Glib::ustrin
 
   for(const auto& item : group->get_items())
   {
-    std::shared_ptr<LayoutItem_Field> item_field = std::dynamic_pointer_cast<LayoutItem_Field>(item);
+    auto item_field = std::dynamic_pointer_cast<LayoutItem_Field>(item);
     if(item_field)
     {
       //Get the field info:
@@ -594,10 +594,10 @@ void Base_DB::get_table_fields_to_show_for_sequence_add_group(const Glib::ustrin
       if(item_field->get_has_relationship_name()) //If it's a field in a related table.
       {
         //TODO_Performance: get_fields_for_table_one_field() is probably very inefficient
-        std::shared_ptr<Field> field = DbUtils::get_fields_for_table_one_field(document, 
item_field->get_table_used(table_name), item->get_name());
+        auto field = DbUtils::get_fields_for_table_one_field(document, 
item_field->get_table_used(table_name), item->get_name());
         if(field)
         {
-          std::shared_ptr<LayoutItem_Field> layout_item = item_field;
+          auto layout_item = item_field;
           layout_item->set_full_field_details(field); //Fill in the full field information for later.
 
 
@@ -620,7 +620,7 @@ void Base_DB::get_table_fields_to_show_for_sequence_add_group(const Glib::ustrin
         //If the field does not exist anymore then we won't try to show it:
         if(iterFind != all_db_fields.end() )
         {
-          std::shared_ptr<LayoutItem_Field> layout_item = item_field;
+          auto layout_item = item_field;
           layout_item->set_full_field_details(*iterFind); //Fill the LayoutItem with the full field 
information.
 
           //std::cout << "debug: " << G_STRFUNC << ": name=" << layout_item->get_name() << std::endl;
@@ -635,10 +635,10 @@ void Base_DB::get_table_fields_to_show_for_sequence_add_group(const Glib::ustrin
     }
     else
     {
-      std::shared_ptr<LayoutGroup> item_group = std::dynamic_pointer_cast<LayoutGroup>(item);
+      auto item_group = std::dynamic_pointer_cast<LayoutGroup>(item);
       if(item_group)
       {
-        std::shared_ptr<LayoutItem_Portal> item_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(item);
+        auto item_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(item);
         if(!item_portal) //Do not recurse into portals. They are filled by means of a separate SQL query.
         {
           //Recurse:
@@ -677,7 +677,7 @@ Base_DB::type_vecConstLayoutFields Base_DB::get_table_fields_to_show_for_sequenc
       Glib::ustring primary_key_field_name;
       if(bPrimaryKeyFound)
       {
-        std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+        auto layout_item = std::make_shared<LayoutItem_Field>();
         layout_item->set_full_field_details(all_fields[iPrimaryKey]);
 
         //Don't use thousands separators with ID numbers:
@@ -697,7 +697,7 @@ Base_DB::type_vecConstLayoutFields Base_DB::get_table_fields_to_show_for_sequenc
       {
         if(field_info->get_name() != primary_key_field_name) //We already added the primary key.
         {
-          std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+          auto layout_item = std::make_shared<LayoutItem_Field>();
           layout_item->set_full_field_details(field_info);
 
           layout_item->set_editable(true); //A sensible default.
@@ -734,7 +734,7 @@ Base_DB::type_vecConstLayoutFields Base_DB::get_table_fields_to_show_for_sequenc
 
 void Base_DB::calculate_field_in_all_records(const Glib::ustring& table_name, const std::shared_ptr<const 
Field>& field)
 {
-  std::shared_ptr<const Field> primary_key = get_field_primary_key_for_table(table_name);
+  auto primary_key = get_field_primary_key_for_table(table_name);
   calculate_field_in_all_records(table_name, field, primary_key);
 }
 
@@ -756,7 +756,7 @@ void Base_DB::calculate_field_in_all_records(const Glib::ustring& table_name, co
   LayoutFieldInRecord field_in_record;
   field_in_record.m_table_name = table_name;
 
-  std::shared_ptr<LayoutItem_Field> layoutitem_field = std::make_shared<LayoutItem_Field>();
+  auto layoutitem_field = std::make_shared<LayoutItem_Field>();
   layoutitem_field->set_full_field_details(field);
   field_in_record.m_field = layoutitem_field;
   field_in_record.m_key = primary_key;
@@ -824,7 +824,7 @@ void Base_DB::calculate_field(const LayoutFieldInRecord& field_in_record)
       }
       else
       {
-        std::shared_ptr<const Field> field_needed = field_item_needed->get_full_field_details();
+        auto field_needed = field_item_needed->get_full_field_details();
         if(field_needed)
         {
           if(field_needed->get_has_calculation())
@@ -860,11 +860,11 @@ void Base_DB::calculate_field(const LayoutFieldInRecord& field_in_record)
       const auto field_values = get_record_field_values_for_calculation(field_in_record.m_table_name, 
field_in_record.m_key, field_in_record.m_key_value);
       if(!field_values.empty())
       {
-        std::shared_ptr<const Field> field = calc_progress_refreshed.m_field;
+        auto field = calc_progress_refreshed.m_field;
         if(field)
         {
           //We need the connection when we run the script, so that the script may use it.
-          std::shared_ptr<SharedConnection> sharedconnection = connect_to_server(0 /* parent window */);
+          auto sharedconnection = connect_to_server(0 /* parent window */);
 
           g_assert(sharedconnection);
 
@@ -882,7 +882,7 @@ void Base_DB::calculate_field(const LayoutFieldInRecord& field_in_record)
           calc_progress_refreshed.m_calc_finished = true;
           calc_progress_refreshed.m_calc_in_progress = false;
 
-          std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+          auto layout_item = std::make_shared<LayoutItem_Field>();
           layout_item->set_full_field_details(field);
 
           //show it:
@@ -1028,7 +1028,7 @@ Gnome::Gda::Value Base_DB::get_field_value_in_database(const LayoutFieldInRecord
   
 
   type_vecConstLayoutFields list_fields;
-  std::shared_ptr<const LayoutItem_Field> layout_item = field_in_record.m_field;
+  auto layout_item = field_in_record.m_field;
   list_fields.push_back(layout_item);
   Glib::RefPtr<Gnome::Gda::SqlBuilder> sql_query = 
Utils::build_sql_select_with_key(field_in_record.m_table_name,
     list_fields, field_in_record.m_key, field_in_record.m_key_value, type_sort_clause(), 1);
@@ -1067,7 +1067,7 @@ Gnome::Gda::Value Base_DB::get_field_value_in_database(const std::shared_ptr<Fie
   }
 
   type_vecConstLayoutFields list_fields;
-  std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+  auto layout_item = std::make_shared<LayoutItem_Field>();
   layout_item->set_full_field_details(field);
   list_fields.push_back(layout_item);
   Glib::RefPtr<Gnome::Gda::SqlBuilder> sql_query = 
Utils::build_sql_select_with_where_clause(found_set.m_table_name,
@@ -1139,7 +1139,7 @@ Base_DB::type_list_const_field_items Base_DB::get_calculated_fields(const Glib::
     //TODO: How do we trigger relcalculation of related fields if necessary?
     for(const auto& field_to_examine : document->get_table_fields(table_name))  //TODO_Performance: Cache 
this?
     {
-      std::shared_ptr<LayoutItem_Field> layoutitem_field_to_examine = std::make_shared<LayoutItem_Field>();
+      auto layoutitem_field_to_examine = std::make_shared<LayoutItem_Field>();
       layoutitem_field_to_examine->set_full_field_details(field_to_examine);
 
       //std::cout << "  debug: examining field=" << field_to_examine->get_name() << std::endl;
@@ -1170,7 +1170,7 @@ Base_DB::type_list_const_field_items Base_DB::get_calculation_fields(const Glib:
 
   type_list_const_field_items result;
 
-  std::shared_ptr<const Field> field = layoutitem_field->get_full_field_details();
+  auto field = layoutitem_field->get_full_field_details();
   if(!field)
     return result;
 
@@ -1198,10 +1198,10 @@ Base_DB::type_list_const_field_items Base_DB::get_calculation_fields(const Glib:
         Glib::ustring::size_type pos_start = pos_find + prefix_size;
         const auto field_name = calculation.substr(pos_start, pos_find_end - pos_start);
 
-        std::shared_ptr<Field> field_found = document->get_field(table_name, field_name);
+        auto field_found = document->get_field(table_name, field_name);
         if(field)
         {
-          std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+          auto layout_item = std::make_shared<LayoutItem_Field>();
           layout_item->set_full_field_details(field_found);
 
           result.push_back(layout_item);
@@ -1253,11 +1253,11 @@ void Base_DB::do_lookups(const LayoutFieldInRecord& field_in_record, const Gtk::
 
      //std::cout << "debug: " << G_STRFUNC << ": item=" << layout_item->get_name() << std::endl;
 
-     std::shared_ptr<const Relationship> relationship = the_pair.second;
-     const std::shared_ptr<const Field> field_lookup = layout_item->get_full_field_details();
+     auto relationship = the_pair.second;
+     const auto field_lookup = layout_item->get_full_field_details();
      if(field_lookup)
      {
-      std::shared_ptr<const Field> field_source = DbUtils::get_fields_for_table_one_field(document, 
relationship->get_to_table(), field_lookup->get_lookup_field());
+      auto field_source = DbUtils::get_fields_for_table_one_field(document, relationship->get_to_table(), 
field_lookup->get_lookup_field());
       if(field_source)
       {
         const auto value = DbUtils::get_lookup_value(document, field_in_record.m_table_name, the_pair.second 
/* relationship */,  field_source /* the field to look in to get the value */, field_value /* Value of to and 
from fields */);
@@ -1348,7 +1348,7 @@ bool Base_DB::get_relationship_exists(const Glib::ustring& table_name, const Gli
   auto document = get_document();
   if(document)
   {
-    std::shared_ptr<Relationship> relationship = document->get_relationship(table_name, relationship_name);
+    auto relationship = document->get_relationship(table_name, relationship_name);
     if(relationship)
       return true;
   }
@@ -1359,7 +1359,7 @@ bool Base_DB::get_relationship_exists(const Glib::ustring& table_name, const Gli
 bool Base_DB::get_primary_key_is_in_foundset(const FoundSet& found_set, const Gnome::Gda::Value& 
primary_key_value)
 {
   //TODO_Performance: This is probably called too often, when we should know that the key is in the found 
set.
-  std::shared_ptr<const Field> primary_key = get_field_primary_key_for_table(found_set.m_table_name);
+  auto primary_key = get_field_primary_key_for_table(found_set.m_table_name);
   if(!primary_key)
   {
     std::cerr << G_STRFUNC << ": No primary key found for table: " << found_set.m_table_name << std::endl;
@@ -1368,7 +1368,7 @@ bool Base_DB::get_primary_key_is_in_foundset(const FoundSet& found_set, const Gn
 
   type_vecLayoutFields fieldsToGet;
 
-  std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+  auto layout_item = std::make_shared<LayoutItem_Field>();
   layout_item->set_full_field_details(primary_key);
   fieldsToGet.push_back(layout_item);
 
@@ -1420,7 +1420,7 @@ void Base_DB::set_found_set_where_clause_for_portal(FoundSet& found_set, const s
   }
 
 
-  std::shared_ptr<const Relationship> relationship = portal->get_relationship();
+  auto relationship = portal->get_relationship();
 
   // Notice that, in the case that this is a portal to doubly-related records,
   // The WHERE clause mentions the first-related table (though by the alias defined in extra_join)
@@ -1429,15 +1429,15 @@ void Base_DB::set_found_set_where_clause_for_portal(FoundSet& found_set, const s
   auto document = get_document();
 
   Glib::ustring where_clause_to_table_name = relationship->get_to_table();
-  std::shared_ptr<Field> where_clause_to_key_field = DbUtils::get_fields_for_table_one_field(document, 
relationship->get_to_table(), relationship->get_to_field());
+  auto where_clause_to_key_field = DbUtils::get_fields_for_table_one_field(document, 
relationship->get_to_table(), relationship->get_to_field());
 
   found_set.m_table_name = portal->get_table_used(Glib::ustring() /* parent table - not relevant */);
 
-  std::shared_ptr<const Relationship> relationship_related = portal->get_related_relationship();
+  auto relationship_related = portal->get_related_relationship();
   if(relationship_related)
   {
     //Add the extra JOIN:
-    std::shared_ptr<UsesRelationship> uses_rel_temp = std::make_shared<UsesRelationship>();
+    auto uses_rel_temp = std::make_shared<UsesRelationship>();
     uses_rel_temp->set_relationship(relationship);
     found_set.m_extra_join = relationship;
 
diff --git a/glom/base_db_table_data.cc b/glom/base_db_table_data.cc
index 35378bb..2f8de86 100644
--- a/glom/base_db_table_data.cc
+++ b/glom/base_db_table_data.cc
@@ -58,7 +58,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
 
   auto document = get_document();
 
-  std::shared_ptr<const Field> fieldPrimaryKey = get_field_primary_key();
+  auto fieldPrimaryKey = get_field_primary_key();
 
   const Glib::ustring primary_key_name = fieldPrimaryKey->get_name();
 
@@ -74,7 +74,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
     const auto iterFind = find_if_same_name(fieldsToAdd, item->get_name());
     if(iterFind == fieldsToAdd.end())
     {
-      std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+      auto layout_item = std::make_shared<LayoutItem_Field>();
       layout_item->set_full_field_details(item);
 
       fieldsToAdd.push_back(layout_item);
@@ -125,7 +125,7 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
 
             //We need the connection when we run the script, so that the script may use it.
             // TODO: Is this function supposed to throw an exception?
-            std::shared_ptr<SharedConnection> sharedconnection = 
connect_to_server(AppWindow::get_appwindow());
+            auto sharedconnection = connect_to_server(AppWindow::get_appwindow());
 
             Glib::ustring error_message; //TODO: Check this.
             value =
@@ -295,7 +295,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const std::shared_ptr<cons
       if(key_is_auto_increment)
       {
         //Set the key in the parent table
-        std::shared_ptr<LayoutItem_Field> item_from_key = std::make_shared<LayoutItem_Field>();
+        auto item_from_key = std::make_shared<LayoutItem_Field>();
         item_from_key->set_name(relationship->get_from_field());
 
         //Show the new from key in the parent table's layout:
@@ -303,7 +303,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const std::shared_ptr<cons
 
         //Set it in the database too:
         auto document = get_document();
-        std::shared_ptr<Field> field_from_key = DbUtils::get_fields_for_table_one_field(document,
+        auto field_from_key = DbUtils::get_fields_for_table_one_field(document,
           relationship->get_from_table(), relationship->get_from_field()); //TODO_Performance.
         if(!field_from_key)
         {
@@ -311,7 +311,7 @@ bool Base_DB_Table_Data::add_related_record_for_field(const std::shared_ptr<cons
           return false;
         }
 
-        std::shared_ptr<Field> parent_primary_key_field = get_field_primary_key();
+        auto parent_primary_key_field = get_field_primary_key();
         if(!parent_primary_key_field)
         {
           std::cerr << G_STRFUNC << ": get_field_primary_key() failed. table = " << get_table_name() << 
std::endl;
@@ -382,7 +382,7 @@ bool Base_DB_Table_Data::confirm_delete_record()
 
 bool Base_DB_Table_Data::record_delete(const Gnome::Gda::Value& primary_key_value)
 {
-  std::shared_ptr<Field> field_primary_key = get_field_primary_key();
+  auto field_primary_key = get_field_primary_key();
   if(field_primary_key && !Conversions::value_is_empty(primary_key_value))
   {
     Glib::RefPtr<Gnome::Gda::SqlBuilder> builder =
@@ -461,7 +461,7 @@ Base_DB_Table_Data::type_vecConstLayoutFields Base_DB_Table_Data::get_related_fi
       if(layout_field->get_has_relationship_name())
       {
         //Get the relationship information:
-        std::shared_ptr<const Relationship> relationship = document->get_relationship(m_table_name, 
layout_field->get_relationship_name());
+        auto relationship = document->get_relationship(m_table_name, layout_field->get_relationship_name());
         if(relationship)
         {
           //If the relationship uses the specified field:
@@ -517,7 +517,7 @@ void Base_DB_Table_Data::refresh_related_fields(const LayoutFieldInRecord& field
         for(guint uiCol = 0; uiCol < cols_count; ++uiCol)
         {
           const auto value = result->get_value_at(uiCol, 0 /* row */);
-          std::shared_ptr<const LayoutItem_Field> layout_item = *iterFields;
+          auto layout_item = *iterFields;
           if(!layout_item)
             std::cerr << G_STRFUNC << ": The layout_item was null." << std::endl;
           else
diff --git a/glom/box_reports.cc b/glom/box_reports.cc
index d4948d6..cc1a21b 100644
--- a/glom/box_reports.cc
+++ b/glom/box_reports.cc
@@ -132,7 +132,7 @@ bool Box_Reports::fill_from_database()
 
 void Box_Reports::on_adddel_Add(const Gtk::TreeModel::iterator& row)
 {
-  std::shared_ptr<Report> report = std::make_shared<Report>();
+  auto report = std::make_shared<Report>();
 
   const auto report_name = m_AddDel.get_value(row, m_colReportName);
   if(!report_name.empty())
@@ -216,7 +216,7 @@ void Box_Reports::on_adddel_changed(const Gtk::TreeModel::iterator& row, guint c
     const auto report_name = m_AddDel.get_value_key(row);
     auto document = get_document();
 
-    std::shared_ptr<Report> report = document->get_report(m_table_name, report_name);
+    auto report = document->get_report(m_table_name, report_name);
     if(report)
     {
       if(column == m_colTitle)
diff --git a/glom/frame_glom.cc b/glom/frame_glom.cc
index 2efd4c5..3f3d300 100644
--- a/glom/frame_glom.cc
+++ b/glom/frame_glom.cc
@@ -372,10 +372,10 @@ void Frame_Glom::show_table_allow_empty(const Glib::ustring& table_name, const G
       //then sort by the ID, just so we sort by something, so that the order is predictable:
       if(found_set.m_sort_clause.empty())
       {
-        std::shared_ptr<Field> field_primary_key = get_field_primary_key_for_table(m_table_name);
+        auto field_primary_key = get_field_primary_key_for_table(m_table_name);
         if(field_primary_key)
         {
-          std::shared_ptr<LayoutItem_Field> layout_item_sort = std::make_shared<LayoutItem_Field>();
+          auto layout_item_sort = std::make_shared<LayoutItem_Field>();
           layout_item_sort->set_full_field_details(field_primary_key);
 
           found_set.m_sort_clause.clear();
@@ -384,7 +384,7 @@ void Frame_Glom::show_table_allow_empty(const Glib::ustring& table_name, const G
           //because that would be too slow.
           //The user can explicitly request a sort later, by clicking on a column header.
           //TODO_Performance: This causes an almost-duplicate COUNT query (we do it in the treemodel too), 
but it's not that slow.
-          std::shared_ptr<LayoutItem_Field> layout_item_temp = std::make_shared<LayoutItem_Field>();
+          auto layout_item_temp = std::make_shared<LayoutItem_Field>();
           layout_item_temp->set_full_field_details(field_primary_key);
           type_vecLayoutFields layout_fields;
           layout_fields.push_back(layout_item_temp);
@@ -461,7 +461,7 @@ bool Frame_Glom::attempt_change_usermode_to_developer()
 
   //Check whether the current user has developer privileges:
   auto connection_pool = ConnectionPool::get_instance();
-      std::shared_ptr<SharedConnection> sharedconnection = connection_pool->connect();
+      auto sharedconnection = connection_pool->connect();
 
   // Default to true; if we don't support users, we always have
   // priviliges to change things in developer mode.
@@ -617,7 +617,7 @@ void Frame_Glom::export_data_to_vector(Document::type_example_rows& the_vector,
         {
           const auto value = result->get_value_at(col_index, row_index);
 
-          std::shared_ptr<const LayoutItem_Field> layout_item = fieldsSequence[col_index];
+          auto layout_item = fieldsSequence[col_index];
           //if(layout_item->m_field.get_glom_type() != Field::glom_field_type::IMAGE) //This is too much 
data.
           //{
 
@@ -667,14 +667,14 @@ void Frame_Glom::export_data_to_stream(std::ostream& the_stream, const FoundSet&
         {
           const auto value = result->get_value_at(col_index, row_index);
 
-          std::shared_ptr<const LayoutItem_Field> layout_item = fieldsSequence[col_index];
+          auto layout_item = fieldsSequence[col_index];
           //if(layout_item->m_field.get_glom_type() != Field::glom_field_type::IMAGE) //This is too much 
data.
           //{
             if(!row_string.empty())
               row_string += ",";
 
             //Output data in canonical SQL format, ignoring the user's locale, and ignoring the layout 
formatting:
-            std::shared_ptr<const Field> field = layout_item->get_full_field_details();
+            auto field = layout_item->get_full_field_details();
             if(!field)
             {
               std::cerr << G_STRFUNC << ": A field was null." << std::endl;
@@ -970,7 +970,7 @@ bool Frame_Glom::attempt_toggle_shared(bool shared)
   if(change)
   {
     auto connectionpool = ConnectionPool::get_instance();
-    std::shared_ptr<SharedConnection> sharedconnection = connectionpool->connect();
+    auto sharedconnection = connectionpool->connect();
     if(sharedconnection)
     {
       sharedconnection->close();
@@ -1175,7 +1175,7 @@ void Frame_Glom::on_dialog_add_related_table_response(int response)
       }
 
       //Create the new relationship:
-      std::shared_ptr<Relationship> relationship = std::make_shared<Relationship>();
+      auto relationship = std::make_shared<Relationship>();
 
       relationship->set_name(relationship_name);
       relationship->set_title(Utils::title_from_string(relationship_name), AppWindow::get_current_locale());
@@ -1183,7 +1183,7 @@ void Frame_Glom::on_dialog_add_related_table_response(int response)
       relationship->set_from_field(from_key_name);
       relationship->set_to_table(table_name);
 
-      std::shared_ptr<Field> related_primary_key = get_field_primary_key_for_table(table_name); //This field 
was created by create_table_with_default_fields().
+      auto related_primary_key = get_field_primary_key_for_table(table_name); //This field was created by 
create_table_with_default_fields().
       if(!related_primary_key)
       {
         std::cerr << G_STRFUNC << ": get_field_primary_key_for_table() failed." << std::endl;
@@ -1458,7 +1458,7 @@ void Frame_Glom::update_table_in_document_from_database()
         {
           //Compare the information:
           Glib::RefPtr<Gnome::Gda::Column> field_info_db = field_database->get_field_info();
-          std::shared_ptr<Field> field_document =  *iterFindDoc;
+          auto field_document =  *iterFindDoc;
           if(field_document)
           {
             if(!field_document->field_info_from_database_is_equal( field_info_db )) //ignores auto_increment 
because libgda does not report it from the database properly.
@@ -1781,7 +1781,7 @@ void Frame_Glom::on_box_reports_selected(const Glib::ustring& report_name)
 {
   m_pDialog_Reports->hide();
 
-  std::shared_ptr<Report> report = get_document()->get_report(m_table_name, report_name);
+  auto report = get_document()->get_report(m_table_name, report_name);
   if(report)
   {
     m_pDialogLayoutReport->set_transient_for(*get_app_window());
@@ -1842,7 +1842,7 @@ void Frame_Glom::on_box_print_layouts_selected(const Glib::ustring& print_layout
 
   m_pDialog_PrintLayouts->hide();
 
-  std::shared_ptr<PrintLayout> print_layout = get_document()->get_print_layout(m_table_name, 
print_layout_name);
+  auto print_layout = get_document()->get_print_layout(m_table_name, print_layout_name);
   if(print_layout)
   {
     m_pDialogLayoutPrint->set_transient_for(*app_window);
@@ -2384,7 +2384,7 @@ void Frame_Glom::on_menu_report_selected(const Glib::ustring& report_name)
   }
 
   auto document = get_document();
-  std::shared_ptr<Report> report = document->get_report(m_table_name, report_name);
+  auto report = document->get_report(m_table_name, report_name);
   if(!report)
     return;
 
@@ -2408,7 +2408,7 @@ void Frame_Glom::on_menu_print_layout_selected(const Glib::ustring& print_layout
 void Frame_Glom::do_print_layout(const Glib::ustring& print_layout_name, bool preview, Gtk::Window* 
transient_for)
 {
   const auto document = get_document();
-  std::shared_ptr<const PrintLayout> print_layout = document->get_print_layout(m_table_name, 
print_layout_name);
+  auto print_layout = document->get_print_layout(m_table_name, print_layout_name);
     
   const auto table_privs = Privs::get_current_privs(m_table_name);
 
@@ -2439,7 +2439,7 @@ void Frame_Glom::on_dialog_layout_report_hide()
   if(document && true) //m_pDialogLayoutReport->get_modified())
   {
     const auto original_name = m_pDialogLayoutReport->get_original_report_name();
-    std::shared_ptr<Report> report = m_pDialogLayoutReport->get_report();
+    auto report = m_pDialogLayoutReport->get_report();
     if(report && (original_name != report->get_name()))
       document->remove_report(m_table_name, original_name);
 
@@ -2459,7 +2459,7 @@ void Frame_Glom::on_dialog_layout_print_hide()
   if(document && true) //m_pDialogLayoutReport->get_modified())
   {
     const auto original_name = m_pDialogLayoutPrint->get_original_name();
-    std::shared_ptr<PrintLayout> print_layout = m_pDialogLayoutPrint->get_print_layout();
+    auto print_layout = m_pDialogLayoutPrint->get_print_layout();
     if(print_layout && (original_name != print_layout->get_name()))
       document->remove_report(m_table_name, original_name);
 
diff --git a/glom/import_csv/dialog_import_csv_progress.cc b/glom/import_csv/dialog_import_csv_progress.cc
index 16bba81..64d3c2c 100644
--- a/glom/import_csv/dialog_import_csv_progress.cc
+++ b/glom/import_csv/dialog_import_csv_progress.cc
@@ -182,7 +182,7 @@ bool Dialog_Import_CSV_Progress::on_idle_import()
   guint col_index = 0;
   for(const auto& str : row)
   {
-    std::shared_ptr<const Field> field = m_data_source->get_field_for_column(col_index++);
+    auto field = m_data_source->get_field_for_column(col_index++);
     if(field)
     {
       // We always assume exported data is in standard CSV format, since
diff --git a/glom/libglom/connectionpool.cc b/glom/libglom/connectionpool.cc
index 8331eff..a6f958d 100644
--- a/glom/libglom/connectionpool.cc
+++ b/glom/libglom/connectionpool.cc
@@ -568,7 +568,7 @@ void ConnectionPool::on_sharedconnection_finished()
 //static
 bool ConnectionPool::handle_error_cerr_only()
 {
-  std::shared_ptr<SharedConnection> sharedconnection = get_and_connect();
+  auto sharedconnection = get_and_connect();
 
   if(sharedconnection)
   {
@@ -787,8 +787,8 @@ bool ConnectionPool::change_columns(const Glib::ustring& table_name, const type_
   auto iter_new = new_fields.begin();
   while( (iter_old != old_fields.end()) && (iter_new != new_fields.end()) )
   {
-    const std::shared_ptr<const Field> field_old = *iter_old;
-    const std::shared_ptr<const Field> field_new = *iter_new;
+    const auto field_old = *iter_old;
+    const auto field_new = *iter_new;
     if(field_old && field_new
       && field_old->get_auto_increment() != field_new->get_auto_increment())
     {
diff --git a/glom/libglom/data_structure/layout/formatting.cc 
b/glom/libglom/data_structure/layout/formatting.cc
index 9ebf470..697a8a1 100644
--- a/glom/libglom/data_structure/layout/formatting.cc
+++ b/glom/libglom/data_structure/layout/formatting.cc
@@ -312,7 +312,7 @@ bool Formatting::change_field_item_name(const Glib::ustring& table_name, const G
   if(!m_choices_related_field)
     return false; //Nothing changed.
 
-  std::shared_ptr<const Relationship> relationship = get_relationship();
+  auto relationship = get_relationship();
   
   const Glib::ustring field_table = 
     m_choices_related_field->get_table_used( relationship->get_to_table() );
diff --git a/glom/libglom/data_structure/layout/layoutgroup.cc 
b/glom/libglom/data_structure/layout/layoutgroup.cc
index c33e24a..63e83c9 100644
--- a/glom/libglom/data_structure/layout/layoutgroup.cc
+++ b/glom/libglom/data_structure/layout/layoutgroup.cc
@@ -189,7 +189,7 @@ LayoutGroup::type_list_const_items LayoutGroup::get_items_recursive() const
 
   for(const auto& item : m_list_items)
   {    
-    std::shared_ptr<const LayoutGroup> group = std::dynamic_pointer_cast<const LayoutGroup>(item);
+    auto group = std::dynamic_pointer_cast<const LayoutGroup>(item);
     if(group)
     {
       const auto sub_result = group->get_items_recursive();
@@ -230,7 +230,7 @@ LayoutGroup::type_list_const_items LayoutGroup::get_items_recursive_with_groups(
     //Add the item itself:
     result.push_back(item);
     
-    std::shared_ptr<const LayoutGroup> group = std::dynamic_pointer_cast<const LayoutGroup>(item);
+    auto group = std::dynamic_pointer_cast<const LayoutGroup>(item);
     if(group)
     {
       const auto sub_result = group->get_items_recursive_with_groups();
@@ -310,7 +310,7 @@ void LayoutGroup::change_related_field_item_name(const Glib::ustring& table_name
     {
       if(field_item->get_has_relationship_name()) //If it's related table.
       {
-        std::shared_ptr<const Relationship> relationship = field_item->get_relationship();
+        auto relationship = field_item->get_relationship();
         if(relationship)
         {
           if(relationship->get_to_table() == table_name)
@@ -335,7 +335,7 @@ void LayoutGroup::change_field_item_name(const Glib::ustring& table_name, const
   //Look at each item:
   for(const auto& item : m_list_items)
   {
-    std::shared_ptr<LayoutItem_Field> field_item = 
+    auto field_item = 
       std::dynamic_pointer_cast<LayoutItem_Field>(item);
     
     //Field layout items:
@@ -343,7 +343,7 @@ void LayoutGroup::change_field_item_name(const Glib::ustring& table_name, const
     {
       if(field_item->get_has_relationship_name()) //If it's a related table (this would be a 
self-relationship)
       {
-        std::shared_ptr<const Relationship> rel = field_item->get_relationship();
+        auto rel = field_item->get_relationship();
         if(rel)
         {
           if(rel->get_to_table() == table_name)
@@ -362,7 +362,7 @@ void LayoutGroup::change_field_item_name(const Glib::ustring& table_name, const
     else
     {
       //Formatting:
-      std::shared_ptr<LayoutItem_WithFormatting> with_formatting = 
+      auto with_formatting = 
         std::dynamic_pointer_cast<LayoutItem_WithFormatting>(item);
       if(with_formatting)
       {
diff --git a/glom/libglom/data_structure/layout/layoutitem_calendarportal.cc 
b/glom/libglom/data_structure/layout/layoutitem_calendarportal.cc
index c53c1f3..d67d1bf 100644
--- a/glom/libglom/data_structure/layout/layoutitem_calendarportal.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_calendarportal.cc
@@ -63,7 +63,7 @@ void LayoutItem_CalendarPortal::change_field_item_name(const Glib::ustring& tabl
 {
   LayoutItem_Portal::change_field_item_name(table_name, field_name, field_name_new);
   
-  std::shared_ptr<const Relationship> relationship = get_relationship();
+  auto relationship = get_relationship();
         
   if(relationship && (relationship->get_to_table() == table_name) && (m_date_field->get_name() == 
field_name))
       m_date_field->set_name(field_name_new); //Change it.
diff --git a/glom/libglom/data_structure/layout/layoutitem_field.cc 
b/glom/libglom/data_structure/layout/layoutitem_field.cc
index 9d0683b..b655e54 100644
--- a/glom/libglom/data_structure/layout/layoutitem_field.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_field.cc
@@ -175,7 +175,7 @@ bool LayoutItem_Field::get_editable_and_allowed() const
   //The relationship might forbid editing of any fields through itself:
   if(get_has_relationship_name())
   {
-    std::shared_ptr<const Relationship> rel = get_relationship();
+    auto rel = get_relationship();
     if(rel)
     {
       if(!(rel->get_allow_edit()))
diff --git a/glom/libglom/data_structure/layout/layoutitem_portal.cc 
b/glom/libglom/data_structure/layout/layoutitem_portal.cc
index 62d9eac..7545502 100644
--- a/glom/libglom/data_structure/layout/layoutitem_portal.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_portal.cc
@@ -95,7 +95,7 @@ void LayoutItem_Portal::change_field_item_name(const Glib::ustring& table_name,
       }
       else
       {
-        std::shared_ptr<const Relationship> relationship = get_relationship();
+        auto relationship = get_relationship();
         if(relationship && (relationship->get_to_table() == table_name) && (field_item->get_name() == 
field_name))
           field_item->set_name(field_name_new); //Change it.
       }
@@ -141,7 +141,7 @@ Glib::ustring LayoutItem_Portal::get_from_table() const
 {
   Glib::ustring from_table;
 
-  std::shared_ptr<const Relationship> relationship = get_relationship();
+  auto relationship = get_relationship();
   if(relationship)
     from_table = relationship->get_from_table();
 
@@ -297,11 +297,11 @@ std::shared_ptr<const UsesRelationship> LayoutItem_Portal::get_portal_navigation
   {
     //If the related table is hidden,
     //then find a suitable related non-hidden table by finding the first layout field that mentions one:
-    std::shared_ptr<const LayoutItem_Field> field = get_field_is_from_non_hidden_related_record(document);
+    auto field = get_field_is_from_non_hidden_related_record(document);
     if(field)
     {
       return field; //Returns the UsesRelationship base part. (A relationship belonging to the portal's 
related table.)
-      //std::shared_ptr<UsesRelationship> result = std::make_shared<UsesRelationship>();
+      //auto result = std::make_shared<UsesRelationship>();
       //result->set_relationship( get_relationship() );
       //result->set_related_relationship( field->get_relationship() );
 
@@ -312,7 +312,7 @@ std::shared_ptr<const UsesRelationship> LayoutItem_Portal::get_portal_navigation
       //Instead, find a key field that's used in a relationship,
       //and pretend that we are showing the to field as a related field:
       std::shared_ptr<const Relationship> used_in_relationship;
-      std::shared_ptr<const LayoutItem_Field> field_identifies = 
get_field_identifies_non_hidden_related_record(used_in_relationship, document);
+      auto field_identifies = get_field_identifies_non_hidden_related_record(used_in_relationship, document);
       if(field_identifies)
       {
         auto result = std::make_shared<UsesRelationship>();
@@ -380,7 +380,7 @@ std::shared_ptr<const LayoutItem_Field> LayoutItem_Portal::get_field_identifies_
     auto field = std::dynamic_pointer_cast<const LayoutItem_Field>(item);
     if(field && !(field->get_has_relationship_name()))
     {
-      std::shared_ptr<const Relationship> relationship = 
document->get_field_used_in_relationship_to_one(parent_table_name, field);
+      auto relationship = document->get_field_used_in_relationship_to_one(parent_table_name, field);
       if(relationship)
       {
         const auto table_name = relationship->get_to_table();
diff --git a/glom/libglom/data_structure/layout/usesrelationship.cc 
b/glom/libglom/data_structure/layout/usesrelationship.cc
index 7f594f8..3689c1d 100644
--- a/glom/libglom/data_structure/layout/usesrelationship.cc
+++ b/glom/libglom/data_structure/layout/usesrelationship.cc
@@ -143,7 +143,7 @@ Glib::ustring UsesRelationship::get_title_used(const Glib::ustring& parent_table
 
 Glib::ustring UsesRelationship::get_title_singular_used(const Glib::ustring& parent_table_title, const 
Glib::ustring& locale) const
 {
-  std::shared_ptr<const Relationship> used = m_related_relationship;
+  auto used = m_related_relationship;
   if(!used)
     used = m_relationship;
 
diff --git a/glom/libglom/db_utils.cc b/glom/libglom/db_utils.cc
index 237e0a3..712a516 100644
--- a/glom/libglom/db_utils.cc
+++ b/glom/libglom/db_utils.cc
@@ -230,7 +230,7 @@ bool recreate_database_from_document(Document* document, const std::function<voi
   try
   {
     connection_pool->set_ready_to_connect(); //This has succeeded already.
-    std::shared_ptr<SharedConnection> sharedconnection = connection_pool->connect();
+    auto sharedconnection = connection_pool->connect();
     std::cerr << G_STRFUNC << ": Failed because database exists already." << std::endl;
 
     return false; //Connection to the database succeeded, because no exception was thrown. so the database 
exists already.
@@ -474,7 +474,7 @@ bool add_standard_tables(const Document* document)
   try
   {
     Document::type_vec_fields pref_fields;
-    std::shared_ptr<TableInfo> prefs_table_info = Document::create_table_system_preferences(pref_fields);
+    auto prefs_table_info = Document::create_table_system_preferences(pref_fields);
 
     //Name, address, etc:
     if(!get_table_exists_in_database(GLOM_STANDARD_TABLE_PREFS_TABLE_NAME))
@@ -940,7 +940,7 @@ type_vec_fields get_fields_for_table_from_database(const Glib::ustring& table_na
           field_info->set_allow_null(value_notnull.get_boolean());
 
 
-        std::shared_ptr<Field> field = std::make_shared<Field>(); //TODO: Get glom-specific information from 
the document?
+        auto field = std::make_shared<Field>(); //TODO: Get glom-specific information from the document?
         field->set_field_info(field_info);
 
 
@@ -1222,7 +1222,7 @@ bool create_table(Document::HostingMode hosting_mode, const std::shared_ptr<cons
   //(We don't actually use this yet)
   if(find_if_same_name_exists(fields, GLOM_STANDARD_FIELD_LOCK))
   {
-    std::shared_ptr<Field> field = std::make_shared<Field>();
+    auto field = std::make_shared<Field>();
     field->set_name(GLOM_STANDARD_FIELD_LOCK);
     field->set_glom_type(Field::glom_field_type::TEXT);
     fields.push_back(field);
@@ -1614,7 +1614,7 @@ bool insert_example_data(const Document* document, const Glib::ustring& table_na
     {
       //std::cout << "  DEBUG: i=" << i << ", row_data.size()=" << row_data.size() << std::endl;
 
-      std::shared_ptr<Field> field = vec_fields[i];
+      auto field = vec_fields[i];
       if(!field)
       {
         std::cerr << G_STRFUNC << ": field was null for field num=" << i << std::endl;
@@ -1885,14 +1885,14 @@ bool layout_field_should_have_navigation(const Glib::ustring& table_name, const
 
   //Check whether the field controls a relationship,
   //meaning it identifies a record in another table.
-  std::shared_ptr<const Relationship> const_relationship =
+  auto const_relationship =
     document->get_field_used_in_relationship_to_one(table_name, layout_item);
   field_used_in_relationship_to_one = std::const_pointer_cast<Relationship>(const_relationship); //This is 
just because we can't seem to have a std::shared_ptr<const Relationship>& output parameter.
   // std::cout << "DEBUG: table_name=" << table_name << ", table_used=" << 
layout_item->get_table_used(table_name) << ", layout_item=" << layout_item->get_name() << ", 
field_used_in_relationship_to_one=" << field_used_in_relationship_to_one << std::endl;
 
   //Check whether the field identifies a record in another table
   //just because it is a primary key in that table:
-  const std::shared_ptr<const Field> field_info = layout_item->get_full_field_details();
+  const auto field_info = layout_item->get_full_field_details();
   const bool field_is_related_primary_key =
     layout_item->get_has_relationship_name() &&
     field_info && field_info->get_primary_key();
@@ -2252,7 +2252,7 @@ Gnome::Gda::Value get_lookup_value(const Document* document, const Glib::ustring
 {
   Gnome::Gda::Value result;
 
-  std::shared_ptr<Field> to_key_field = get_fields_for_table_one_field(document, 
relationship->get_to_table(), relationship->get_to_field());
+  auto to_key_field = get_fields_for_table_one_field(document, relationship->get_to_table(), 
relationship->get_to_field());
   if(to_key_field)
   {
     //Convert the value, in case the from and to fields have different types:
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index a3f9d3a..b31e579 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -604,7 +604,7 @@ std::shared_ptr<Relationship> Document::get_relationship(const Glib::ustring& ta
     return create_relationship_system_preferences(table_name);
   }
 
-  const std::shared_ptr<const DocumentTableInfo> info = get_table_info(table_name);
+  const auto info = get_table_info(table_name);
   if(info)
   {
     //Look for the relationship with this name:
@@ -851,7 +851,7 @@ Document::type_vec_fields Document::get_table_fields(const Glib::ustring& table_
 
   if(!table_name.empty())
   {
-    const std::shared_ptr<const DocumentTableInfo> info = get_table_info(table_name);
+    const auto info = get_table_info(table_name);
     if(info)
     {
       if(info->m_fields.empty())
@@ -1148,7 +1148,7 @@ Document::type_listConstTableInfo Document::get_tables(bool plus_system_prefs) c
 
   for(const auto& table_pair : m_tables)
   {
-    const std::shared_ptr<const DocumentTableInfo> doctableinfo = table_pair.second;
+    const auto doctableinfo = table_pair.second;
     if(doctableinfo)
       result.push_back(doctableinfo->m_info);
 
@@ -1203,7 +1203,7 @@ std::vector<Glib::ustring> Document::get_table_names(bool plus_system_prefs) con
 
 std::shared_ptr<TableInfo> Document::get_table(const Glib::ustring& table_name) const
 {
-  const std::shared_ptr<const DocumentTableInfo> doctableinfo = get_table_info(table_name);
+  const auto doctableinfo = get_table_info(table_name);
   if(doctableinfo)
     return doctableinfo->m_info;
 
@@ -1227,7 +1227,7 @@ void Document::add_table(const std::shared_ptr<TableInfo>& table_info)
 
 bool Document::get_table_overview_position(const Glib::ustring& table_name, float& x, float& y) const
 {
-  const std::shared_ptr<const DocumentTableInfo> doctableinfo = get_table_info(table_name);
+  const auto doctableinfo = get_table_info(table_name);
   if(doctableinfo)
   {
     if( doctableinfo->m_overviewx == std::numeric_limits<float>::infinity() ||
@@ -1268,7 +1268,7 @@ void Document::set_tables(const type_listTableInfo& tables)
     if(!doctableinfo)
       continue;
 
-    std::shared_ptr<TableInfo> info = doctableinfo->m_info;
+    auto info = doctableinfo->m_info;
     if(!info)
       continue;
 
@@ -1278,7 +1278,7 @@ void Document::set_tables(const type_listTableInfo& tables)
     auto iterfind = find_if_same_name(tables, table_name);
     if(iterfind != tables.end())
     {
-      std::shared_ptr<TableInfo> infoFound = *iterfind;
+      auto infoFound = *iterfind;
       if(infoFound && (*infoFound != *info))
       {
         *info = *infoFound;
@@ -1296,7 +1296,7 @@ void Document::fill_sort_field_details(const Glib::ustring& parent_table_name, F
 {
   for(const auto& sort_pair : sort_fields)
   {
-    std::shared_ptr<const LayoutItem_Field> sort_field = sort_pair.first;
+    auto sort_field = sort_pair.first;
     if(!sort_field)
      continue;
  
@@ -1317,7 +1317,7 @@ void Document::fill_layout_field_details(const Glib::ustring& parent_table_name,
   for(const auto& layout_item : layout_group->m_list_items)
   {
     //Check custom Field Formatting:
-    std::shared_ptr<LayoutItem_WithFormatting> layout_withformatting = 
+    auto layout_withformatting = 
       std::dynamic_pointer_cast<LayoutItem_WithFormatting>(layout_item);
     if(layout_withformatting)
     {
@@ -1512,7 +1512,7 @@ Document::type_list_layout_groups Document::get_data_layout_groups(const Glib::u
 {
   //std::cout << "debug: " << G_STRFUNC << ": layout_name=" << layout_name << ", parent_table_name=" << 
parent_table_name << ", layout_platform=" << layout_platform << std::endl;
 
-  const std::shared_ptr<const DocumentTableInfo> info = get_table_info(parent_table_name);
+  const auto info = get_table_info(parent_table_name);
   if(info)
   {
     const DocumentTableInfo::type_layouts layouts = info->m_layouts;
@@ -1588,7 +1588,7 @@ std::shared_ptr<const Document::DocumentTableInfo> Document::get_table_info(cons
 
 std::shared_ptr<Document::DocumentTableInfo> Document::get_table_info_with_add(const Glib::ustring& 
table_name)
 {
-  std::shared_ptr<DocumentTableInfo>  doctableinfo = get_table_info(table_name);
+  auto  doctableinfo = get_table_info(table_name);
   if(doctableinfo)
   {
     return doctableinfo;
@@ -1604,7 +1604,7 @@ std::shared_ptr<Document::DocumentTableInfo> Document::get_table_info_with_add(c
 
 Glib::ustring Document::get_table_title(const Glib::ustring& table_name, const Glib::ustring& locale) const
 {
-  const std::shared_ptr<const DocumentTableInfo> doctableinfo = get_table_info(table_name);
+  const auto doctableinfo = get_table_info(table_name);
   if(doctableinfo && doctableinfo->m_info)
     return doctableinfo->m_info->get_title(locale);
 
@@ -1613,7 +1613,7 @@ Glib::ustring Document::get_table_title(const Glib::ustring& table_name, const G
 
 Glib::ustring Document::get_table_title_original(const Glib::ustring& table_name) const
 {
-  const std::shared_ptr<const DocumentTableInfo> doctableinfo = get_table_info(table_name);
+  const auto doctableinfo = get_table_info(table_name);
   if(doctableinfo && doctableinfo->m_info)
     return doctableinfo->m_info->get_title_original();
 
@@ -1622,7 +1622,7 @@ Glib::ustring Document::get_table_title_original(const Glib::ustring& table_name
 
 Glib::ustring Document::get_table_title_singular(const Glib::ustring& table_name, const Glib::ustring& 
locale) const
 {
-  const std::shared_ptr<const DocumentTableInfo> doctableinfo = get_table_info(table_name);
+  const auto doctableinfo = get_table_info(table_name);
   if(doctableinfo && doctableinfo->m_info)
     return doctableinfo->m_info->get_title_singular_with_fallback(locale);
 
@@ -1631,7 +1631,7 @@ Glib::ustring Document::get_table_title_singular(const Glib::ustring& table_name
 
 Glib::ustring Document::get_table_title_singular_original(const Glib::ustring& table_name) const
 {
-  const std::shared_ptr<const DocumentTableInfo> doctableinfo = get_table_info(table_name);
+  const auto doctableinfo = get_table_info(table_name);
   if(doctableinfo && doctableinfo->m_info)
     return doctableinfo->m_info->get_title_singular_original();
 
@@ -1669,7 +1669,7 @@ void Document::set_table_example_data(const Glib::ustring& table_name, const typ
 //TODO: Avoid doing this all in one go, because that leaves all the data in memory at once.
 Document::type_example_rows Document::get_table_example_data(const Glib::ustring& table_name) const
 {
-  const std::shared_ptr<const DocumentTableInfo> doctableinfo = get_table_info(table_name);
+  const auto doctableinfo = get_table_info(table_name);
   if(doctableinfo)
    return doctableinfo->m_example_rows;
 
@@ -1684,7 +1684,7 @@ bool Document::get_table_is_known(const Glib::ustring& table_name) const
 
 bool Document::get_table_is_hidden(const Glib::ustring& table_name) const
 {
-  const std::shared_ptr<const DocumentTableInfo> doctableinfo = get_table_info(table_name);
+  const auto doctableinfo = get_table_info(table_name);
   if(doctableinfo && doctableinfo->m_info)
       return doctableinfo->m_info->get_hidden();
 
@@ -1775,11 +1775,11 @@ Glib::ustring Document::get_default_table() const
 {
   for(const auto& table_pair : m_tables)
   {
-    const std::shared_ptr<const DocumentTableInfo> doctableinfo = table_pair.second;
+    const auto doctableinfo = table_pair.second;
     if(!doctableinfo)
       continue;
 
-    const std::shared_ptr<const TableInfo> info = doctableinfo->m_info;
+    const auto info = doctableinfo->m_info;
     if(info && info->get_default())
       return info->get_name();
   }
@@ -1789,7 +1789,7 @@ Glib::ustring Document::get_default_table() const
   {
     auto iter = m_tables.begin();
 
-    const std::shared_ptr<const DocumentTableInfo> doctableinfo = iter->second;
+    const auto doctableinfo = iter->second;
     if(doctableinfo && doctableinfo->m_info)
       return doctableinfo->m_info->get_name();
   }
@@ -1803,7 +1803,7 @@ Glib::ustring Document::get_first_table() const
     return Glib::ustring();
 
   auto iter = m_tables.begin();
-  const std::shared_ptr<const DocumentTableInfo> doctableinfo = iter->second;
+  const auto doctableinfo = iter->second;
   if(doctableinfo && doctableinfo->m_info)
     return doctableinfo->m_info->get_name();
 
@@ -1968,7 +1968,7 @@ void Document::load_after_layout_item_formatting(const xmlpp::Element* element,
               //Discover the field type, so we can interpret the text as a value.
               //Not all calling functions know this, so they don't all supply the correct value.
               //TODO_Performance.
-              const std::shared_ptr<const Field> field_temp = get_field(table_name, field_name);
+              const auto field_temp = get_field(table_name, field_name);
               if(field_temp)
                 field_type = field_temp->get_glom_type();
             }
@@ -1988,7 +1988,7 @@ void Document::load_after_layout_item_formatting(const xmlpp::Element* element,
     const auto relationship_name = XmlUtils::get_node_attribute_value(element, 
GLOM_ATTRIBUTE_FORMAT_CHOICES_RELATED_RELATIONSHIP);
     if(!relationship_name.empty())
     {
-      std::shared_ptr<const Relationship> relationship = get_relationship(table_name, relationship_name);
+      auto relationship = get_relationship(table_name, relationship_name);
 
       auto show_all = XmlUtils::get_node_attribute_value_as_bool(element, 
GLOM_ATTRIBUTE_FORMAT_CHOICES_RELATED_SHOW_ALL);
       if(get_document_format_version() < 6)
@@ -2091,7 +2091,7 @@ void Document::load_after_layout_item_field(const xmlpp::Element* element, const
   load_after_layout_item_usesrelationship(element, table_name, item);
 
   //Needed to decide what formatting to load/save:
-  const std::shared_ptr<const Field> field = get_field(item->get_table_used(table_name), name);
+  const auto field = get_field(item->get_table_used(table_name), name);
   
   // This is not unusual, because tables often refer to tables that have not been loaded yet.
   // Code should sometimes check this before returning the layout items.
@@ -2158,7 +2158,7 @@ void Document::load_after_layout_group(const xmlpp::Element* node, const Glib::u
   group->set_border_width( XmlUtils::get_node_attribute_value_as_decimal_double(node, 
GLOM_ATTRIBUTE_BORDER_WIDTH) );
 
   //Translations:
-  std::shared_ptr<LayoutGroup> temp = group;
+  auto temp = group;
   load_after_translations(node, temp);
 
   //Get the child items:
@@ -2483,7 +2483,7 @@ void Document::load_after_translations(const xmlpp::Element* element, const std:
   }
 
   //If it has a singular title, then load that too:
-  const std::shared_ptr<HasTitleSingular> has_title_singular =
+  const auto has_title_singular =
      std::dynamic_pointer_cast<HasTitleSingular>(item);
   if(has_title_singular)
   {
@@ -2517,7 +2517,7 @@ void Document::load_after_choicevalue(const xmlpp::Element* element, const std::
   const auto value = XmlUtils::get_node_attribute_value_as_value(element, GLOM_ATTRIBUTE_VALUE, field_type);
   item->set_value(value);
 
-  std::shared_ptr<ChoiceValue> nonconst_item = item; //TODO: Avoid this.
+  auto nonconst_item = item; //TODO: Avoid this.
   load_after_translations(element, nonconst_item);
 }
 
@@ -2711,7 +2711,7 @@ bool Document::load_after(int& failure_code)
                 if(nodeLookup)
                 {
                   const auto lookup_relationship_name = XmlUtils::get_node_attribute_value(nodeLookup, 
GLOM_ATTRIBUTE_RELATIONSHIP_NAME);
-                  std::shared_ptr<Relationship> lookup_relationship = get_relationship(table_name, 
lookup_relationship_name);
+                  auto lookup_relationship = get_relationship(table_name, lookup_relationship_name);
                   field->set_lookup_relationship(lookup_relationship);
 
                   field->set_lookup_field( XmlUtils::get_node_attribute_value(nodeLookup, 
GLOM_ATTRIBUTE_FIELD) );
@@ -2783,7 +2783,7 @@ bool Document::load_after(int& failure_code)
                       // consider a map to find the column more quickly.
                       for(unsigned int i = 0; i < doctableinfo->m_fields.size(); ++i)
                       {
-                        std::shared_ptr<const Field> field = doctableinfo->m_fields[i];
+                        auto field = doctableinfo->m_fields[i];
                         //std::cout << "  DEBUG: searching: field i=" << i << " =" << field->get_name() << 
std::endl;
                         if(field && (field->get_name() == column_name->get_value()))
                         {
@@ -2890,7 +2890,7 @@ bool Document::load_after(int& failure_code)
                     const auto node_layout_group = dynamic_cast<const xmlpp::Element*>(item_group);
                     if(node_layout_group)
                     {
-                      std::shared_ptr<LayoutGroup> group = report->get_layout_group();
+                      auto group = report->get_layout_group();
                       group->remove_all_items();
                       load_after_layout_group(node_layout_group, table_name, group);
 
@@ -2975,7 +2975,7 @@ bool Document::load_after(int& failure_code)
                     const auto node_layout_group = dynamic_cast<const xmlpp::Element*>(item_group);
                     if(node_layout_group)
                     {
-                      std::shared_ptr<LayoutGroup> group = print_layout->get_layout_group();
+                      auto group = print_layout->get_layout_group();
                       group->remove_all_items();
                       load_after_layout_group(node_layout_group, table_name, group, true /* load positions 
too. */);
 
@@ -3082,7 +3082,7 @@ void Document::save_before_layout_item_formatting(xmlpp::Element* nodeItem, cons
 
   const Formatting& format = layout_item->m_formatting;
 
-  std::shared_ptr<const LayoutItem_Field> field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(layout_item);
+  auto field = std::dynamic_pointer_cast<const LayoutItem_Field>(layout_item);
 
   Field::glom_field_type field_type = Field::glom_field_type::INVALID;
   if(field)
@@ -3203,7 +3203,7 @@ void Document::save_before_layout_item_field(xmlpp::Element* nodeItem, const std
 
   XmlUtils::set_node_attribute_value_as_bool(nodeItem, 
GLOM_ATTRIBUTE_DATA_LAYOUT_ITEM_FIELD_USE_DEFAULT_FORMATTING, field->get_formatting_use_default());
 
-  std::shared_ptr<const CustomTitle> custom_title = field->get_title_custom();
+  auto custom_title = field->get_title_custom();
   if(custom_title)
   {
     auto elementCustomTitle = nodeItem->add_child_element(GLOM_NODE_LAYOUT_ITEM_CUSTOM_TITLE);
@@ -3220,7 +3220,7 @@ void Document::save_before_sort_by(xmlpp::Element* node, const LayoutItem_GroupB
 
   for(const auto& field_pair : list_fields)
   {
-    std::shared_ptr<const LayoutItem_Field> field = field_pair.first;
+    auto field = field_pair.first;
 
     auto nodeChild = node->add_child_element(GLOM_NODE_DATA_LAYOUT_ITEM_FIELD);
     save_before_layout_item_field(nodeChild, field);
@@ -3238,7 +3238,7 @@ void Document::save_before_layout_group(xmlpp::Element* node, const std::shared_
 
   xmlpp::Element* child = nullptr;
 
-  std::shared_ptr<const LayoutItem_GroupBy> group_by = std::dynamic_pointer_cast<const 
LayoutItem_GroupBy>(group);
+  auto group_by = std::dynamic_pointer_cast<const LayoutItem_GroupBy>(group);
   if(group_by) //If it is a GroupBy report part.
   {
     child = node->add_child_element(GLOM_NODE_DATA_LAYOUT_ITEM_GROUPBY);
@@ -3265,7 +3265,7 @@ void Document::save_before_layout_group(xmlpp::Element* node, const std::shared_
   }
   else
   {
-    std::shared_ptr<const LayoutItem_Summary> summary = std::dynamic_pointer_cast<const 
LayoutItem_Summary>(group);
+    auto summary = std::dynamic_pointer_cast<const LayoutItem_Summary>(group);
     if(summary) //If it is a GroupBy report part.
     {
       child = node->add_child_element(GLOM_NODE_DATA_LAYOUT_ITEM_SUMMARY);
@@ -3273,35 +3273,35 @@ void Document::save_before_layout_group(xmlpp::Element* node, const std::shared_
     }
     else
     {
-      std::shared_ptr<const LayoutItem_VerticalGroup> verticalgroup = std::dynamic_pointer_cast<const 
LayoutItem_VerticalGroup>(group);
+      auto verticalgroup = std::dynamic_pointer_cast<const LayoutItem_VerticalGroup>(group);
       if(verticalgroup) //If it is a GroupBy report part.
       {
         child = node->add_child_element(GLOM_NODE_DATA_LAYOUT_ITEM_VERTICALGROUP);
       }
       else
       {
-        std::shared_ptr<const LayoutItem_Header> headerGroup = std::dynamic_pointer_cast<const 
LayoutItem_Header>(group);
+        auto headerGroup = std::dynamic_pointer_cast<const LayoutItem_Header>(group);
         if(headerGroup) //If it is a GroupBy report part.
         {
           child = node->add_child_element(GLOM_NODE_DATA_LAYOUT_ITEM_HEADER);
         }
         else
         {
-          std::shared_ptr<const LayoutItem_Footer> footerGroup = std::dynamic_pointer_cast<const 
LayoutItem_Footer>(group);
+          auto footerGroup = std::dynamic_pointer_cast<const LayoutItem_Footer>(group);
           if(footerGroup) //If it is a GroupBy report part.
           {
             child = node->add_child_element(GLOM_NODE_DATA_LAYOUT_ITEM_FOOTER);
           }
           else
           {
-            std::shared_ptr<const LayoutItem_Portal> portal = std::dynamic_pointer_cast<const 
LayoutItem_Portal>(group);
+            auto portal = std::dynamic_pointer_cast<const LayoutItem_Portal>(group);
             if(portal) //If it is a related records portal
             {
-              std::shared_ptr<const LayoutItem_CalendarPortal> calendar_portal = 
std::dynamic_pointer_cast<const LayoutItem_CalendarPortal>(portal);
+              auto calendar_portal = std::dynamic_pointer_cast<const LayoutItem_CalendarPortal>(portal);
               if(calendar_portal)
               {
                 child = node->add_child_element(GLOM_NODE_DATA_LAYOUT_CALENDAR_PORTAL);
-                std::shared_ptr<const Field> date_field = calendar_portal->get_date_field();
+                auto date_field = calendar_portal->get_date_field();
                 if(date_field)
                   XmlUtils::set_node_attribute_value(child, GLOM_ATTRIBUTE_PORTAL_CALENDAR_DATE_FIELD, 
date_field->get_name());
               }
@@ -3368,7 +3368,7 @@ void Document::save_before_layout_group(xmlpp::Element* node, const std::shared_
             }
             else
             {
-              std::shared_ptr<const LayoutItem_Notebook> notebook = std::dynamic_pointer_cast<const 
LayoutItem_Notebook>(group);
+              auto notebook = std::dynamic_pointer_cast<const LayoutItem_Notebook>(group);
               if(notebook) //If it is a notebook.
               {
                 child = node->add_child_element(GLOM_NODE_DATA_LAYOUT_NOTEBOOK);
@@ -3405,7 +3405,7 @@ void Document::save_before_layout_group(xmlpp::Element* node, const std::shared_
   {
     //g_warning("save_before_layout_group: child part type=%s", item->get_part_type_name().c_str());
 
-    std::shared_ptr<const LayoutGroup> child_group = std::dynamic_pointer_cast<const LayoutGroup>(item);
+    auto child_group = std::dynamic_pointer_cast<const LayoutGroup>(item);
     if(child_group) //If it is a group, portal, summary, or groupby.
     {
       //recurse:
@@ -3415,7 +3415,7 @@ void Document::save_before_layout_group(xmlpp::Element* node, const std::shared_
     {
       xmlpp::Element* nodeItem = nullptr;
 
-      std::shared_ptr<const LayoutItem_FieldSummary> fieldsummary = std::dynamic_pointer_cast<const 
LayoutItem_FieldSummary>(item);
+      auto fieldsummary = std::dynamic_pointer_cast<const LayoutItem_FieldSummary>(item);
       if(fieldsummary) //If it is a summaryfield
       {
         nodeItem = child->add_child_element(GLOM_NODE_DATA_LAYOUT_ITEM_FIELDSUMMARY);
@@ -3424,7 +3424,7 @@ void Document::save_before_layout_group(xmlpp::Element* node, const std::shared_
       }
       else
       {
-        std::shared_ptr<const LayoutItem_Field> field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(item);
+        auto field = std::dynamic_pointer_cast<const LayoutItem_Field>(item);
         if(field) //If it is a field
         {
           nodeItem = child->add_child_element(GLOM_NODE_DATA_LAYOUT_ITEM_FIELD);
@@ -3432,7 +3432,7 @@ void Document::save_before_layout_group(xmlpp::Element* node, const std::shared_
         }
         else
         {
-          std::shared_ptr<const LayoutItem_Button> button = std::dynamic_pointer_cast<const 
LayoutItem_Button>(item);
+          auto button = std::dynamic_pointer_cast<const LayoutItem_Button>(item);
           if(button) //If it is a button
           {
             nodeItem = child->add_child_element(GLOM_NODE_DATA_LAYOUT_BUTTON);
@@ -3441,7 +3441,7 @@ void Document::save_before_layout_group(xmlpp::Element* node, const std::shared_
           }
           else
           {
-            std::shared_ptr<const LayoutItem_Text> textobject = std::dynamic_pointer_cast<const 
LayoutItem_Text>(item);
+            auto textobject = std::dynamic_pointer_cast<const LayoutItem_Text>(item);
             if(textobject) //If it is a text object.
             {
               nodeItem = child->add_child_element(GLOM_NODE_DATA_LAYOUT_TEXTOBJECT);
@@ -3453,7 +3453,7 @@ void Document::save_before_layout_group(xmlpp::Element* node, const std::shared_
             }
             else
             {
-              std::shared_ptr<const LayoutItem_Image> imageobject = std::dynamic_pointer_cast<const 
LayoutItem_Image>(item);
+              auto imageobject = std::dynamic_pointer_cast<const LayoutItem_Image>(item);
               if(imageobject) //If it is an image object.
               {
                 nodeItem = child->add_child_element(GLOM_NODE_DATA_LAYOUT_IMAGEOBJECT);
@@ -3464,7 +3464,7 @@ void Document::save_before_layout_group(xmlpp::Element* node, const std::shared_
               }
               else
               {
-                std::shared_ptr<const LayoutItem_Line> line = std::dynamic_pointer_cast<const 
LayoutItem_Line>(item);
+                auto line = std::dynamic_pointer_cast<const LayoutItem_Line>(item);
                 if(line) //If it is a line
                 {
                   nodeItem = child->add_child_element(GLOM_NODE_DATA_LAYOUT_LINE);
@@ -3494,7 +3494,7 @@ void Document::save_before_layout_group(xmlpp::Element* node, const std::shared_
         if(nodeItem)
         {
           //Save formatting for any layout items that use it:
-        std::shared_ptr<const LayoutItem_WithFormatting> withformatting = std::dynamic_pointer_cast<const 
LayoutItem_WithFormatting>(item);
+        auto withformatting = std::dynamic_pointer_cast<const LayoutItem_WithFormatting>(item);
           if(withformatting)
           {
             auto elementFormat = nodeItem->add_child_element(GLOM_NODE_FORMAT);
@@ -3523,7 +3523,7 @@ void Document::save_before_translations(xmlpp::Element* element, const std::shar
   if(!element)
     return;
 
-  const std::shared_ptr<const ChoiceValue> choicevalue = std::dynamic_pointer_cast<const ChoiceValue>(item);
+  const auto choicevalue = std::dynamic_pointer_cast<const ChoiceValue>(item);
   if(!choicevalue) //This item does not use the title, but uses the title translations to translate its 
value, if it is of type text.
   {
     XmlUtils::set_node_attribute_value(element, GLOM_ATTRIBUTE_TITLE, item->get_title_original());
@@ -3543,7 +3543,7 @@ void Document::save_before_translations(xmlpp::Element* element, const std::shar
   }
 
   //If it has a singular title, then save that too:
-  const std::shared_ptr<const HasTitleSingular> has_title_singular =
+  const auto has_title_singular =
     std::dynamic_pointer_cast<const HasTitleSingular>(item);
   if(has_title_singular && has_title_singular->m_title_singular
     && !(has_title_singular->m_title_singular->get_title_original().empty()))
@@ -3659,7 +3659,7 @@ bool Document::save_before()
     //Add tables:
   for(const auto& table_pair : m_tables)
     {
-      const std::shared_ptr<const DocumentTableInfo> doctableinfo = table_pair.second;
+      const auto doctableinfo = table_pair.second;
       if(!doctableinfo || !doctableinfo->m_info)
         continue;
 
@@ -3689,7 +3689,7 @@ bool Document::save_before()
               const auto row_data_size = row_data.size();
               for(unsigned int i = 0; i < row_data_size; ++i)
               {
-                std::shared_ptr<const Field> field = doctableinfo->m_fields[i];
+                auto field = doctableinfo->m_fields[i];
                 if(!field)
                   break;
 
@@ -3734,7 +3734,7 @@ bool Document::save_before()
           {
             auto elemFieldLookup = elemField->add_child_element(GLOM_NODE_FIELD_LOOKUP);
 
-            std::shared_ptr<Relationship> lookup_relationship = field->get_lookup_relationship();
+            auto lookup_relationship = field->get_lookup_relationship();
             XmlUtils::set_node_attribute_value(elemFieldLookup, GLOM_ATTRIBUTE_RELATIONSHIP_NAME, 
glom_get_sharedptr_name(lookup_relationship));
 
             XmlUtils::set_node_attribute_value(elemFieldLookup, GLOM_ATTRIBUTE_FIELD, 
field->get_lookup_field());
@@ -3797,7 +3797,7 @@ bool Document::save_before()
         {
           auto nodeReport = nodeReports->add_child_element(GLOM_NODE_REPORT);
 
-          std::shared_ptr<const Report> report = report_pair.second;
+          auto report = report_pair.second;
           XmlUtils::set_node_attribute_value(nodeReport, GLOM_ATTRIBUTE_NAME, report->get_name());
           XmlUtils::set_node_attribute_value_as_bool(nodeReport, GLOM_ATTRIBUTE_REPORT_SHOW_TABLE_TITLE, 
report->get_show_table_title());
 
@@ -4006,7 +4006,7 @@ void Document::remove_group(const Glib::ustring& group_name)
 
 std::vector<Glib::ustring> Document::get_report_names(const Glib::ustring& table_name) const
 {
-  const std::shared_ptr<const DocumentTableInfo> info = get_table_info(table_name);
+  const auto info = get_table_info(table_name);
   if(info)
   {
     std::vector<Glib::ustring> result;
@@ -4033,7 +4033,7 @@ void Document::set_report(const Glib::ustring& table_name, const std::shared_ptr
 
 std::shared_ptr<Report> Document::get_report(const Glib::ustring& table_name, const Glib::ustring& 
report_name) const
 {
-  const std::shared_ptr<const DocumentTableInfo> info = get_table_info(table_name);
+  const auto info = get_table_info(table_name);
   if(info)
   {
     const auto iterFindReport = info->m_reports.find(report_name);
@@ -4064,7 +4064,7 @@ void Document::remove_report(const Glib::ustring& table_name, const Glib::ustrin
 
 std::vector<Glib::ustring> Document::get_print_layout_names(const Glib::ustring& table_name) const
 {
-  const std::shared_ptr<const DocumentTableInfo> info = get_table_info(table_name);
+  const auto info = get_table_info(table_name);
   if(info)
   {
     std::vector<Glib::ustring> result;
@@ -4092,7 +4092,7 @@ void Document::set_print_layout(const Glib::ustring& table_name, const std::shar
 
 std::shared_ptr<PrintLayout> Document::get_print_layout(const Glib::ustring& table_name, const 
Glib::ustring& print_layout_name) const
 {
-  const std::shared_ptr<const DocumentTableInfo> info = get_table_info(table_name);
+  const auto info = get_table_info(table_name);
   if(info)
   {
     const auto iterFindPrintLayout = info->m_print_layouts.find(print_layout_name);
@@ -4124,10 +4124,10 @@ void Document::remove_print_layout(const Glib::ustring& table_name, const Glib::
 
 bool Document::get_relationship_is_to_one(const Glib::ustring& table_name, const Glib::ustring& 
relationship_name) const
 {
-  std::shared_ptr<const Relationship> relationship = get_relationship(table_name, relationship_name);
+  auto relationship = get_relationship(table_name, relationship_name);
   if(relationship)
   {
-    std::shared_ptr<const Field> field_to = get_field(relationship->get_to_table(), 
relationship->get_to_field());
+    auto field_to = get_field(relationship->get_to_table(), relationship->get_to_field());
     if(field_to)
       return (field_to->get_primary_key() || field_to->get_unique_key());
   }
@@ -4146,7 +4146,7 @@ std::shared_ptr<const Relationship> Document::get_field_used_in_relationship_to_
   }
 
   const auto table_used = layout_field->get_table_used(table_name);
-  const std::shared_ptr<const DocumentTableInfo> table_info = get_table_info(table_used);
+  const auto table_info = get_table_info(table_used);
   if(!table_info)
   {
     //This table is special. We would not create a relationship to it using a field:
@@ -4198,7 +4198,7 @@ void Document::set_layout_record_viewed(const Glib::ustring& table_name, const G
 
 Gnome::Gda::Value Document::get_layout_record_viewed(const Glib::ustring& table_name, const Glib::ustring& 
layout_name) const
 {
-  const std::shared_ptr<const DocumentTableInfo> info = get_table_info(table_name);
+  const auto info = get_table_info(table_name);
   if(info)
   {
     const auto iterLayoutKeys = info->m_map_current_record.find(layout_name);
@@ -4225,7 +4225,7 @@ void Document::set_criteria_current(const Glib::ustring& table_name, const Found
 
 Glib::ustring Document::get_layout_current(const Glib::ustring& table_name) const
 {
-  const std::shared_ptr<const DocumentTableInfo> info = get_table_info(table_name);
+  const auto info = get_table_info(table_name);
   if(info)
     return info->m_layout_current;
 
@@ -4234,7 +4234,7 @@ Glib::ustring Document::get_layout_current(const Glib::ustring& table_name) cons
 
 FoundSet Document::get_criteria_current(const Glib::ustring& table_name) const
 {
-  const std::shared_ptr<const DocumentTableInfo> info = get_table_info(table_name);
+  const auto info = get_table_info(table_name);
   if(info)
     return info->m_foundset_current;
 
@@ -4401,7 +4401,7 @@ Document::type_list_translatables Document::get_translatable_items()
     //The table's report titles:
     for(const auto& report_name : get_report_names(table_name))
     {
-      std::shared_ptr<Report> report = get_report(table_name, report_name);
+      auto report = get_report(table_name, report_name);
       if(!report)
         continue;
 
@@ -4416,7 +4416,7 @@ Document::type_list_translatables Document::get_translatable_items()
     //The table's print layout titles:
     for(const auto& print_layout_name : get_print_layout_names(table_name))
     {
-      std::shared_ptr<PrintLayout> print_layout = get_print_layout(table_name, print_layout_name);
+      auto print_layout = get_print_layout(table_name, print_layout_name);
       if(!print_layout)
         continue;
 
@@ -4465,7 +4465,7 @@ Document::type_list_translatables Document::get_translatable_report_items(const
 {
   Document::type_list_translatables the_list;
 
-  std::shared_ptr<Report> report = get_report(table_name, report_name);
+  auto report = get_report(table_name, report_name);
   if(report)
     fill_translatable_layout_items(report->get_layout_group(), the_list, hint);
 
@@ -4476,7 +4476,7 @@ Document::type_list_translatables Document::get_translatable_print_layout_items(
 {
   Document::type_list_translatables the_list;
 
-  std::shared_ptr<PrintLayout> print_layout = get_print_layout(table_name, print_layout_name);
+  auto print_layout = get_print_layout(table_name, print_layout_name);
   if(print_layout)
     fill_translatable_layout_items(print_layout->get_layout_group(), the_list, hint);
 
@@ -4498,7 +4498,7 @@ void Document::fill_translatable_layout_items(const std::shared_ptr<LayoutItem_F
 {
   //LayoutItem_Field items do not have their own titles.
   //They use either the field's title or a custom title:
-  std::shared_ptr<CustomTitle> custom_title = layout_field->get_title_custom();
+  auto custom_title = layout_field->get_title_custom();
   if(custom_title)
   {
     the_list.push_back( pair_translatable_item_and_hint(custom_title, hint) ); 
@@ -4519,7 +4519,7 @@ void Document::fill_translatable_layout_items(const std::shared_ptr<LayoutItem_F
 void Document::fill_translatable_layout_items(const std::shared_ptr<LayoutGroup>& group, 
type_list_translatables& the_list, const Glib::ustring& hint)
 {
   //Portals don't have their own titles - they use the relationship title (though we might want to allow 
custom titles)
-  std::shared_ptr<LayoutItem_Portal> portal = std::dynamic_pointer_cast<LayoutItem_Portal>(group);
+  auto portal = std::dynamic_pointer_cast<LayoutItem_Portal>(group);
   if(!portal)
   {
     the_list.push_back( pair_translatable_item_and_hint(group, hint) );
@@ -4533,13 +4533,13 @@ void Document::fill_translatable_layout_items(const std::shared_ptr<LayoutGroup>
   //Look at each item:
   for(const auto& item : group->get_items())
   {
-    std::shared_ptr<LayoutGroup> child_group = std::dynamic_pointer_cast<LayoutGroup>(item);
+    auto child_group = std::dynamic_pointer_cast<LayoutGroup>(item);
     if(child_group) //If it is a group, portal, summary, or groupby.
     {
-      std::shared_ptr<LayoutItem_GroupBy> group_by = 
std::dynamic_pointer_cast<LayoutItem_GroupBy>(child_group);
+      auto group_by = std::dynamic_pointer_cast<LayoutItem_GroupBy>(child_group);
       if(group_by)
       {
-        std::shared_ptr<LayoutItem_Field> field = group_by->get_field_group_by();
+        auto field = group_by->get_field_group_by();
         fill_translatable_layout_items(field, the_list, hint);
 
         fill_translatable_layout_items(group_by->get_secondary_fields(), the_list, this_hint);
@@ -4551,12 +4551,12 @@ void Document::fill_translatable_layout_items(const std::shared_ptr<LayoutGroup>
     else
     {
       //Buttons too:
-      std::shared_ptr<LayoutItem_Button> button = std::dynamic_pointer_cast<LayoutItem_Button>(item);
+      auto button = std::dynamic_pointer_cast<LayoutItem_Button>(item);
       if(button)
         the_list.push_back( pair_translatable_item_and_hint(button, this_hint) );
       else
       {
-        std::shared_ptr<LayoutItem_Text> text = std::dynamic_pointer_cast<LayoutItem_Text>(item);
+        auto text = std::dynamic_pointer_cast<LayoutItem_Text>(item);
         if(text)
         {
           the_list.push_back( pair_translatable_item_and_hint(text, this_hint) );
@@ -4566,12 +4566,12 @@ void Document::fill_translatable_layout_items(const std::shared_ptr<LayoutGroup>
         else
         {
           //Images have titles:
-          std::shared_ptr<LayoutItem_Image> image = std::dynamic_pointer_cast<LayoutItem_Image>(item);
+          auto image = std::dynamic_pointer_cast<LayoutItem_Image>(item);
           if(image)
             the_list.push_back( pair_translatable_item_and_hint(image, this_hint) );
           else
           {
-            std::shared_ptr<LayoutItem_Field> layout_field = 
std::dynamic_pointer_cast<LayoutItem_Field>(item);
+            auto layout_field = std::dynamic_pointer_cast<LayoutItem_Field>(item);
             if(layout_field)
             {
               fill_translatable_layout_items(layout_field, the_list, hint);
diff --git a/glom/libglom/example_document_load.cc b/glom/libglom/example_document_load.cc
index 030aded..ab78cce 100644
--- a/glom/libglom/example_document_load.cc
+++ b/glom/libglom/example_document_load.cc
@@ -48,7 +48,7 @@ void print_layout_group(const std::shared_ptr<Glom::LayoutGroup>& layout_group,
     std::cout << std::endl;
 
     //Recurse into child groups:
-    std::shared_ptr<Glom::LayoutGroup> group = std::dynamic_pointer_cast<Glom::LayoutGroup>(layout_item);
+    auto group = std::dynamic_pointer_cast<Glom::LayoutGroup>(layout_item);
     if(group)
     {
       print_layout_group(group, indent + "  ");
diff --git a/glom/libglom/privs.cc b/glom/libglom/privs.cc
index 2e40dd7..c019132 100644
--- a/glom/libglom/privs.cc
+++ b/glom/libglom/privs.cc
@@ -472,7 +472,7 @@ Privileges Privs::get_current_privs(const Glib::ustring& table_name)
     result.m_developer = true;
   }
   */
-  std::shared_ptr<SharedConnection> sharedconnection = connection_pool->connect();
+  auto sharedconnection = connection_pool->connect();
   if(sharedconnection && 
sharedconnection->get_gda_connection()->supports_feature(Gnome::Gda::CONNECTION_FEATURE_USERS))
   {
     //Get the "true" rights for any groups that the user is in:
diff --git a/glom/libglom/python_embed/py_glom_record.cc b/glom/libglom/python_embed/py_glom_record.cc
index eb84edd..0006996 100644
--- a/glom/libglom/python_embed/py_glom_record.cc
+++ b/glom/libglom/python_embed/py_glom_record.cc
@@ -139,7 +139,7 @@ void PyGlomRecord::setitem(const boost::python::object& key, const boost::python
   if(extractor.check())
     field_name = extractor;
 
-  std::shared_ptr<const Field> field = m_document->get_field(m_table_name, field_name);
+  auto field = m_document->get_field(m_table_name, field_name);
   if(!field)
   {
      std::cerr << G_STRFUNC << ": field=" << field_name << " not found in table=" << m_table_name << 
std::endl;
diff --git a/glom/libglom/python_embed/py_glom_related.cc b/glom/libglom/python_embed/py_glom_related.cc
index cac9820..e7f1ed9 100644
--- a/glom/libglom/python_embed/py_glom_related.cc
+++ b/glom/libglom/python_embed/py_glom_related.cc
@@ -67,7 +67,7 @@ boost::python::object PyGlomRelated::getitem(const boost::python::object& cppite
         if(iterFind != m_map_relationships.end())
         {
           //Get the value of the from_key in the parent record.
-          std::shared_ptr<Relationship> relationship = iterFind->second;
+          auto relationship = iterFind->second;
           const auto from_key = relationship->get_from_field();
 
           boost::python::extract<PyGlomRecord*> extractor_record(m_record);
@@ -81,7 +81,7 @@ boost::python::object PyGlomRelated::getitem(const boost::python::object& cppite
 
               //TODO_Performance:
               //Get the full field details so we can sqlize its value:
-              std::shared_ptr<const Field> from_key_field = 
record->m_document->get_field(record->m_table_name, from_key);
+              auto from_key_field = record->m_document->get_field(record->m_table_name, from_key);
               if(from_key_field)
               {
                 //Return a new RelatedRecord:
diff --git a/glom/libglom/python_embed/py_glom_relatedrecord.cc 
b/glom/libglom/python_embed/py_glom_relatedrecord.cc
index c74fabd..ed32218 100644
--- a/glom/libglom/python_embed/py_glom_relatedrecord.cc
+++ b/glom/libglom/python_embed/py_glom_relatedrecord.cc
@@ -76,7 +76,7 @@ boost::python::object PyGlomRelatedRecord::getitem(const boost::python::object&
   }
 
   //Check whether the field exists in the table.
-  std::shared_ptr<const Field> field = m_document->get_field(m_relationship->get_to_table(), field_name);
+  auto field = m_document->get_field(m_relationship->get_to_table(), field_name);
   if(!field)
   {
     std::cerr << G_STRFUNC << ": field " << field_name << " not found in table " << 
m_relationship->get_to_table() << std::endl;
@@ -87,7 +87,7 @@ boost::python::object PyGlomRelatedRecord::getitem(const boost::python::object&
   {
     //Try to get the value from the database:
     //const Glib::ustring parent_key_name;
-    std::shared_ptr<SharedConnection> sharedconnection = ConnectionPool::get_instance()->connect();
+    auto sharedconnection = ConnectionPool::get_instance()->connect();
 
     if(!sharedconnection)
     {
@@ -169,7 +169,7 @@ boost::python::object PyGlomRelatedRecord::generic_aggregate(const std::string&
   }
 
   //Check whether the field exists in the table.
-  std::shared_ptr<Field> field = m_document->get_field(m_relationship->get_to_table(), field_name);
+  auto field = m_document->get_field(m_relationship->get_to_table(), field_name);
   if(!field)
   {
     g_warning("RelatedRecord_sum: field %s not found in table %s", field_name.c_str(), 
m_relationship->get_to_table().c_str());
@@ -178,7 +178,7 @@ boost::python::object PyGlomRelatedRecord::generic_aggregate(const std::string&
 
   //Try to get the value from the database:
   //const Glib::ustring parent_key_name;
-  std::shared_ptr<SharedConnection> sharedconnection = ConnectionPool::get_instance()->connect();
+  auto sharedconnection = ConnectionPool::get_instance()->connect();
   if(!sharedconnection)
   {
     g_warning("RelatedRecord_sum: no connection.");
diff --git a/glom/libglom/report_builder.cc b/glom/libglom/report_builder.cc
index e7291bf..6fe2132 100644
--- a/glom/libglom/report_builder.cc
+++ b/glom/libglom/report_builder.cc
@@ -47,7 +47,7 @@ bool ReportBuilder::report_build_headerfooter(const FoundSet& found_set, xmlpp::
   type_vecLayoutItems itemsToGet;
   for(const auto& item : group->m_list_items)
   {
-    std::shared_ptr<LayoutItem_Text> item_text = std::dynamic_pointer_cast<LayoutItem_Text>(item);
+    auto item_text = std::dynamic_pointer_cast<LayoutItem_Text>(item);
     if(item_text)
     {
       if(!report_build_records_text(found_set, *node, item_text))
@@ -58,7 +58,7 @@ bool ReportBuilder::report_build_headerfooter(const FoundSet& found_set, xmlpp::
     }
     else
     {
-      std::shared_ptr<LayoutItem_Image> item_image = std::dynamic_pointer_cast<LayoutItem_Image>(item);
+      auto item_image = std::dynamic_pointer_cast<LayoutItem_Image>(item);
       if(item_image)
       {
         if(!report_build_records_image(found_set, *node, item_image))
@@ -69,7 +69,7 @@ bool ReportBuilder::report_build_headerfooter(const FoundSet& found_set, xmlpp::
       }
       else
       {
-        std::shared_ptr<LayoutItem_Field> pField = std::dynamic_pointer_cast<LayoutItem_Field>(item);
+        auto pField = std::dynamic_pointer_cast<LayoutItem_Field>(item);
         if(pField)
         {
           guint col_index = 0; //ignored.
@@ -81,7 +81,7 @@ bool ReportBuilder::report_build_headerfooter(const FoundSet& found_set, xmlpp::
         }
         else
         {
-          std::shared_ptr<LayoutItem_VerticalGroup> vertical_group = 
std::dynamic_pointer_cast<LayoutItem_VerticalGroup>(item);
+          auto vertical_group = std::dynamic_pointer_cast<LayoutItem_VerticalGroup>(item);
           if(vertical_group)
           {
             //Reuse (a bit hacky) this function for the header and footer:
@@ -109,7 +109,7 @@ bool ReportBuilder::report_build_summary(const FoundSet& found_set, xmlpp::Eleme
   type_vecLayoutItems itemsToGet;
   for(const auto& item : summary->m_list_items)
   {
-    std::shared_ptr<LayoutItem_GroupBy> pGroupBy = std::dynamic_pointer_cast<LayoutItem_GroupBy>(item);
+    auto pGroupBy = std::dynamic_pointer_cast<LayoutItem_GroupBy>(item);
     if(pGroupBy)
     {
       //Recurse, adding a sub-groupby block:
@@ -121,7 +121,7 @@ bool ReportBuilder::report_build_summary(const FoundSet& found_set, xmlpp::Eleme
     }
     else
     {
-      std::shared_ptr<LayoutItem_Summary> pSummary = std::dynamic_pointer_cast<LayoutItem_Summary>(item);
+      auto pSummary = std::dynamic_pointer_cast<LayoutItem_Summary>(item);
       if(pSummary)
       {
         //Recurse, adding a summary block:
@@ -165,7 +165,7 @@ bool ReportBuilder::report_build_groupby_children(const FoundSet& found_set, xml
   type_vecLayoutItems itemsToGet;
   for(const auto& item : group_by->m_list_items)
   {
-    std::shared_ptr<LayoutItem_GroupBy> pGroupBy = std::dynamic_pointer_cast<LayoutItem_GroupBy>(item);
+    auto pGroupBy = std::dynamic_pointer_cast<LayoutItem_GroupBy>(item);
     if(pGroupBy)
     {
       //Recurse, adding a sub-groupby block:
@@ -177,7 +177,7 @@ bool ReportBuilder::report_build_groupby_children(const FoundSet& found_set, xml
     }
     else
     {
-      std::shared_ptr<LayoutItem_Summary> pSummary = std::dynamic_pointer_cast<LayoutItem_Summary>(item);
+      auto pSummary = std::dynamic_pointer_cast<LayoutItem_Summary>(item);
       if(pSummary)
       {
         //Recurse, adding a summary block:
@@ -214,7 +214,7 @@ bool ReportBuilder::report_build_groupby(const FoundSet& found_set_parent, xmlpp
   //Get the possible heading values.
   if(group_by->get_has_field_group_by())
   {
-    std::shared_ptr<LayoutItem_Field> field_group_by = group_by->get_field_group_by();
+    auto field_group_by = group_by->get_field_group_by();
     DbUtils::layout_item_fill_field_details(get_document(), found_set_parent.m_table_name, field_group_by);
 
     //Get the possible group values, ignoring repeats by using GROUP BY.
@@ -313,7 +313,7 @@ bool ReportBuilder::report_build_records_get_fields(const FoundSet& found_set, c
 {
   for(const auto& item : group->m_list_items)
   {
-    std::shared_ptr<LayoutItem_VerticalGroup> pVerticalGroup = 
std::dynamic_pointer_cast<LayoutItem_VerticalGroup>(item);
+    auto pVerticalGroup = std::dynamic_pointer_cast<LayoutItem_VerticalGroup>(item);
     if(pVerticalGroup)
     {
       if(!report_build_records_get_fields(found_set, pVerticalGroup, items))
@@ -324,7 +324,7 @@ bool ReportBuilder::report_build_records_get_fields(const FoundSet& found_set, c
     }
     else
     {
-      std::shared_ptr<LayoutItem_Field> pField = std::dynamic_pointer_cast<LayoutItem_Field>(item);
+      auto pField = std::dynamic_pointer_cast<LayoutItem_Field>(item);
       if(pField)
         items.push_back(pField);
     }
@@ -340,7 +340,7 @@ bool ReportBuilder::report_build_records(const FoundSet& found_set, xmlpp::Eleme
     //Add Field headings:
     for(const auto& layout_item : items)
     {
-      std::shared_ptr<LayoutItem_Field> layoutitem_field = 
std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+      auto layoutitem_field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
 
       //This adds a field heading (and therefore, column) for fields, or for a vertical group.
       auto nodeFieldHeading = parent_node.add_child_element("field_heading");
@@ -355,12 +355,12 @@ bool ReportBuilder::report_build_records(const FoundSet& found_set, xmlpp::Eleme
     Utils::type_vecLayoutFields fieldsToGet;
     for(const auto& layout_item : items)
     {
-      std::shared_ptr<LayoutItem_Field> layoutitem_field = 
std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+      auto layoutitem_field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
       if(layoutitem_field)
         fieldsToGet.push_back(layoutitem_field);
       else
       {
-        std::shared_ptr<LayoutItem_VerticalGroup> vertical_group = 
std::dynamic_pointer_cast<LayoutItem_VerticalGroup>(layout_item);
+        auto vertical_group = std::dynamic_pointer_cast<LayoutItem_VerticalGroup>(layout_item);
         if(vertical_group)
         {
           //Get all the fields in this group:
@@ -400,7 +400,7 @@ bool ReportBuilder::report_build_records(const FoundSet& found_set, xmlpp::Eleme
         guint colField = 0;
         for(const auto& item : items)
         {
-          std::shared_ptr<LayoutItem_Field> field = std::dynamic_pointer_cast<LayoutItem_Field>(item);
+          auto field = std::dynamic_pointer_cast<LayoutItem_Field>(item);
           if(field)
           {
             if(!report_build_records_field(found_set, *nodeRow, field, datamodel, row, colField))
@@ -411,7 +411,7 @@ bool ReportBuilder::report_build_records(const FoundSet& found_set, xmlpp::Eleme
           }
           else
           {
-            std::shared_ptr<LayoutItem_Text> item_text = std::dynamic_pointer_cast<LayoutItem_Text>(item);
+            auto item_text = std::dynamic_pointer_cast<LayoutItem_Text>(item);
             if(item_text)
             {
               if(!report_build_records_text(found_set, *nodeRow, item_text))
@@ -422,7 +422,7 @@ bool ReportBuilder::report_build_records(const FoundSet& found_set, xmlpp::Eleme
             }
             else
             {
-              std::shared_ptr<LayoutItem_VerticalGroup> item_verticalgroup = 
std::dynamic_pointer_cast<LayoutItem_VerticalGroup>(item);
+              auto item_verticalgroup = std::dynamic_pointer_cast<LayoutItem_VerticalGroup>(item);
               if(item_verticalgroup)
               {
                 if(!report_build_records_vertical_group(found_set, *nodeRow, item_verticalgroup, datamodel, 
row, colField))
@@ -537,7 +537,7 @@ bool ReportBuilder::report_build_records_vertical_group(const FoundSet& found_se
 
   for(const auto& item : group->m_list_items)
   {
-    std::shared_ptr<LayoutItem_VerticalGroup> pVerticalGroup = 
std::dynamic_pointer_cast<LayoutItem_VerticalGroup>(item);
+    auto pVerticalGroup = std::dynamic_pointer_cast<LayoutItem_VerticalGroup>(item);
     if(pVerticalGroup)
     {
       if(!report_build_records_vertical_group(found_set, *nodeGroupVertical, pVerticalGroup, datamodel, row, 
field_index))
@@ -548,7 +548,7 @@ bool ReportBuilder::report_build_records_vertical_group(const FoundSet& found_se
     }
     else
     {
-      std::shared_ptr<LayoutItem_Field> pField = std::dynamic_pointer_cast<LayoutItem_Field>(item);
+      auto pField = std::dynamic_pointer_cast<LayoutItem_Field>(item);
       if(pField)
       {
         if(!report_build_records_field(found_set, *nodeGroupVertical, pField, datamodel, row, field_index, 
true /* vertical, so we get a row for each field too. */))
@@ -559,7 +559,7 @@ bool ReportBuilder::report_build_records_vertical_group(const FoundSet& found_se
       }
       else
       {
-        std::shared_ptr<LayoutItem_Text> pText = std::dynamic_pointer_cast<LayoutItem_Text>(item);
+        auto pText = std::dynamic_pointer_cast<LayoutItem_Text>(item);
         if(pText)
         {
           if(!report_build_records_text(found_set, *nodeGroupVertical, pText, true))
@@ -657,11 +657,11 @@ Glib::ustring ReportBuilder::report_build(const FoundSet& found_set, const std::
 
   type_vecLayoutItems itemsToGet_TopLevel;
 
-  const std::shared_ptr<const LayoutGroup> group = report->get_layout_group();
+  const auto group = report->get_layout_group();
   for(const auto& pPart : group->m_list_items)
   {
     //The Group, and the details for each record in the group:
-    std::shared_ptr<LayoutItem_GroupBy> pGroupBy = std::dynamic_pointer_cast<LayoutItem_GroupBy>(pPart);
+    auto pGroupBy = std::dynamic_pointer_cast<LayoutItem_GroupBy>(pPart);
     if(pGroupBy)
     {
       if(!report_build_groupby(found_set, *nodeParent, pGroupBy))
@@ -672,7 +672,7 @@ Glib::ustring ReportBuilder::report_build(const FoundSet& found_set, const std::
     }
     else
     {
-      std::shared_ptr<LayoutItem_Summary> pSummary = std::dynamic_pointer_cast<LayoutItem_Summary>(pPart);
+      auto pSummary = std::dynamic_pointer_cast<LayoutItem_Summary>(pPart);
       if(pSummary)
       {
         //Recurse, adding a summary block:
@@ -684,11 +684,11 @@ Glib::ustring ReportBuilder::report_build(const FoundSet& found_set, const std::
       }
       else
       {
-        std::shared_ptr<LayoutGroup> pGroup = std::dynamic_pointer_cast<LayoutGroup>(pPart);
+        auto pGroup = std::dynamic_pointer_cast<LayoutGroup>(pPart);
         if(pGroup)
         {
-          std::shared_ptr<LayoutItem_Header> pHeader = std::dynamic_pointer_cast<LayoutItem_Header>(pPart);
-          std::shared_ptr<LayoutItem_Footer> pFooter = std::dynamic_pointer_cast<LayoutItem_Footer>(pPart);
+          auto pHeader = std::dynamic_pointer_cast<LayoutItem_Header>(pPart);
+          auto pFooter = std::dynamic_pointer_cast<LayoutItem_Footer>(pPart);
           if(pHeader || pFooter)
           {
             //Recurse, adding a summary block:
diff --git a/glom/libglom/spawn_with_feedback.cc b/glom/libglom/spawn_with_feedback.cc
index cb4fd3d..2888568 100644
--- a/glom/libglom/spawn_with_feedback.cc
+++ b/glom/libglom/spawn_with_feedback.cc
@@ -325,7 +325,7 @@ static int spawn_sync(const Glib::ustring& command_line, std::string* stdout_tex
 
   Glib::RefPtr<Glib::MainLoop> mainloop = Glib::MainLoop::create(false);
 
-  std::shared_ptr<const SpawnInfo> info = spawn_async(command_line, redirect_flags); //This could throw
+  auto info = spawn_async(command_line, redirect_flags); //This could throw
   info->signal_finished().connect(
     sigc::bind(sigc::ptr_fun(&on_spawn_info_finished), sigc::ref(mainloop) ) );
 
diff --git a/glom/libglom/translations_po.cc b/glom/libglom/translations_po.cc
index 19a775b..136fbc1 100644
--- a/glom/libglom/translations_po.cc
+++ b/glom/libglom/translations_po.cc
@@ -212,7 +212,7 @@ bool write_translations_to_po_file(Document* document, const Glib::ustring& po_f
 
   for(const auto& the_pair : document->get_translatable_items())
   {
-    std::shared_ptr<TranslatableItem> item = the_pair.first;
+    auto item = the_pair.first;
     if(!item)
       continue;
 
diff --git a/glom/libglom/utils.cc b/glom/libglom/utils.cc
index 0335f48..5250895 100644
--- a/glom/libglom/utils.cc
+++ b/glom/libglom/utils.cc
@@ -244,7 +244,7 @@ static void add_to_relationships_list(type_list_relationships& list_relationship
   auto iterFind = find_if_uses_relationship_has_relationship(list_relationships, layout_item, true /* 
top_level_only */);
   if(iterFind == list_relationships.end()) //If the table is not yet in the list:
   {
-    std::shared_ptr<UsesRelationship> uses_rel = std::make_shared<UsesRelationship>();
+    auto uses_rel = std::make_shared<UsesRelationship>();
     uses_rel->set_relationship(layout_item->get_relationship());
     list_relationships.push_front(uses_rel); //These need to be at the front, so that related relationships 
can use them later in the SQL statement.
   }
@@ -253,7 +253,7 @@ static void add_to_relationships_list(type_list_relationships& list_relationship
   iterFind = find_if_uses_relationship_has_relationship(list_relationships, layout_item);
   if(iterFind == list_relationships.end()) //If the table is not yet in the list:
   {
-    std::shared_ptr<UsesRelationship> uses_rel = std::make_shared<UsesRelationship>();
+    auto uses_rel = std::make_shared<UsesRelationship>();
     uses_rel->set_relationship(layout_item->get_relationship());
     uses_rel->set_related_relationship(layout_item->get_related_relationship());
     list_relationships.push_back(uses_rel);
@@ -263,7 +263,7 @@ static void add_to_relationships_list(type_list_relationships& list_relationship
 
 static void builder_add_join(const Glib::RefPtr<Gnome::Gda::SqlBuilder>& builder, const 
std::shared_ptr<const UsesRelationship>& uses_relationship)
 {
-  std::shared_ptr<const Relationship> relationship = uses_relationship->get_relationship();
+  auto relationship = uses_relationship->get_relationship();
   if(!relationship->get_has_fields()) //TODO: Handle related_record has_fields.
   {
     if(relationship->get_has_to_table())
@@ -298,7 +298,7 @@ static void builder_add_join(const Glib::RefPtr<Gnome::Gda::SqlBuilder>& builder
   {
      UsesRelationship parent_relationship;
      parent_relationship.set_relationship(relationship);
-     std::shared_ptr<const Relationship> related_relationship = 
uses_relationship->get_related_relationship();
+     auto related_relationship = uses_relationship->get_related_relationship();
 
      const guint to_target_id = builder->select_add_target(related_relationship->get_to_table(), alias_name);
 
@@ -401,7 +401,7 @@ Glib::RefPtr<Gnome::Gda::SqlBuilder> Utils::build_sql_select_with_where_clause(c
 
     if(extra_join)
     {
-      std::shared_ptr<UsesRelationship> uses_relationship = std::make_shared<UsesRelationship>();
+      auto uses_relationship = std::make_shared<UsesRelationship>();
       uses_relationship->set_relationship(extra_join);
       builder_add_join(builder, uses_relationship);
     }
@@ -554,7 +554,7 @@ Utils::type_list_values_with_second Utils::get_choice_values(const Document* doc
   }
 
   const Glib::ustring to_table = choice_relationship->get_to_table();
-  const std::shared_ptr<const Field> to_field = document->get_field(to_table, 
choice_relationship->get_to_field());
+  const auto to_field = document->get_field(to_table, choice_relationship->get_to_field());
 
   if(!to_field)
   {
@@ -584,7 +584,7 @@ Utils::type_list_values_with_second Utils::get_choice_values(const Document* doc
   //TODO: builder->select_order_by(choice_field_id);
 
   //Connect to database and get the related values:
-  std::shared_ptr<SharedConnection> connection = ConnectionPool::get_instance()->connect();
+  auto connection = ConnectionPool::get_instance()->connect();
 
   if(!connection)
   {
@@ -1482,7 +1482,7 @@ LayoutGroup::type_list_const_items Utils::get_layout_items_plus_primary_key(cons
     return items;
   }
 
-  std::shared_ptr<LayoutItem_Field> pk_layout_item = std::make_shared<LayoutItem_Field>();
+  auto pk_layout_item = std::make_shared<LayoutItem_Field>();
   pk_layout_item->set_hidden();
   pk_layout_item->set_full_field_details(field_primary_key);
   
@@ -1510,7 +1510,7 @@ LayoutGroup::type_list_items Utils::get_layout_items_plus_primary_key(const Layo
     return items;
   }
 
-  std::shared_ptr<LayoutItem_Field> pk_layout_item = std::make_shared<LayoutItem_Field>();
+  auto pk_layout_item = std::make_shared<LayoutItem_Field>();
   pk_layout_item->set_hidden();
   pk_layout_item->set_full_field_details(field_primary_key);
   
diff --git a/glom/mode_data/box_data.cc b/glom/mode_data/box_data.cc
index b962c9c..bf7cc79 100644
--- a/glom/mode_data/box_data.cc
+++ b/glom/mode_data/box_data.cc
@@ -104,7 +104,7 @@ Gnome::Gda::SqlExpr Box_Data::get_find_where_clause() const
 
     if(!Conversions::value_is_empty(data))
     {
-      const std::shared_ptr<const Field> field = item->get_full_field_details();
+      const auto field = item->get_full_field_details();
       if(field)
       {
         bool use_this_field = true;
@@ -294,10 +294,10 @@ void Box_Data::fill_layout_group_field_info(const std::shared_ptr<LayoutGroup>&
       {
         //Get the full field information:
         const auto relationship_name = item_field->get_relationship_name();
-        std::shared_ptr<const Relationship> relationship = document->get_relationship(m_table_name, 
relationship_name);
+        auto relationship = document->get_relationship(m_table_name, relationship_name);
         if(relationship)
         {
-          std::shared_ptr<Field> field = DbUtils::get_fields_for_table_one_field(document, 
relationship->get_to_table(), item->get_name());
+          auto field = DbUtils::get_fields_for_table_one_field(document, relationship->get_to_table(), 
item->get_name());
           if(field)
           {
             item_field->set_full_field_details(field);
@@ -312,7 +312,7 @@ void Box_Data::fill_layout_group_field_info(const std::shared_ptr<LayoutGroup>&
       else
       {
         //Get the field info:
-        std::shared_ptr<Field> field = DbUtils::get_fields_for_table_one_field(document, m_table_name, 
item_field->get_name());
+        auto field = DbUtils::get_fields_for_table_one_field(document, m_table_name, item_field->get_name());
         if(field)
         {
           item_field->set_full_field_details(field); //TODO_Performance: Just use this as the output arg?
@@ -323,7 +323,7 @@ void Box_Data::fill_layout_group_field_info(const std::shared_ptr<LayoutGroup>&
     }
     else
     {
-      std::shared_ptr<LayoutGroup> item_group = std::dynamic_pointer_cast<LayoutGroup>(item);
+      auto item_group = std::dynamic_pointer_cast<LayoutGroup>(item);
       if(item_group) //If it is a group
       {
         //recurse, to fill the fields info in this group:
@@ -357,7 +357,7 @@ void Box_Data::execute_button_script(const std::shared_ptr<const LayoutItem_Butt
   const auto field_values = get_record_field_values_for_calculation(m_table_name, field_primary_key, 
primary_key_value);
 
   //We need the connection when we run the script, so that the script may use it.
-  std::shared_ptr<SharedConnection> sharedconnection = connect_to_server(0 /* parent window */);
+  auto sharedconnection = connect_to_server(0 /* parent window */);
 
   //Allow this UI to respond to UI change requests from the Python code:
   AppPythonUICallbacks callbacks;
diff --git a/glom/mode_data/box_data_calendar_related.cc b/glom/mode_data/box_data_calendar_related.cc
index a640d4e..e087d4d 100644
--- a/glom/mode_data/box_data_calendar_related.cc
+++ b/glom/mode_data/box_data_calendar_related.cc
@@ -169,23 +169,23 @@ bool Box_Data_Calendar_Related::fill_from_database()
     Gnome::Gda::Value date_end_value(date_end);
 
     //Add a WHERE clause for this date range:
-    std::shared_ptr<const Relationship> relationship = m_portal->get_relationship();
+    auto relationship = m_portal->get_relationship();
     Glib::ustring where_clause_to_table_name = relationship->get_to_table();
 
-    std::shared_ptr<LayoutItem_CalendarPortal> derived_portal = 
std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(m_portal);
+    auto derived_portal = std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(m_portal);
     const auto date_field_name = derived_portal->get_date_field()->get_name();
 
-    std::shared_ptr<const Relationship> relationship_related = m_portal->get_related_relationship();
+    auto relationship_related = m_portal->get_related_relationship();
     if(relationship_related)
     {
       //Adjust the WHERE clause appropriately for the extra JOIN:
-      std::shared_ptr<UsesRelationship> uses_rel_temp = std::make_shared<UsesRelationship>();
+      auto uses_rel_temp = std::make_shared<UsesRelationship>();
       uses_rel_temp->set_relationship(relationship);
       where_clause_to_table_name = uses_rel_temp->get_sql_join_alias_name();
     }
 
     //Add an AND to the existing where clause, to get only records within these dates, if any:
-    std::shared_ptr<const Field> date_field = derived_portal->get_date_field();
+    auto date_field = derived_portal->get_date_field();
 
     Glib::RefPtr<Gnome::Gda::SqlBuilder> builder =
       Gnome::Gda::SqlBuilder::create(Gnome::Gda::SQL_STATEMENT_SELECT);
@@ -275,7 +275,7 @@ void Box_Data_Calendar_Related::on_record_added(const Gnome::Gda::Value& primary
   if(m_key_field)
   {
     //m_key_field is the field in this table that must match another field in the parent table.
-    std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+    auto layout_item = std::make_shared<LayoutItem_Field>();
     layout_item->set_full_field_details(m_key_field);
     //TODO: key_value = m_calendar.get_value(row, layout_item);
   }
@@ -312,7 +312,7 @@ void Box_Data_Calendar_Related::on_record_added(const Gnome::Gda::Value& primary
       if(test)
       {
         //Show it on the view, if it's visible:
-        std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+        auto layout_item = std::make_shared<LayoutItem_Field>();
         layout_item->set_full_field_details(field_primary_key);
 
         //TODO: m_calendar.set_value(row, layout_item, m_key_value);
@@ -327,14 +327,14 @@ Box_Data_Calendar_Related::type_vecConstLayoutFields Box_Data_Calendar_Related::
 {
   type_vecConstLayoutFields layout_fields = Box_Data_Portal::get_fields_to_show();
 
-  std::shared_ptr<LayoutItem_CalendarPortal> derived_portal = 
std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(m_portal);
+  auto derived_portal = std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(m_portal);
   if(!derived_portal)
   {
     std::cerr << G_STRFUNC << ": The portal is not a LayoutItem_CalendarPortal." << std::endl;
     return layout_fields;
   }
 
-  std::shared_ptr<const Field> date_field = derived_portal->get_date_field();
+  auto date_field = derived_portal->get_date_field();
   if(!date_field)
   {
     std::cerr << G_STRFUNC << ": get_date_field() returned no field." << std::endl;
@@ -342,7 +342,7 @@ Box_Data_Calendar_Related::type_vecConstLayoutFields Box_Data_Calendar_Related::
   }
 
   //Add it to the list to ensure that we request the date (though it will not really be shown in the 
calendar):
-  std::shared_ptr<LayoutItem_Field> layout_item_date_field = std::make_shared<LayoutItem_Field>();
+  auto layout_item_date_field = std::make_shared<LayoutItem_Field>();
   layout_item_date_field->set_full_field_details(date_field);
   layout_fields.push_back(layout_item_date_field);
   m_query_column_date_field = layout_fields.size() - 1;
@@ -358,12 +358,12 @@ void Box_Data_Calendar_Related::on_dialog_layout_hide()
 
 
   //Update the UI:
-  std::shared_ptr<LayoutItem_CalendarPortal> derived_portal = 
std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(m_portal);
+  auto derived_portal = std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(m_portal);
   init_db_details(derived_portal);
 
   Box_Data::on_dialog_layout_hide();
 
-  std::shared_ptr<LayoutItem_CalendarPortal> pLayoutItem = 
std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(get_layout_item());
+  auto pLayoutItem = std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(get_layout_item());
   if(pLayoutItem)
   {
     if(derived_portal)
@@ -387,7 +387,7 @@ void Box_Data_Calendar_Related::prepare_layout_dialog(Dialog_Layout* dialog)
   auto related_dialog = dynamic_cast<Dialog_Layout_Calendar_Related*>(dialog);
   g_assert(related_dialog);
 
-  std::shared_ptr<LayoutItem_CalendarPortal> derived_portal = 
std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(m_portal);
+  auto derived_portal = std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(m_portal);
   if(derived_portal && derived_portal->get_has_relationship_name())
   {
     related_dialog->init_with_portal(m_layout_name, m_layout_platform, get_document(), derived_portal);
@@ -407,14 +407,14 @@ void Box_Data_Calendar_Related::on_calendar_month_changed()
 
 Glib::ustring Box_Data_Calendar_Related::on_calendar_details(guint year, guint month, guint day)
 {
-  std::shared_ptr<LayoutItem_CalendarPortal> derived_portal = 
std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(m_portal);
+  auto derived_portal = std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(m_portal);
   if(!derived_portal)
   {
     //std::cout << "debug: " << G_STRFUNC << ": date_field is NULL" << std::endl;
     return Glib::ustring();
   }
 
-  std::shared_ptr<const Field> date_field = derived_portal->get_date_field();
+  auto date_field = derived_portal->get_date_field();
   if(!date_field)
   {
     std::cerr << G_STRFUNC << ":  get_date_field() returned no field." << std::endl;
@@ -461,13 +461,13 @@ Glib::ustring Box_Data_Calendar_Related::on_calendar_details(guint year, guint m
       Glib::ustring text;
 
       //Text for a text item:
-      std::shared_ptr<const LayoutItem_Text> layout_item_text = std::dynamic_pointer_cast<const 
LayoutItem_Text>(layout_item);
+      auto layout_item_text = std::dynamic_pointer_cast<const LayoutItem_Text>(layout_item);
       if(layout_item_text)
         text = layout_item_text->get_text(AppWindow::get_current_locale());
       else
       {
         //Text for a field:
-        std::shared_ptr<const LayoutItem_Field> layout_item_field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(layout_item);
+        auto layout_item_field = std::dynamic_pointer_cast<const LayoutItem_Field>(layout_item);
 
         const Gnome::Gda::Value value = (*pRow)[column_index];
         text = Conversions::get_text_for_gda_value(layout_item_field->get_glom_type(), value, 
layout_item_field->get_formatting_used().m_numeric_format);
diff --git a/glom/mode_data/box_data_details.cc b/glom/mode_data/box_data_details.cc
index 024aa57..8dabdc1 100644
--- a/glom/mode_data/box_data_details.cc
+++ b/glom/mode_data/box_data_details.cc
@@ -298,7 +298,7 @@ bool Box_Data_Details::fill_from_database()
       if(table_privs.m_view)
       {
         //Add extra possibly-non-visible columns that we need:
-        std::shared_ptr<LayoutItem_Field> layout_item_pk = std::make_shared<LayoutItem_Field>();
+        auto layout_item_pk = std::make_shared<LayoutItem_Field>();
         layout_item_pk->set_full_field_details(m_field_primary_key);
 
         //Get the primary key index, adding the primary key if necessary:
@@ -317,7 +317,7 @@ bool Box_Data_Details::fill_from_database()
           const auto count = fieldsToGet.size();
           for(type_vecLayoutFields::size_type i = 0; i < count; ++i)
           {
-            std::shared_ptr<const LayoutItem_Field> element = fieldsToGet[i];
+            auto element = fieldsToGet[i];
             if(!element)
               continue;
 
@@ -325,8 +325,8 @@ bool Box_Data_Details::fill_from_database()
               continue;
 
             //Compare the relationship and related relationship:
-            std::shared_ptr<const UsesRelationship> uses_a = layout_item_pk;
-            std::shared_ptr<const UsesRelationship> uses_b = element;
+            auto uses_a = layout_item_pk;
+            auto uses_b = element;
             if(*uses_a == *uses_b)
             {
               index_primary_key = i;
@@ -369,7 +369,7 @@ bool Box_Data_Details::fill_from_database()
             //Get field values to show:
             for(int i = 0; i < cols_count; ++i)
             {
-              std::shared_ptr<const LayoutItem_Field> layout_item = fieldsToGet[i];
+              auto layout_item = fieldsToGet[i];
 
               //Field value:
               Gnome::Gda::Value value;
@@ -519,13 +519,13 @@ void Box_Data_Details::recalculate_fields_for_related_records(const Glib::ustrin
     {
       if(field)
       {
-        std::shared_ptr<LayoutItem_Field> layoutitem_field = std::make_shared<LayoutItem_Field>();
+        auto layoutitem_field = std::make_shared<LayoutItem_Field>();
         layoutitem_field->set_full_field_details(field);
         LayoutFieldInRecord field_in_record(layoutitem_field, m_table_name, m_field_primary_key, 
primary_key_value);
         calculate_field(field_in_record); //And any dependencies.
 
         //Calculate anything that depends on this.
-        //std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+        //auto layout_item = std::make_shared<LayoutItem_Field>();
         //layout_item->set_full_field_details(field);
 
         do_calculations(field_in_record, false /* recurse, reusing m_FieldsCalculationInProgress */);
@@ -643,7 +643,7 @@ void Box_Data_Details::on_flowtable_field_open_details_requested(const std::shar
 
   //Updating doesn't seem necessary. The field details seem to be full already.
   //Update the field details from the document:
-  ////std::shared_ptr<LayoutItem_Field> unconst_field = 
std::const_pointer_cast<LayoutItem_Field>(layout_field); //A hack, because 
layout_field_should_have_navigation() needs to get full field details.
+  ////auto unconst_field = std::const_pointer_cast<LayoutItem_Field>(layout_field); //A hack, because 
layout_field_should_have_navigation() needs to get full field details.
   //unconst_field->set_full_field_details(
   //  document->get_field(field->get_table_used(table_name), field->get_name()) ); //Otherwise 
get_primary_key() returns false always.
       
@@ -726,7 +726,7 @@ void Box_Data_Details::on_flowtable_field_edited(const std::shared_ptr<const Lay
       //plus how to identify the record in that table.
       const auto relationship_name = layout_field->get_relationship_name();
 
-      std::shared_ptr<Relationship> relationship = document->get_relationship(get_table_name(), 
relationship_name);
+      auto relationship = document->get_relationship(get_table_name(), relationship_name);
       if(relationship)
       {
         table_name = relationship->get_to_table();
@@ -736,7 +736,7 @@ void Box_Data_Details::on_flowtable_field_edited(const std::shared_ptr<const Lay
         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)
-          std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+          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);
@@ -937,7 +937,7 @@ void Box_Data_Details::print_layout()
   //breaks because those spaces would be empty space on the page after
   //we have moved items down when expanding:
   //TODO: Squash that space when expanding custom layouts.
-  std::shared_ptr<PrintLayout> layout = 
+  auto layout = 
     PrintLayoutUtils::create_standard(page_setup, m_table_name, document,
       false /* do not avoid page margins */);
   
diff --git a/glom/mode_data/box_data_list.cc b/glom/mode_data/box_data_list.cc
index 8324bf5..8b9f524 100644
--- a/glom/mode_data/box_data_list.cc
+++ b/glom/mode_data/box_data_list.cc
@@ -388,7 +388,7 @@ void Box_Data_List::create_layout()
   m_AddDel.set_table_name(m_table_name);
 
 
-  std::shared_ptr<Field> field_primary_key = get_field_primary_key_for_table(m_table_name);
+  auto field_primary_key = get_field_primary_key_for_table(m_table_name);
   if(!field_primary_key)
   {
     std::cerr << G_STRFUNC << ": primary key not found for table: " << m_table_name << std::endl;
@@ -415,7 +415,7 @@ void Box_Data_List::create_layout()
       if(m_read_only)
         child_item->set_editable(false);
 
-      std::shared_ptr<const LayoutItem_Field> child_field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(child_item);
+      auto child_field = std::dynamic_pointer_cast<const LayoutItem_Field>(child_item);
 
       //This check has already happened in Frame_Glom::update_table_in_document_from_database().
       //It is inefficient and unnecessary to do it here too.
@@ -442,7 +442,7 @@ void Box_Data_List::create_layout()
   items_to_use = Utils::get_layout_items_plus_primary_key(items_to_use, pDoc, m_table_name);
   if(field_primary_key)
   {
-    std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+    auto layout_item = std::make_shared<LayoutItem_Field>();
     layout_item->set_hidden();
     layout_item->set_full_field_details(m_AddDel.get_key_field());
 
diff --git a/glom/mode_data/box_data_list_related.cc b/glom/mode_data/box_data_list_related.cc
index 56846aa..5ec40de 100644
--- a/glom/mode_data/box_data_list_related.cc
+++ b/glom/mode_data/box_data_list_related.cc
@@ -279,7 +279,7 @@ void Box_Data_List_Related::on_adddel_record_added(const Gtk::TreeModel::iterato
   if(m_key_field)
   {
     //m_key_field is the field in this table that must match another field in the parent table.
-    std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+    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);
   }
@@ -299,7 +299,7 @@ void Box_Data_List_Related::on_adddel_record_added(const Gtk::TreeModel::iterato
   }
   else
   {
-    std::shared_ptr<Field> field_primary_key = m_AddDel.get_key_field();
+    auto field_primary_key = m_AddDel.get_key_field();
 
     //Create the link by setting the foreign key
     if(m_key_field && m_portal)
@@ -307,7 +307,7 @@ void Box_Data_List_Related::on_adddel_record_added(const Gtk::TreeModel::iterato
       make_record_related(primary_key_value);
 
       //Show it on the view, if it's visible:
-      std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+      auto layout_item = std::make_shared<LayoutItem_Field>();
       layout_item->set_full_field_details(m_key_field);
 
       //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:
@@ -337,7 +337,7 @@ void Box_Data_List_Related::on_dialog_layout_hide()
 
   Box_Data::on_dialog_layout_hide();
 
-  std::shared_ptr<LayoutItem_Portal> pLayoutItem = 
std::dynamic_pointer_cast<LayoutItem_Portal>(get_layout_item());
+  auto pLayoutItem = std::dynamic_pointer_cast<LayoutItem_Portal>(get_layout_item());
   if(pLayoutItem)
   {
     *pLayoutItem = *m_portal;
@@ -418,7 +418,7 @@ void Box_Data_List_Related::create_layout()
       m_AddDel.set_height_rows(rows_count_min, rows_count_max);
   }
 
-  std::shared_ptr<Field> field_primary_key = get_field_primary_key_for_table(Base_DB_Table::m_table_name);
+  auto field_primary_key = get_field_primary_key_for_table(Base_DB_Table::m_table_name);
   if(!field_primary_key)
   {
     std::cerr << G_STRFUNC << ": primary key not found." << std::endl;
@@ -445,7 +445,7 @@ void Box_Data_List_Related::create_layout()
       if(m_read_only)
         child_item->set_editable(false);
 
-      std::shared_ptr<const LayoutItem_Field> child_field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(child_item);
+      auto child_field = std::dynamic_pointer_cast<const LayoutItem_Field>(child_item);
       
       //This check has already happened in Frame_Glom::update_table_in_document_from_database().
       //It is inefficient and unnecessary to do it here too.
@@ -471,7 +471,7 @@ void Box_Data_List_Related::create_layout()
   //TODO: Only add it if it is not already there.
   if(field_primary_key)
   {
-    std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+    auto layout_item = std::make_shared<LayoutItem_Field>();
     layout_item->set_hidden();
     layout_item->set_full_field_details(m_AddDel.get_key_field());
     m_FieldsShown.push_back(layout_item);
diff --git a/glom/mode_data/box_data_manyrecords.cc b/glom/mode_data/box_data_manyrecords.cc
index cfe9ec7..a86acb3 100644
--- a/glom/mode_data/box_data_manyrecords.cc
+++ b/glom/mode_data/box_data_manyrecords.cc
@@ -80,7 +80,7 @@ void Box_Data_ManyRecords::print_layout()
   {
     //Create a simple report on the fly:
     auto document = get_document();
-    std::shared_ptr<Report> report_temp = ReportBuilder::create_standard_list_report(document, m_table_name);
+    auto report_temp = ReportBuilder::create_standard_list_report(document, m_table_name);
 
     //TODO: Find a way to get a full locale name from the simplified locale name from 
AppWindow::get_current_locale():
     ReportBuilder report_builder(std::locale("") /* the user's current locale */);
diff --git a/glom/mode_data/box_data_portal.cc b/glom/mode_data/box_data_portal.cc
index 6998dd2..1e5bf55 100644
--- a/glom/mode_data/box_data_portal.cc
+++ b/glom/mode_data/box_data_portal.cc
@@ -52,7 +52,7 @@ Box_Data_Portal::Box_Data_Portal()
 
 void Box_Data_Portal::make_record_related(const Gnome::Gda::Value& related_record_primary_key_value)
 {
-  std::shared_ptr<Field> field_primary_key = get_field_primary_key();
+  auto field_primary_key = get_field_primary_key();
 
   //Create the link by setting the foreign key
   if(!m_key_field)
@@ -187,7 +187,7 @@ Box_Data_Portal::type_vecConstLayoutFields Box_Data_Portal::get_fields_to_show()
     Document::type_list_layout_groups mapGroups;
     mapGroups.push_back(m_portal);
 
-    std::shared_ptr<const Relationship> relationship = m_portal->get_relationship();
+    auto relationship = m_portal->get_relationship();
     if(relationship)
     {
       type_vecConstLayoutFields result = 
get_table_fields_to_show_for_sequence(m_portal->get_table_used(Glib::ustring() /* not relevant */), 
mapGroups);
@@ -199,7 +199,7 @@ Box_Data_Portal::type_vecConstLayoutFields Box_Data_Portal::get_fields_to_show()
       {
         for(const auto& item : result)
         {
-          std::shared_ptr<const LayoutItem_Field> item = *iter;
+          auto item = *iter;
           if(item)
             item->set_editable(false);
         }
@@ -264,10 +264,10 @@ void Box_Data_Portal::get_suitable_record_to_view_details(const Gnome::Gda::Valu
     return;
 
   //Get the primary key of that table:
-  std::shared_ptr<Field> navigation_table_primary_key = 
get_field_primary_key_for_table(navigation_table_name);
+  auto navigation_table_primary_key = get_field_primary_key_for_table(navigation_table_name);
 
   //Build a layout item to get the field's value:
-  std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+  auto layout_item = std::make_shared<LayoutItem_Field>();
   layout_item->set_full_field_details(navigation_table_primary_key);
 
   if(navigation_relationship)
@@ -283,7 +283,7 @@ void Box_Data_Portal::get_suitable_record_to_view_details(const Gnome::Gda::Valu
 
   //For instance "invoice_line_id" if this is a portal to an "invoice_lines" table:
   const auto related_table = m_portal->get_table_used(Glib::ustring() /* not relevant */);
-  std::shared_ptr<const Field> key_field = get_field_primary_key_for_table(related_table);
+  auto key_field = get_field_primary_key_for_table(related_table);
   //std::cout << "DEBUG: related table=" << related_table << ", whose primary_key=" << key_field->get_name() 
<< ", with value=" << primary_key_value.to_string() << "getting value for: " << 
layout_item->get_layout_display_name() << std::endl;
 
   Glib::RefPtr<Gnome::Gda::SqlBuilder> query = Utils::build_sql_select_with_key(related_table, fieldsToGet, 
key_field, primary_key_value);
diff --git a/glom/mode_data/buttonglom.cc b/glom/mode_data/buttonglom.cc
index d8c066b..e5a9b2a 100644
--- a/glom/mode_data/buttonglom.cc
+++ b/glom/mode_data/buttonglom.cc
@@ -65,7 +65,7 @@ void ButtonGlom::on_menu_properties_activate()
   if(!dialog) //Unlikely and it already warns on stderr.
     return;
 
-  std::shared_ptr<LayoutItem_Button> layout_item = 
+  auto layout_item = 
     std::dynamic_pointer_cast<LayoutItem_Button>(get_layout_item());
   dialog->set_script(layout_item, m_table_name);
   const auto response = Glom::UiUtils::dialog_run_with_help(dialog);
diff --git a/glom/mode_data/datawidget/cellcreation.cc b/glom/mode_data/datawidget/cellcreation.cc
index 86cc772..ba907f0 100644
--- a/glom/mode_data/datawidget/cellcreation.cc
+++ b/glom/mode_data/datawidget/cellcreation.cc
@@ -70,7 +70,7 @@ Gtk::CellRenderer* create_cell(const std::shared_ptr<const LayoutItem>& layout_i
   Gtk::CellRenderer* cell = nullptr;
 
   //Create the appropriate cellrenderer type:
-  std::shared_ptr<const LayoutItem_Field> item_field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(layout_item);
+  auto item_field = std::dynamic_pointer_cast<const LayoutItem_Field>(layout_item);
   if(item_field)
   {
     //Ignore hidden fields.
@@ -102,7 +102,7 @@ Gtk::CellRenderer* create_cell(const std::shared_ptr<const LayoutItem>& layout_i
         if(formatting.get_has_choices())
         {
           auto rendererList = Gtk::manage( new CellRendererDbList() );
-          std::shared_ptr<LayoutItem> unconst = std::const_pointer_cast<LayoutItem>(layout_item); //TODO: 
Avoid this.
+          auto unconst = std::const_pointer_cast<LayoutItem>(layout_item); //TODO: Avoid this.
           rendererList->set_layout_item(unconst, table_name);
           bool as_radio_buttons = false; //Can't really be done in a list, so we ignore it.
           const auto restricted = formatting.get_choices_restricted(as_radio_buttons);
@@ -128,7 +128,7 @@ Gtk::CellRenderer* create_cell(const std::shared_ptr<const LayoutItem>& layout_i
   {
     //Non-fields:
 
-    std::shared_ptr<const LayoutItem_Image> item_image = std::dynamic_pointer_cast<const 
LayoutItem_Image>(layout_item);
+    auto item_image = std::dynamic_pointer_cast<const LayoutItem_Image>(layout_item);
     if(item_image)
     {
       auto pixbuf_renderer = Gtk::manage( new Gtk::CellRendererPixbuf() );
@@ -143,7 +143,7 @@ Gtk::CellRenderer* create_cell(const std::shared_ptr<const LayoutItem>& layout_i
     }
     else
     {
-      std::shared_ptr<const LayoutItem_Text> item_text = std::dynamic_pointer_cast<const 
LayoutItem_Text>(layout_item);
+      auto item_text = std::dynamic_pointer_cast<const LayoutItem_Text>(layout_item);
       if(item_text)
       {
         auto pCellText = Gtk::manage( new Gtk::CellRendererText() );
@@ -153,7 +153,7 @@ Gtk::CellRenderer* create_cell(const std::shared_ptr<const LayoutItem>& layout_i
       }
       else
       {
-        std::shared_ptr<const LayoutItem_Button> item_button = std::dynamic_pointer_cast<const 
LayoutItem_Button>(layout_item);
+        auto item_button = std::dynamic_pointer_cast<const LayoutItem_Button>(layout_item);
         if(item_button)
         {
           auto pCellButton = Gtk::manage( new GlomCellRenderer_ButtonText() );
@@ -173,7 +173,7 @@ Gtk::CellRenderer* create_cell(const std::shared_ptr<const LayoutItem>& layout_i
   }
 
   //Use formatting:
-  std::shared_ptr<const LayoutItem_WithFormatting> item_withformatting =
+  auto item_withformatting =
     std::dynamic_pointer_cast<const LayoutItem_WithFormatting>(layout_item);
   if(item_withformatting)
   {
diff --git a/glom/mode_data/datawidget/cellrenderer_dblist.cc 
b/glom/mode_data/datawidget/cellrenderer_dblist.cc
index 974cb52..f891b86 100644
--- a/glom/mode_data/datawidget/cellrenderer_dblist.cc
+++ b/glom/mode_data/datawidget/cellrenderer_dblist.cc
@@ -127,7 +127,7 @@ void CellRendererDbList::repack_cells_fixed(Gtk::CellLayout* combobox)
         cell = Gtk::manage(new Gtk::CellRendererText);
       else if(col < m_db_layout_items.size())
       {
-        std::shared_ptr<const LayoutItem_Field> layout_item = m_db_layout_items[col];
+        auto layout_item = m_db_layout_items[col];
         cell = create_cell(layout_item, m_table_name, m_document, get_fixed_cell_height(*widget));
       }
 
@@ -232,7 +232,7 @@ void CellRendererDbList::on_editing_started(Gtk::CellEditable* cell_editable, co
 
 void CellRendererDbList::set_value(const Gnome::Gda::Value& value)
 {
-  std::shared_ptr<const LayoutItem_Field> layout_item = std::dynamic_pointer_cast<const 
LayoutItem_Field>(get_layout_item());
+  auto layout_item = std::dynamic_pointer_cast<const LayoutItem_Field>(get_layout_item());
   if(!layout_item)
     return;
 
@@ -265,7 +265,7 @@ void CellRendererDbList::set_value(const Gnome::Gda::Value& value)
 
 Gnome::Gda::Value CellRendererDbList::get_value() const
 {
-  std::shared_ptr<const LayoutItem_Field> layout_item = std::dynamic_pointer_cast<const 
LayoutItem_Field>(get_layout_item());
+  auto layout_item = std::dynamic_pointer_cast<const LayoutItem_Field>(get_layout_item());
   bool success = false;
 
   const auto text = get_text();
diff --git a/glom/mode_data/datawidget/combo.cc b/glom/mode_data/datawidget/combo.cc
index 9bc8423..f58abb6 100644
--- a/glom/mode_data/datawidget/combo.cc
+++ b/glom/mode_data/datawidget/combo.cc
@@ -70,7 +70,7 @@ void ComboGlom::on_fixed_cell_data(const Gtk::TreeModel::iterator& iter, Gtk::Ce
     return;
 
   const std::shared_ptr<const LayoutItem>& layout_item = get_layout_item();
-  const std::shared_ptr<const LayoutItem_Field> field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(layout_item);
+  const auto field = std::dynamic_pointer_cast<const LayoutItem_Field>(layout_item);
   if(!field)
     return;
 
@@ -117,7 +117,7 @@ void ComboGlom::set_choices_fixed(const Formatting::type_list_values& list_value
     columns_count -= 1; //The last one is the just the extra text-equivalent of the first one, for 
GtkComboBox with has-entry=true, or for translations.
 
   const std::shared_ptr<const LayoutItem>& layout_item = get_layout_item();
-  const std::shared_ptr<const LayoutItem_Field> field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(layout_item);
+  const auto field = std::dynamic_pointer_cast<const LayoutItem_Field>(layout_item);
 
   //For fixed (custom) choices, this will always be 1 column anyway,
   //so the for() loop here is excessive.
@@ -228,7 +228,7 @@ void ComboGlom::check_for_change()
 
 void ComboGlom::set_value(const Gnome::Gda::Value& value)
 {
-  std::shared_ptr<const LayoutItem_Field> layout_item = std::dynamic_pointer_cast<const 
LayoutItem_Field>(get_layout_item());
+  auto layout_item = std::dynamic_pointer_cast<const LayoutItem_Field>(get_layout_item());
   if(!layout_item)
     return;
 
diff --git a/glom/mode_data/datawidget/combo_as_radio_buttons.cc 
b/glom/mode_data/datawidget/combo_as_radio_buttons.cc
index 83469e2..448e1fb 100644
--- a/glom/mode_data/datawidget/combo_as_radio_buttons.cc
+++ b/glom/mode_data/datawidget/combo_as_radio_buttons.cc
@@ -54,7 +54,7 @@ void ComboAsRadioButtons::set_choices_with_second(const type_list_values_with_se
   }
   m_map_buttons.clear();
 
-  std::shared_ptr<LayoutItem_Field> layout_item =
+  auto layout_item =
     std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
   const auto format = layout_item->get_formatting_used();
   std::shared_ptr<const Relationship> choice_relationship;
@@ -84,7 +84,7 @@ void ComboAsRadioButtons::set_choices_with_second(const type_list_values_with_se
         for(const auto& item : extra_fields)
         {
           if(iterValues != extra_values.end()) {
-            const std::shared_ptr<const LayoutItem_Field> item_field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(item);
+            const auto item_field = std::dynamic_pointer_cast<const LayoutItem_Field>(item);
             if(item_field)
             {
               const Gnome::Gda::Value value = *iterValues; //TODO: Use a vector instead?
@@ -126,7 +126,7 @@ void ComboAsRadioButtons::set_choices_fixed(const Formatting::type_list_values&
   Gtk::RadioButton::Group group;
   for(const auto& choicevalue : list_values)
   {
-    std::shared_ptr<const LayoutItem_Field> layout_item = 
std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
+    auto layout_item = std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
     if(layout_item)
     {
       Gnome::Gda::Value value;
@@ -171,7 +171,7 @@ void ComboAsRadioButtons::check_for_change()
   //Validate the input:
   bool success = false;
 
-  std::shared_ptr<const LayoutItem_Field> layout_item = std::dynamic_pointer_cast<const 
LayoutItem_Field>(get_layout_item());
+  auto layout_item = std::dynamic_pointer_cast<const LayoutItem_Field>(get_layout_item());
   const auto value = Conversions::parse_value(layout_item->get_glom_type(), new_text, 
layout_item->get_formatting_used().m_numeric_format, success);
 
   if(success)
@@ -195,7 +195,7 @@ void ComboAsRadioButtons::check_for_change()
 
 void ComboAsRadioButtons::set_value(const Gnome::Gda::Value& value)
 {
-  std::shared_ptr<const LayoutItem_Field> layout_item = std::dynamic_pointer_cast<const 
LayoutItem_Field>(get_layout_item());
+  auto layout_item = std::dynamic_pointer_cast<const LayoutItem_Field>(get_layout_item());
   if(!layout_item)
     return;
 
@@ -228,7 +228,7 @@ void ComboAsRadioButtons::set_text(const Glib::ustring& text)
 
 Gnome::Gda::Value ComboAsRadioButtons::get_value() const
 {
-  std::shared_ptr<const LayoutItem_Field> layout_item = std::dynamic_pointer_cast<const 
LayoutItem_Field>(get_layout_item());
+  auto layout_item = std::dynamic_pointer_cast<const LayoutItem_Field>(get_layout_item());
   bool success = false;
 
   const auto text = get_text();
diff --git a/glom/mode_data/datawidget/combochoices.cc b/glom/mode_data/datawidget/combochoices.cc
index d547d78..1f5d1d9 100644
--- a/glom/mode_data/datawidget/combochoices.cc
+++ b/glom/mode_data/datawidget/combochoices.cc
@@ -44,7 +44,7 @@ ComboChoices::ComboChoices()
 bool ComboChoices::refresh_data_from_database_with_foreign_key(const Document* /* document */, const 
Gnome::Gda::Value& /* foreign_key_value */)
 {
   /** TODO:
-  std::shared_ptr<LayoutItem_Field> layout_item =
+  auto layout_item =
     std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
 
   if(!layout_item || Conversions::value_is_empty(foreign_key_value))
@@ -69,12 +69,12 @@ void ComboChoices::set_choices_related(const Document* /* document */, const std
   /* TODO:
   type_list_values_with_second list_values;
 
-  std::shared_ptr<LayoutItem_Field> layout_item =
+  auto layout_item =
     std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
   if(layout_item)
   {
     bool choice_show_all = false;
-    const std::shared_ptr<const Relationship> choice_relationship =
+    const auto choice_relationship =
       layout_item->get_formatting_used().get_choices_related_relationship(choice_show_all);
 
     //Set the values now because if it will be the same regardless of the foreign key value.
diff --git a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc 
b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
index 8716df5..03ed747 100644
--- a/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
+++ b/glom/mode_data/datawidget/combochoiceswithtreemodel.cc
@@ -132,7 +132,7 @@ void ComboChoicesWithTreeModel::set_choices_with_second(const type_list_values_w
   create_model(columns_count);
 
   //Fill the model with data:
-  std::shared_ptr<LayoutItem_Field> layout_item =
+  auto layout_item =
     std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
   const auto format = layout_item->get_formatting_used();
   std::shared_ptr<const Relationship> choice_relationship;
@@ -176,8 +176,8 @@ void ComboChoicesWithTreeModel::set_choices_with_second(const type_list_values_w
           if(iterValues == extra_values.end())
             break;
 
-          const std::shared_ptr<const LayoutItem> item = extra_field;
-          const std::shared_ptr<const LayoutItem_Field> item_field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(item);
+          const auto item = extra_field;
+          const auto item_field = std::dynamic_pointer_cast<const LayoutItem_Field>(item);
           if(item_field)
           {
             const Gnome::Gda::Value value = *iterValues;
@@ -212,7 +212,7 @@ void ComboChoicesWithTreeModel::set_choices_fixed(const Formatting::type_list_va
     auto iterTree = list_store->append();
     Gtk::TreeModel::Row row = *iterTree;
 
-    std::shared_ptr<const LayoutItem_Field> layout_item = 
std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
+    auto layout_item = std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
     if(!layout_item)
       continue;
     
@@ -264,7 +264,7 @@ void ComboChoicesWithTreeModel::set_choices_related(const Document* document, co
     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:
-  std::shared_ptr<LayoutGroup> layout_choice_extra_full = glom_sharedptr_clone(layout_choice_extra);
+  auto layout_choice_extra_full = glom_sharedptr_clone(layout_choice_extra);
   const auto table_name = choice_relationship->get_to_table();
   document->fill_layout_field_details(table_name,  layout_choice_extra_full);
 
@@ -288,7 +288,7 @@ void ComboChoicesWithTreeModel::set_choices_related(const Document* document, co
 
   if(!foreign_key_value.is_null())
   {
-    const std::shared_ptr<const Field> to_field = document->get_field(to_table, 
choice_relationship->get_to_field());
+    const auto to_field = document->get_field(to_table, choice_relationship->get_to_field());
 
     found_set.m_where_clause = Utils::build_simple_where_expression(
       to_table, to_field, foreign_key_value);
@@ -408,7 +408,7 @@ void ComboChoicesWithTreeModel::on_cell_data(const Gtk::TreeModel::iterator& ite
     return;
 
   const std::shared_ptr<const LayoutItem>& layout_item = m_db_layout_items[model_column_index];
-  std::shared_ptr<const LayoutItem_Field> field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(layout_item);
+  auto field = std::dynamic_pointer_cast<const LayoutItem_Field>(layout_item);
   if(!field)
     return;
 
@@ -452,7 +452,7 @@ int ComboChoicesWithTreeModel::get_fixed_cell_height(Gtk::Widget& widget)
     {
       Glib::ustring font_name;
 
-      const std::shared_ptr<const LayoutItem_WithFormatting> item_withformatting = 
std::dynamic_pointer_cast<const LayoutItem_WithFormatting>(item);
+      const auto item_withformatting = std::dynamic_pointer_cast<const LayoutItem_WithFormatting>(item);
       if(item_withformatting)
       {
          const auto formatting = item_withformatting->get_formatting_used();
diff --git a/glom/mode_data/datawidget/datawidget.cc b/glom/mode_data/datawidget/datawidget.cc
index 5a7e248..0be7cc5 100644
--- a/glom/mode_data/datawidget/datawidget.cc
+++ b/glom/mode_data/datawidget/datawidget.cc
@@ -522,10 +522,10 @@ void DataWidget::on_menupopup_activate_layout()
 {
   //finish_editing();
 
-  std::shared_ptr<LayoutItem_Field> layoutField = 
std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
+  auto layoutField = std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
   if(layoutField)
   {
-    std::shared_ptr<LayoutItem_Field> itemchosen = offer_field_list(m_table_name, layoutField);
+    auto itemchosen = offer_field_list(m_table_name, layoutField);
     if(itemchosen)
     {
       *layoutField = *itemchosen;
@@ -538,10 +538,10 @@ void DataWidget::on_menupopup_activate_layout_properties()
 {
   //finish_editing();
 
-  std::shared_ptr<LayoutItem_Field> layoutField = 
std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
+  auto layoutField = std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
   if(layoutField)
   {
-    std::shared_ptr<LayoutItem_Field> itemchosen = offer_field_layout(layoutField);
+    auto itemchosen = offer_field_layout(layoutField);
     if(itemchosen)
     {
       *layoutField = *itemchosen;
@@ -653,7 +653,7 @@ void DataWidget::on_button_choose_date()
 
 void DataWidget::on_self_style_changed(const Glib::RefPtr<Gtk::Style>& /* style */)
 {
-  std::shared_ptr<LayoutItem_Field> layoutField = 
std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
+  auto layoutField = std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
   set_child_size_by_field(layoutField);
 }
 
@@ -677,10 +677,10 @@ bool DataWidget::offer_related_record_id_find(Gnome::Gda::Value& chosen_id)
 
     //Discover the related table, in the relationship that uses this ID field:
     Glib::ustring related_table_name;
-    std::shared_ptr<const LayoutItem_Field> layoutField = 
std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
+    auto layoutField = std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
     if(layoutField)
     {
-      std::shared_ptr<const Relationship> relationship = 
get_document()->get_field_used_in_relationship_to_one(m_table_name, layoutField);
+      auto relationship = get_document()->get_field_used_in_relationship_to_one(m_table_name, layoutField);
       if(relationship)
         related_table_name = relationship->get_to_table();
     }
@@ -726,10 +726,10 @@ bool DataWidget::offer_related_record_id_new(Gnome::Gda::Value& chosen_id)
 
     //Discover the related table, in the relationship that uses this ID field:
     Glib::ustring related_table_name;
-    std::shared_ptr<const LayoutItem_Field> layoutField = 
std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
+    auto layoutField = std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
     if(layoutField)
     {
-      std::shared_ptr<const Relationship> relationship = 
get_document()->get_field_used_in_relationship_to_one(m_table_name, layoutField);
+      auto relationship = get_document()->get_field_used_in_relationship_to_one(m_table_name, layoutField);
       if(relationship)
         related_table_name = relationship->get_to_table();
     }
diff --git a/glom/mode_data/datawidget/entry.cc b/glom/mode_data/datawidget/entry.cc
index 03d7834..5e4d19e 100644
--- a/glom/mode_data/datawidget/entry.cc
+++ b/glom/mode_data/datawidget/entry.cc
@@ -69,7 +69,7 @@ void Entry::set_layout_item(const std::shared_ptr<LayoutItem>& layout_item, cons
   //Horizontal Alignment:
   Formatting::HorizontalAlignment alignment = 
     Formatting::HorizontalAlignment::LEFT;
-  std::shared_ptr<LayoutItem_Field> layout_field =
+  auto layout_field =
     std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
   if(layout_field)
     alignment = layout_field->get_formatting_used_horizontal_alignment(true /* for details view */);
@@ -91,7 +91,7 @@ void Entry::check_for_change()
     //Validate the input:
     bool success = false;
 
-    std::shared_ptr<const LayoutItem_Field> layout_item = std::dynamic_pointer_cast<const 
LayoutItem_Field>(get_layout_item());
+    auto layout_item = std::dynamic_pointer_cast<const LayoutItem_Field>(get_layout_item());
     Gnome::Gda::Value value = Conversions::parse_value(m_glom_type, get_text(), 
layout_item->get_formatting_used().m_numeric_format, success);
 
     if(success)
@@ -144,7 +144,7 @@ void Entry::on_changed()
 
 void Entry::set_value(const Gnome::Gda::Value& value)
 {
-  std::shared_ptr<const LayoutItem_Field> layout_item = 
std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
+  auto layout_item = std::dynamic_pointer_cast<LayoutItem_Field>(get_layout_item());
   if(!layout_item)
     return;
 
@@ -179,7 +179,7 @@ Gnome::Gda::Value Entry::get_value() const
 {
   bool success = false;
 
-  std::shared_ptr<const LayoutItem_Field> layout_item = std::dynamic_pointer_cast<const 
LayoutItem_Field>(get_layout_item());
+  auto layout_item = std::dynamic_pointer_cast<const LayoutItem_Field>(get_layout_item());
   return Conversions::parse_value(m_glom_type, get_text(), 
layout_item->get_formatting_used().m_numeric_format, success);
 }
 
diff --git a/glom/mode_data/datawidget/label.cc b/glom/mode_data/datawidget/label.cc
index 6428e0d..241a705 100644
--- a/glom/mode_data/datawidget/label.cc
+++ b/glom/mode_data/datawidget/label.cc
@@ -75,7 +75,7 @@ AppWindow* Label::get_appwindow() const
 #ifndef GLOM_ENABLE_CLIENT_ONLY
 void Label::on_menu_properties_activate()
 {
-  std::shared_ptr<LayoutItem_Text> textobject = std::dynamic_pointer_cast<LayoutItem_Text>(m_pLayoutItem);
+  auto textobject = std::dynamic_pointer_cast<LayoutItem_Text>(m_pLayoutItem);
   if(!textobject)
     return;
 
diff --git a/glom/mode_data/datawidget/treemodel_db.cc b/glom/mode_data/datawidget/treemodel_db.cc
index fa928cf..505dc2f 100644
--- a/glom/mode_data/datawidget/treemodel_db.cc
+++ b/glom/mode_data/datawidget/treemodel_db.cc
@@ -209,7 +209,7 @@ DbTreeModel::DbTreeModel(const FoundSet& found_set, const type_vec_const_layout_
   {
     for(const auto& item : layout_items)
     {
-      std::shared_ptr<const LayoutItem_Field> item_field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(item);
+      auto item_field = std::dynamic_pointer_cast<const LayoutItem_Field>(item);
       if(item_field)
       {
         if(item_field->get_glom_type() == Field::glom_field_type::INVALID)
@@ -233,7 +233,7 @@ DbTreeModel::DbTreeModel(const FoundSet& found_set, const type_vec_const_layout_
 
       if( !(layout_item->get_has_relationship_name()) )
       {
-        const std::shared_ptr<const Field> field_full = layout_item->get_full_field_details();
+        const auto field_full = layout_item->get_full_field_details();
         if(!field_full)
           std::cerr << G_STRFUNC << ": The layout item (" << layout_item->get_name() << ") has no field 
details." << std::endl;
         else if(field_full->get_primary_key() )
diff --git a/glom/mode_data/datawidget/treemodel_db_withextratext.cc 
b/glom/mode_data/datawidget/treemodel_db_withextratext.cc
index 6a7716e..9e07c00 100644
--- a/glom/mode_data/datawidget/treemodel_db_withextratext.cc
+++ b/glom/mode_data/datawidget/treemodel_db_withextratext.cc
@@ -42,7 +42,7 @@ DbTreeModelWithExtraText::DbTreeModelWithExtraText(const FoundSet& found_set, co
   int column_index = 0;
   for(const auto& item : layout_items)
   {
-    const std::shared_ptr<const LayoutItem_Field> item_field = 
+    const auto item_field = 
       std::dynamic_pointer_cast<const LayoutItem_Field>(item);
     if(item_field)
     {
diff --git a/glom/mode_data/db_adddel/db_adddel.cc b/glom/mode_data/db_adddel/db_adddel.cc
index 9be073e..f50f646 100644
--- a/glom/mode_data/db_adddel/db_adddel.cc
+++ b/glom/mode_data/db_adddel/db_adddel.cc
@@ -521,7 +521,7 @@ guint DbAddDel::get_fixed_cell_height()
     {
       Glib::ustring font_name;
 
-      std::shared_ptr<const LayoutItem_WithFormatting> item_withformatting = std::dynamic_pointer_cast<const 
LayoutItem_WithFormatting>(*iter);
+      auto item_withformatting = std::dynamic_pointer_cast<const LayoutItem_WithFormatting>(*iter);
       if(item_withformatting)
       {
          const auto formatting = item_withformatting->get_formatting_used();
@@ -561,7 +561,7 @@ Gtk::CellRenderer* DbAddDel::construct_specified_columns_cellrenderer(const std:
 
   auto pCellRenderer = create_cell(layout_item, m_table_name, get_document(), get_fixed_cell_height());
 
-  std::shared_ptr<const LayoutItem_Field> item_field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(layout_item);
+  auto item_field = std::dynamic_pointer_cast<const LayoutItem_Field>(layout_item);
 
   //Set extra cellrenderer attributes, depending on the type used,
   //to support editing:
@@ -609,7 +609,7 @@ Gtk::CellRenderer* DbAddDel::construct_specified_columns_cellrenderer(const std:
   auto pCellButton = Gtk::manage( new GlomCellRenderer_ButtonText() );
   if(pCellButton)
   {
-    std::shared_ptr<const LayoutItem_Button> item_button = std::dynamic_pointer_cast<const 
LayoutItem_Button>(layout_item);
+    auto item_button = std::dynamic_pointer_cast<const LayoutItem_Button>(layout_item);
     if(item_button)
     {
       pCellButton->signal_clicked().connect(
@@ -705,7 +705,7 @@ void DbAddDel::construct_specified_columns()
       // Whenever we are dealing with real database fields,
       // we need to know the index of the field in the query:
       int item_data_model_column_index = -1;
-      std::shared_ptr<const LayoutItem_Field> item_field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(layout_item);
+      auto item_field = std::dynamic_pointer_cast<const LayoutItem_Field>(layout_item);
       if(item_field)
       {
         item_data_model_column_index = data_model_column_index;
@@ -861,8 +861,8 @@ void DbAddDel::refresh_cell_choices_data_from_database_with_foreign_key(guint mo
     return;
   }
 
-  std::shared_ptr<const LayoutItem> item = m_column_items[model_index];
-  std::shared_ptr<const LayoutItem_Field> layout_field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(item);
+  auto item = m_column_items[model_index];
+  auto layout_field = std::dynamic_pointer_cast<const LayoutItem_Field>(item);
   if(!layout_field)
   {
     std::cerr << G_STRFUNC << ": The layout item was not a LayoutItem_Field." << std::endl;
@@ -913,10 +913,10 @@ void DbAddDel::set_columns(const LayoutGroup::type_list_items& layout_items)
     //Make it non-editable if it is auto-generated:
     //TODO: Actually use this bool:
     /*
-    std::shared_ptr<const LayoutItem_Field> field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(layout_item);
+    auto field = std::dynamic_pointer_cast<const LayoutItem_Field>(layout_item);
     if(field)
     {
-      std::shared_ptr<const Field> field_full = field->get_full_field_details();
+      auto field_full = field->get_full_field_details();
       if(field_full && field_full->get_auto_increment())
         column_info.m_editable = false;
       else
@@ -953,7 +953,7 @@ DbAddDel::type_list_indexes DbAddDel::get_data_model_column_index(const std::sha
   guint data_model_column_index = 0;
   for(const auto& item : m_column_items)
   {
-    std::shared_ptr<const LayoutItem_Field> field = std::dynamic_pointer_cast<const LayoutItem_Field>(item); 
//TODO_Performance: This would be unnecessary if !layout_item_field
+    auto field = std::dynamic_pointer_cast<const LayoutItem_Field>(item); //TODO_Performance: This would be 
unnecessary if !layout_item_field
     if(field)
     {
       if(field->is_same_field(layout_item_field)
@@ -981,12 +981,12 @@ DbAddDel::type_list_indexes DbAddDel::get_column_index(const std::shared_ptr<con
     return list_indexes;
   }
 
-  std::shared_ptr<const LayoutItem_Field> layout_item_field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(layout_item);
+  auto layout_item_field = std::dynamic_pointer_cast<const LayoutItem_Field>(layout_item);
 
   guint i = 0;
   for(const auto& item : m_column_items)
   {
-    const std::shared_ptr<const LayoutItem_Field> field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(item); //TODO_Performance: This would be unnecessary if !layout_item_field
+    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))
     {
       list_indexes.push_back(i);
@@ -1014,14 +1014,14 @@ DbAddDel::type_list_indexes DbAddDel::get_choice_index(const std::shared_ptr<con
   guint index = 0;
   for(const auto& item : m_column_items)
   {
-    std::shared_ptr<const LayoutItem_Field> field = std::dynamic_pointer_cast<const LayoutItem_Field>(item);
+    auto field = std::dynamic_pointer_cast<const LayoutItem_Field>(item);
     if(!field)
        continue;
 
     const auto format = field->get_formatting_used();
 
     bool choice_show_all = false;
-    const std::shared_ptr<const Relationship> choice_relationship =
+    const auto choice_relationship =
       format.get_choices_related_relationship(choice_show_all);
     if(choice_relationship && !choice_show_all) //"Show All" choices don't use the ID field values.
     {
@@ -1040,7 +1040,7 @@ std::shared_ptr<const LayoutItem_Field> DbAddDel::get_column_field(guint column_
 {
   if(column_index < m_column_items.size())
   {
-    std::shared_ptr<LayoutItem_Field> field = std::dynamic_pointer_cast<LayoutItem_Field>( 
m_column_items[column_index] );
+    auto field = std::dynamic_pointer_cast<LayoutItem_Field>( m_column_items[column_index] );
     if(field)
       return field;
   }
@@ -1261,8 +1261,8 @@ void DbAddDel::on_cell_layout_button_clicked(const Gtk::TreeModel::Path& path, i
   auto iter = m_refListStore->get_iter(path);
   if(iter)
   {
-    std::shared_ptr<const LayoutItem> layout_item = m_column_items[model_column_index];
-    std::shared_ptr<const LayoutItem_Button> item_button = std::dynamic_pointer_cast<const 
LayoutItem_Button>(layout_item);
+    auto layout_item = m_column_items[model_column_index];
+    auto item_button = std::dynamic_pointer_cast<const LayoutItem_Button>(layout_item);
     if(item_button)
     {
       m_signal_script_button_clicked.emit(item_button, iter);
@@ -1443,7 +1443,7 @@ void DbAddDel::on_treeview_cell_edited(const Glib::ustring& path_string, const G
     }
 
 
-    std::shared_ptr<LayoutItem_Field> item_field = 
std::dynamic_pointer_cast<LayoutItem_Field>(m_column_items[model_column_index]);
+    auto item_field = std::dynamic_pointer_cast<LayoutItem_Field>(m_column_items[model_column_index]);
     if(!item_field)
       return;
 
@@ -1578,7 +1578,7 @@ void DbAddDel::on_treeview_column_clicked(int model_column_index)
   if(model_column_index >= (int)m_column_items.size())
     return;
 
-  std::shared_ptr<const LayoutItem_Field> layout_item = std::dynamic_pointer_cast<const 
LayoutItem_Field>(m_column_items[model_column_index]); //We can only sort on fields, not on other layout item.
+  auto layout_item = std::dynamic_pointer_cast<const LayoutItem_Field>(m_column_items[model_column_index]); 
//We can only sort on fields, not on other layout item.
   if(layout_item && layout_item->get_name_not_empty())
   {
     bool ascending = true;
@@ -1639,7 +1639,7 @@ bool DbAddDel::get_column_to_expand(guint& column_to_expand) const
   guint i = 0;
   for(const auto& layout_item : m_column_items)
   {
-    std::shared_ptr<LayoutItem_Field> layout_item_field = 
std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+    auto layout_item_field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
     if(layout_item_field)
     {
       //Only text columns should expand.
@@ -1676,8 +1676,8 @@ guint DbAddDel::treeview_append_column(const Glib::ustring& title, Gtk::CellRend
 
   guint cols_count = m_TreeView.append_column(*pViewColumn);
 
-  std::shared_ptr<const LayoutItem> layout_item = m_column_items[model_column_index];
-  std::shared_ptr<const LayoutItem_Field> layout_item_field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(layout_item);
+  auto layout_item = m_column_items[model_column_index];
+  auto layout_item_field = std::dynamic_pointer_cast<const LayoutItem_Field>(layout_item);
 
   //Tell the Treeview.how to render the Gnome::Gda::Values:
   if(layout_item_field)
@@ -1874,7 +1874,7 @@ void DbAddDel::treeviewcolumn_on_cell_data(Gtk::CellRenderer* renderer, const Gt
   {
     const std::shared_ptr<LayoutItem>& layout_item = m_column_items[model_column_index];
 
-    std::shared_ptr<LayoutItem_Field> field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+    auto field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
     if(field)
     {
       const guint col_real = data_model_column_index + get_count_hidden_system_columns();
@@ -2055,13 +2055,13 @@ bool DbAddDel::start_new_record()
   if(!bPresent)
     return false;
 
-  std::shared_ptr<Field> fieldPrimaryKey = get_key_field();
+  auto fieldPrimaryKey = get_key_field();
   if(fieldPrimaryKey && fieldPrimaryKey->get_auto_increment())
   {
     //Start editing in the first cell that is not auto_increment:
     for(const auto& layout_item : m_column_items)
     {
-      std::shared_ptr<LayoutItem_Field> layout_item_field = 
std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+      auto layout_item_field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
       if(!(layout_item_field->get_full_field_details()->get_auto_increment()))
       {
         fieldToEdit = layout_item_field;
@@ -2097,7 +2097,7 @@ void DbAddDel::user_changed(const Gtk::TreeModel::iterator& row, guint col)
   const auto parent_primary_key_value = get_value_key(row);
   //std::cout << "debug: " << G_STRFUNC << ": parent_primary_key_value=" << 
parent_primary_key_value.to_string() << std::endl;
 
-  std::shared_ptr<const LayoutItem_Field> layout_field = get_column_field(col);
+  auto layout_field = get_column_field(col);
 
   if(!Conversions::value_is_empty(parent_primary_key_value)) //If the record's primary key is filled in:
   {
@@ -2123,7 +2123,7 @@ void DbAddDel::user_changed(const Gtk::TreeModel::iterator& row, guint col)
 
         auto document = dynamic_cast<Document*>(get_document());
 
-        std::shared_ptr<Relationship> relationship = document->get_relationship(m_found_set.m_table_name, 
relationship_name);
+        auto relationship = document->get_relationship(m_found_set.m_table_name, relationship_name);
         if(relationship)
         {
           table_name = relationship->get_to_table();
@@ -2134,7 +2134,7 @@ 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)
-            std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+            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_value_selected(layout_item);
@@ -2262,7 +2262,7 @@ void DbAddDel::user_added(const Gtk::TreeModel::iterator& row)
 
   Gnome::Gda::Value primary_key_value;
 
-  std::shared_ptr<const Field> primary_key_field = get_key_field();
+  auto primary_key_field = get_key_field();
 
   //Get the new primary key value, if one is available now:
   if(primary_key_field->get_auto_increment())
@@ -2278,7 +2278,7 @@ 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();
 
-    std::shared_ptr<LayoutItem_Field> layout_field = std::make_shared<LayoutItem_Field>();
+    auto layout_field = std::make_shared<LayoutItem_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;
@@ -2288,7 +2288,7 @@ void DbAddDel::user_added(const Gtk::TreeModel::iterator& row)
   if(Conversions::value_is_empty(primary_key_value))
     return;
 
-  std::shared_ptr<SharedConnection> sharedconnection = connect_to_server(get_appwindow()); //Keep it alive 
while we need the data_model.
+  auto sharedconnection = connect_to_server(get_appwindow()); //Keep it alive while we need the data_model.
   if(!sharedconnection)
   {
     //Add Record failed.
@@ -2298,7 +2298,7 @@ void DbAddDel::user_added(const Gtk::TreeModel::iterator& row)
   }
 
 
-  std::shared_ptr<LayoutItem_Field> layout_field = std::make_shared<LayoutItem_Field>();
+  auto layout_field = std::make_shared<LayoutItem_Field>();
   layout_field->set_full_field_details(primary_key_field);
   if(!check_entered_value_for_uniqueness(m_found_set.m_table_name, layout_field, primary_key_value, 
get_appwindow()))
   {
@@ -2326,7 +2326,7 @@ 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())
   {
-    std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
+    auto layout_item = std::make_shared<LayoutItem_Field>();
     layout_item->set_full_field_details(primary_key_field);
     set_value(row, layout_item, primary_key_value);
   }
diff --git a/glom/mode_data/flowtablewithfields.cc b/glom/mode_data/flowtablewithfields.cc
index f3933a7..1319ec7 100644
--- a/glom/mode_data/flowtablewithfields.cc
+++ b/glom/mode_data/flowtablewithfields.cc
@@ -95,13 +95,13 @@ void FlowTableWithFields::set_table(const Glib::ustring& table_name)
 void FlowTableWithFields::add_layout_item(const std::shared_ptr<LayoutItem>& item)
 {
   //Get derived type and do the appropriate thing:
-  std::shared_ptr<LayoutItem_Field> field = std::dynamic_pointer_cast<LayoutItem_Field>(item);
+  auto field = std::dynamic_pointer_cast<LayoutItem_Field>(item);
   if(field)
   {
     add_field(field, m_table_name);
 
     //Do not allow editing of auto-increment fields:
-    std::shared_ptr<const Field> field_details = field->get_full_field_details();
+    auto field_details = field->get_full_field_details();
     if(field_details)
     {
       if(field_details->get_auto_increment())
@@ -112,36 +112,36 @@ void FlowTableWithFields::add_layout_item(const std::shared_ptr<LayoutItem>& ite
   }
   else
   {
-    std::shared_ptr<LayoutItem_Portal> portal = std::dynamic_pointer_cast<LayoutItem_Portal>(item);
+    auto portal = std::dynamic_pointer_cast<LayoutItem_Portal>(item);
     if(portal)
     {
       add_layout_portal(portal);
     }
     else
     {
-      std::shared_ptr<LayoutItem_Notebook> notebook = std::dynamic_pointer_cast<LayoutItem_Notebook>(item);
+      auto notebook = std::dynamic_pointer_cast<LayoutItem_Notebook>(item);
       if(notebook)
       {
         add_layout_notebook(notebook);
       }
       else
       {
-        std::shared_ptr<LayoutGroup> group = std::dynamic_pointer_cast<LayoutGroup>(item);
+        auto group = std::dynamic_pointer_cast<LayoutGroup>(item);
         if(group)
           add_layout_group(group);
         else
         {
-          std::shared_ptr<LayoutItem_Button> layout_button = 
std::dynamic_pointer_cast<LayoutItem_Button>(item);
+          auto layout_button = std::dynamic_pointer_cast<LayoutItem_Button>(item);
           if(layout_button)
             add_button(layout_button, m_table_name);
           else
           {
-            std::shared_ptr<LayoutItem_Text> layout_textobject = 
std::dynamic_pointer_cast<LayoutItem_Text>(item);
+            auto layout_textobject = std::dynamic_pointer_cast<LayoutItem_Text>(item);
             if(layout_textobject)
               add_textobject(layout_textobject, m_table_name);
             else
             {
-              std::shared_ptr<LayoutItem_Image> layout_imageobject = 
std::dynamic_pointer_cast<LayoutItem_Image>(item);
+              auto layout_imageobject = std::dynamic_pointer_cast<LayoutItem_Image>(item);
               if(layout_imageobject)
                 add_imageobject(layout_imageobject, m_table_name);
             }
@@ -263,7 +263,7 @@ Box_Data_List_Related* FlowTableWithFields::create_related(const std::shared_ptr
       portal_box->init_db_details(m_table_name, show_title);
 
     Glib::ustring to_table;
-    std::shared_ptr<Relationship> relationship = pDocument->get_relationship(m_table_name, 
portal->get_relationship_name());
+    auto relationship = pDocument->get_relationship(m_table_name, portal->get_relationship_name());
     if(relationship)
       to_table = relationship->get_to_table();
 
@@ -303,7 +303,7 @@ Box_Data_Calendar_Related* FlowTableWithFields::create_related_calendar(const st
       portal_box->init_db_details(m_table_name, show_title);
 
     Glib::ustring to_table;
-    std::shared_ptr<Relationship> relationship = pDocument->get_relationship(m_table_name, 
portal->get_relationship_name());
+    auto relationship = pDocument->get_relationship(m_table_name, portal->get_relationship_name());
     if(relationship)
       to_table = relationship->get_to_table();
 
@@ -327,7 +327,7 @@ Box_Data_Calendar_Related* FlowTableWithFields::create_related_calendar(const st
 void FlowTableWithFields::add_layout_portal(const std::shared_ptr<LayoutItem_Portal>& portal)
 {
   Box_Data_Portal* portal_box = nullptr;
-  std::shared_ptr<LayoutItem_CalendarPortal> calendar_portal = 
std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(portal);
+  auto calendar_portal = std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(portal);
   if(calendar_portal)
     portal_box = create_related_calendar(calendar_portal);
   else
@@ -368,7 +368,7 @@ void FlowTableWithFields::add_layout_notebook(const std::shared_ptr<LayoutItem_N
 
       tab_label->set_label(item_get_title_or_name(group));
 
-      std::shared_ptr<LayoutItem_Portal> portal = std::dynamic_pointer_cast<LayoutItem_Portal>(group);
+      auto portal = std::dynamic_pointer_cast<LayoutItem_Portal>(group);
       if(portal)
       {
         //Add a Related Records list for this portal:
@@ -751,8 +751,8 @@ void FlowTableWithFields::update_choices(const std::shared_ptr<const LayoutItem_
     if(!combo)
       continue;
 
-    const std::shared_ptr<const LayoutItem> layout_item = combo->get_layout_item();
-    const std::shared_ptr<const LayoutItem_Field> layout_item_field = 
+    const auto layout_item = combo->get_layout_item();
+    const auto layout_item_field = 
       std::dynamic_pointer_cast<const LayoutItem_Field>(layout_item);
     if(!layout_item_field || !layout_item_field->get_formatting_used().get_has_related_choices())
       continue;
@@ -777,10 +777,10 @@ FlowTableWithFields::type_portals FlowTableWithFields::get_portals(const std::sh
     //*iter is a FlowTableItem.
     if(pPortalUI)
     {
-      std::shared_ptr<LayoutItem_Portal> portal = pPortalUI->get_portal();
+      auto portal = pPortalUI->get_portal();
       if(portal)
       {
-        std::shared_ptr<const Relationship> relationship = portal->get_relationship(); //In this case, we 
only care about the first relationship (not any child relationships), because that's what would trigger a 
change.
+        auto relationship = portal->get_relationship(); //In this case, we only care about the first 
relationship (not any child relationships), because that's what would trigger a change.
         if(relationship && (relationship->get_from_field() == from_key_name))
           result.push_back(pPortalUI);
       }
@@ -828,9 +828,9 @@ FlowTableWithFields::type_choice_widgets FlowTableWithFields::get_choice_widgets
     if(!combochoices)
       continue;
 
-    const std::shared_ptr<const LayoutItem> layout_item =
+    const auto layout_item =
       combochoices->get_layout_item();
-    const std::shared_ptr<const LayoutItem_Field> field =
+    const auto field =
        std::dynamic_pointer_cast<const LayoutItem_Field>(layout_item);
     if(!field)
       continue;
@@ -838,7 +838,7 @@ FlowTableWithFields::type_choice_widgets FlowTableWithFields::get_choice_widgets
     const auto format = field->get_formatting_used();
 
     bool choice_show_all = false;
-    const std::shared_ptr<const Relationship> choice_relationship =
+    const auto choice_relationship =
       format.get_choices_related_relationship(choice_show_all);
     if(choice_show_all)
       continue; //"Show All" choices don't use the ID field values.
@@ -1058,7 +1058,7 @@ void FlowTableWithFields::on_datawidget_layout_item_added(LayoutWidgetBase::enum
   //so the new item will be after that item, next to it.
 
   //Get the widget's layout item:
-  std::shared_ptr<const LayoutItem> layout_item_parent = pDataWidget->get_layout_item();
+  auto layout_item_parent = pDataWidget->get_layout_item();
   if(!layout_item_parent)
   {
     std::cerr << G_STRFUNC << ": layout_item_parent is null." << std::endl;
@@ -1068,7 +1068,7 @@ void FlowTableWithFields::on_datawidget_layout_item_added(LayoutWidgetBase::enum
   //std::cout << "debug: layout_item_parent name=" << layout_item_parent->get_name() << std::endl;
 
   //Get the group that the widget's layout item is in:
-  std::shared_ptr<LayoutGroup> layout_group = std::dynamic_pointer_cast<LayoutGroup>(get_layout_item());
+  auto layout_group = std::dynamic_pointer_cast<LayoutGroup>(get_layout_item());
   if(!layout_group)
   {
     std::cerr << G_STRFUNC << ": layout_group is null." << std::endl;
@@ -1080,7 +1080,7 @@ void FlowTableWithFields::on_datawidget_layout_item_added(LayoutWidgetBase::enum
   std::shared_ptr<LayoutItem> layout_item_new;
   if(item_type == LayoutWidgetBase::enumType::FIELD)
   {
-    std::shared_ptr<LayoutItem_Field> layout_item_field = pDataWidget->offer_field_list(m_table_name);
+    auto layout_item_field = pDataWidget->offer_field_list(m_table_name);
     if(layout_item_field)
     {
       //TODO: privileges.
@@ -1089,17 +1089,17 @@ void FlowTableWithFields::on_datawidget_layout_item_added(LayoutWidgetBase::enum
   }
   else if(item_type == LayoutWidgetBase::enumType::GROUP)
   {
-    std::shared_ptr<LayoutGroup> layout_item = std::make_shared<LayoutGroup>();
+    auto layout_item = std::make_shared<LayoutGroup>();
     layout_item->set_title_original(_("New Group"));
     layout_item_new = layout_item;
   }
   else if(item_type == LayoutWidgetBase::enumType::NOTEBOOK)
   {
-    std::shared_ptr<LayoutItem_Notebook> layout_item = std::make_shared<LayoutItem_Notebook>();
+    auto layout_item = std::make_shared<LayoutItem_Notebook>();
     layout_item->set_name(_("notebook"));
 
     //Add an example tab, so that it shows up.
-    std::shared_ptr<LayoutGroup> group_tab = std::make_shared<LayoutGroup>();
+    auto group_tab = std::make_shared<LayoutGroup>();
 
     //Note to translators: This is the default name (not seen by most users) for a notebook tab.
     group_tab->set_name(_("tab1"));
@@ -1117,14 +1117,14 @@ void FlowTableWithFields::on_datawidget_layout_item_added(LayoutWidgetBase::enum
   }
   else if(item_type == LayoutWidgetBase::enumType::BUTTON)
   {
-    std::shared_ptr<LayoutItem_Button> layout_item = std::make_shared<LayoutItem_Button>();
+    auto layout_item = std::make_shared<LayoutItem_Button>();
     layout_item->set_name(_("button"));
     layout_item->set_title_original(_("New Button"));
     layout_item_new = layout_item;
   }
   else if(item_type == LayoutWidgetBase::enumType::TEXT)
   {
-    std::shared_ptr<LayoutItem_Text> layout_item = std::make_shared<LayoutItem_Text>();
+    auto layout_item = std::make_shared<LayoutItem_Text>();
     layout_item->set_name(_("text"));
     layout_item->set_text_original(_("New Text"));
     layout_item_new = layout_item;
@@ -1145,7 +1145,7 @@ void FlowTableWithFields::on_datawidget_layout_item_added(LayoutWidgetBase::enum
 //TODO: Use Value by const &
 void FlowTableWithFields::on_portal_user_requested_details(Gnome::Gda::Value primary_key_value, 
Box_Data_Portal* portal_box)
 {
-  std::shared_ptr<const LayoutItem_Portal> portal = portal_box->get_portal();
+  auto portal = portal_box->get_portal();
   if(!portal)
     return;
 
@@ -1259,7 +1259,7 @@ void FlowTableWithFields::on_menu_properties_activate()
   const auto response = dialog->run();
   if(response == Gtk::RESPONSE_OK)
   {
-    std::shared_ptr<LayoutGroup> group = get_layout_group();
+    auto group = get_layout_group();
     group->set_columns_count( dialog->get_columns_count() );
     group->set_title(dialog->get_title(), AppWindow::get_current_locale());
     signal_layout_changed().emit();
@@ -1329,10 +1329,10 @@ std::shared_ptr<LayoutItem_Portal> FlowTableWithFields::get_portal_relationship(
   if(response == Gtk::RESPONSE_OK)
   {
     //Get the chosen relationship:
-    std::shared_ptr<Relationship> relationship  = dialog->get_relationship_chosen();
+    auto relationship  = dialog->get_relationship_chosen();
     if(relationship)
     {
-      std::shared_ptr<LayoutItem_Portal> layout_item = std::make_shared<LayoutItem_Portal>();
+      auto layout_item = std::make_shared<LayoutItem_Portal>();
       layout_item->set_relationship(relationship);
       delete dialog;
       return layout_item;
diff --git a/glom/mode_data/notebook_data.cc b/glom/mode_data/notebook_data.cc
index 2f08b1d..971f864 100644
--- a/glom/mode_data/notebook_data.cc
+++ b/glom/mode_data/notebook_data.cc
@@ -105,7 +105,7 @@ bool Notebook_Data::init_db_details(const FoundSet& found_set, const Gnome::Gda:
   //Performance optimisation:
   //Keep the connection open during all these operations:
   {
-    std::shared_ptr<SharedConnection> sharedconnection = connect_to_server(get_app_window());
+    auto sharedconnection = connect_to_server(get_app_window());
 
     result = m_Box_List.init_db_details(found_set, get_active_layout_platform(get_document())); //TODO: 
Select the last selected record.
 
@@ -257,7 +257,7 @@ FoundSet Notebook_Data::get_found_set_selected() const
       return found_set;
     }
     
-    std::shared_ptr<Field> primary_key_field =
+    auto primary_key_field =
       document->get_field_primary_key(m_table_name);
     found_set.m_where_clause = Utils::build_simple_where_expression(
       m_table_name, primary_key_field,
diff --git a/glom/mode_design/box_db_table_relationships.cc b/glom/mode_design/box_db_table_relationships.cc
index 95b890f..bd678f0 100644
--- a/glom/mode_design/box_db_table_relationships.cc
+++ b/glom/mode_design/box_db_table_relationships.cc
@@ -82,7 +82,7 @@ bool Box_DB_Table_Relationships::fill_from_database()
 
   m_AddDel.remove_all();
 
-  std::shared_ptr<SharedConnection> sharedconnection = connect_to_server(get_app_window());
+  auto sharedconnection = connect_to_server(get_app_window());
   if(sharedconnection)
   {
     Glib::RefPtr<Gnome::Gda::Connection> connection = sharedconnection->get_gda_connection();
@@ -149,7 +149,7 @@ void Box_DB_Table_Relationships::save_to_document()
 
       if(find_if_same_name_exists(vecRelationships, name)) //Don't add 2 relationships with the same name.
       {
-        std::shared_ptr<Relationship> relationship = document->get_relationship(m_table_name, name); 
//Preserve other information, such as translations.
+        auto relationship = document->get_relationship(m_table_name, name); //Preserve other information, 
such as translations.
         if(!relationship)
           relationship = std::make_shared<Relationship>();
 
@@ -238,7 +238,7 @@ void Box_DB_Table_Relationships::on_adddel_user_activated(const Gtk::TreeModel::
       //Set list of 'To' fields depending on table:
       m_AddDel.set_value(row, m_colToField, Glib::ustring(""));
 
-      std::shared_ptr<SharedConnection> sharedconnection = connect_to_server(get_app_window());
+      auto sharedconnection = connect_to_server(get_app_window());
       if(sharedconnection)
       {
         Glib::RefPtr<Gnome::Gda::Connection> connection = sharedconnection->get_gda_connection();
@@ -277,7 +277,7 @@ void Box_DB_Table_Relationships::on_adddel_user_requested_delete(const Gtk::Tree
     auto document = get_document();
     if(document)
     {
-      std::shared_ptr<const Relationship> relationship = document->get_relationship(m_table_name, 
relationship_name);
+      auto relationship = document->get_relationship(m_table_name, relationship_name);
       if(relationship)
       {
         document->remove_relationship(relationship);
diff --git a/glom/mode_design/dialog_database_preferences.cc b/glom/mode_design/dialog_database_preferences.cc
index a179946..231d9e3 100644
--- a/glom/mode_design/dialog_database_preferences.cc
+++ b/glom/mode_design/dialog_database_preferences.cc
@@ -263,7 +263,7 @@ void Dialog_Database_Preferences::on_button_test_script()
     return;
 
   //We need the connection when we run the script, so that the script may use it.
-  std::shared_ptr<SharedConnection> sharedconnection = connect_to_server(this /* parent window */);
+  auto sharedconnection = connect_to_server(this /* parent window */);
 
   Glib::ustring error_message; //TODO: Check this and tell the user.
   PythonUICallbacks callbacks;
diff --git a/glom/mode_design/fields/box_db_table_definition.cc 
b/glom/mode_design/fields/box_db_table_definition.cc
index e19232c..937b195 100644
--- a/glom/mode_design/fields/box_db_table_definition.cc
+++ b/glom/mode_design/fields/box_db_table_definition.cc
@@ -369,7 +369,7 @@ void Box_DB_Table_Definition::on_adddel_changed(const Gtk::TreeModel::iterator&
   {
     const auto strFieldNameBeingEdited = m_AddDel.get_value_key(row);
 
-    std::shared_ptr<const Field> constfield = pDoc->get_field(m_table_name, strFieldNameBeingEdited);
+    auto constfield = pDoc->get_field(m_table_name, strFieldNameBeingEdited);
     m_Field_BeingEdited = constfield;
 
     //Get DB field info: (TODO: This might be unnecessary).
@@ -378,11 +378,11 @@ void Box_DB_Table_Definition::on_adddel_changed(const Gtk::TreeModel::iterator&
       std::cerr << G_STRFUNC << ": field not found: " << strFieldNameBeingEdited << std::endl;
     else
     {
-      std::shared_ptr<const Field> const_field_found = *iterFind;
+      auto const_field_found = *iterFind;
       m_Field_BeingEdited = const_field_found;
 
       //Get new field definition:
-      std::shared_ptr<Field> fieldNew = get_field_definition(row);
+      auto fieldNew = get_field_definition(row);
 
       //Change it:
       if(*m_Field_BeingEdited != *fieldNew) //If it has really changed.
@@ -390,7 +390,7 @@ void Box_DB_Table_Definition::on_adddel_changed(const Gtk::TreeModel::iterator&
         const auto bcontinue = check_field_change(m_Field_BeingEdited, fieldNew);
         if(bcontinue)
         {
-          std::shared_ptr<Field> fieldNewWithModifications = change_definition(m_Field_BeingEdited, 
fieldNew);
+          auto fieldNewWithModifications = change_definition(m_Field_BeingEdited, fieldNew);
 
           //Update the row to show any extra changes (such as unique being set/unset whenever the primary 
key is set/unset) 
          // TODO: When change_definition decides to unset another column from
@@ -410,7 +410,7 @@ void Box_DB_Table_Definition::on_adddel_changed(const Gtk::TreeModel::iterator&
 
 void Box_DB_Table_Definition::on_adddel_edit(const Gtk::TreeModel::iterator& row)
 {
-  std::shared_ptr<const Field> constfield = get_field_definition(row);
+  auto constfield = get_field_definition(row);
   m_Field_BeingEdited = constfield;
 
   m_dialog_field_definition->set_field(m_Field_BeingEdited, m_table_name);
@@ -426,7 +426,7 @@ void Box_DB_Table_Definition::on_adddel_edit(const Gtk::TreeModel::iterator& row
 
 void Box_DB_Table_Definition::on_adddel_extra(const Gtk::TreeModel::iterator& row)
 {
-  std::shared_ptr<const Field> constfield = get_field_definition(row);
+  auto constfield = get_field_definition(row);
   m_Field_BeingEdited = constfield;
 
   m_dialog_default_formatting->set_field(m_Field_BeingEdited, m_table_name);
@@ -471,7 +471,7 @@ std::shared_ptr<Field> Box_DB_Table_Definition::get_field_definition(const Gtk::
 
   //Start with original definitions, so that we preserve things like UNSIGNED.
   //TODO maybe use document's fieldinfo instead of m_vecFields.
-  std::shared_ptr<const Field> field_temp = 
+  auto field_temp = 
     DbUtils::get_fields_for_table_one_field(pDoc, m_table_name, strFieldNameBeforeEdit);
   if(field_temp)
   {
@@ -518,7 +518,7 @@ std::shared_ptr<Field> Box_DB_Table_Definition::get_field_definition(const Gtk::
 
 void Box_DB_Table_Definition::on_field_definition_apply()
 {
-  std::shared_ptr<Field> field_New = m_dialog_field_definition->get_field();
+  auto field_New = m_dialog_field_definition->get_field();
 
   if(*m_Field_BeingEdited != *field_New)
   {
@@ -558,10 +558,10 @@ std::shared_ptr<Field> Box_DB_Table_Definition::change_definition(const std::sha
     {
       //Unset the current primary key:
       //(There should be one.)
-      std::shared_ptr<Field> existing_primary_key = get_field_primary_key_for_table(m_table_name);
+      auto existing_primary_key = get_field_primary_key_for_table(m_table_name);
       if(existing_primary_key)
       {
-        std::shared_ptr<Field> existing_primary_key_unset = glom_sharedptr_clone(existing_primary_key);
+        auto existing_primary_key_unset = glom_sharedptr_clone(existing_primary_key);
         existing_primary_key_unset->set_primary_key(false);
        old_fields.push_back(existing_primary_key);
        new_fields.push_back(existing_primary_key_unset);
diff --git a/glom/mode_design/fields/dialog_defaultformatting.cc 
b/glom/mode_design/fields/dialog_defaultformatting.cc
index 67c1163..503596c 100644
--- a/glom/mode_design/fields/dialog_defaultformatting.cc
+++ b/glom/mode_design/fields/dialog_defaultformatting.cc
@@ -81,9 +81,9 @@ void Dialog_DefaultFormatting::set_field(const std::shared_ptr<const Field>& fie
 
 std::shared_ptr<Field> Dialog_DefaultFormatting::get_field() const
 {
-  std::shared_ptr<Field> field = glom_sharedptr_clone(m_Field); //Start with the old details, to preserve 
anything that is not in our UI.
+  auto field = glom_sharedptr_clone(m_Field); //Start with the old details, to preserve anything that is not 
in our UI.
   // const_cast is necessary and save here for the window (jhs)
-  std::shared_ptr<SharedConnection> sharedcnc = 
connect_to_server(const_cast<Dialog_DefaultFormatting*>(this));
+  auto sharedcnc = connect_to_server(const_cast<Dialog_DefaultFormatting*>(this));
   Glib::RefPtr<Gnome::Gda::Connection> cnc = sharedcnc->get_gda_connection();
 
   //Get the field info from the widgets:
diff --git a/glom/mode_design/fields/dialog_fieldcalculation.cc 
b/glom/mode_design/fields/dialog_fieldcalculation.cc
index 6b60ebe..15126bb 100644
--- a/glom/mode_design/fields/dialog_fieldcalculation.cc
+++ b/glom/mode_design/fields/dialog_fieldcalculation.cc
@@ -85,7 +85,7 @@ void Dialog_FieldCalculation::set_field(const std::shared_ptr<const Field>& fiel
 
 std::shared_ptr<Field> Dialog_FieldCalculation::get_field() const
 {
-  std::shared_ptr<Field> field = glom_sharedptr_clone(m_field); //Start with the old details, to preserve 
anything that is not in our UI.
+  auto field = glom_sharedptr_clone(m_field); //Start with the old details, to preserve anything that is not 
in our UI.
 
   field->set_calculation( m_text_view->get_buffer()->get_text() );
 
@@ -125,7 +125,7 @@ void Dialog_FieldCalculation::on_button_test()
   }
 
   //We need the connection when we run the script, so that the script may use it.
-  std::shared_ptr<SharedConnection> sharedconnection = connect_to_server(this /* parent window */);
+  auto sharedconnection = connect_to_server(this /* parent window */);
 
   Glib::ustring error_message;
   const auto value = glom_evaluate_python_function_implementation(
@@ -144,9 +144,9 @@ void Dialog_FieldCalculation::on_button_test()
     UiUtils::show_ok_dialog( _("Calculation failed"), Glib::ustring::compose(_("The calculation failed with 
this error:\n%s"), error_message), *this, Gtk::MESSAGE_ERROR);
 
   //Show what fields would trigger the recalculation:
-  std::shared_ptr<Field> temp = std::make_shared<Field>();
+  auto temp = std::make_shared<Field>();
   temp->set_calculation(calculation);
-  std::shared_ptr<LayoutItem_Field> layoutitem_temp = std::make_shared<LayoutItem_Field>();
+  auto layoutitem_temp = std::make_shared<LayoutItem_Field>();
   layoutitem_temp->set_full_field_details(temp);
   const auto triggered_fields = get_calculation_fields(m_table_name, layoutitem_temp);
 
diff --git a/glom/mode_design/fields/dialog_fielddefinition.cc 
b/glom/mode_design/fields/dialog_fielddefinition.cc
index bc9d74f..37c4346 100644
--- a/glom/mode_design/fields/dialog_fielddefinition.cc
+++ b/glom/mode_design/fields/dialog_fielddefinition.cc
@@ -140,8 +140,8 @@ void Dialog_FieldDefinition::set_field(const std::shared_ptr<const Field>& field
 
   //We use a regular DataWidget for the default value, so we can reuse its functionality,
   //but it's not a real field - hence the special title.
-  std::shared_ptr<LayoutItem_Field> layout_item = std::make_shared<LayoutItem_Field>();
-  std::shared_ptr<Field> field_default_value = glom_sharedptr_clone(m_Field);
+  auto layout_item = std::make_shared<LayoutItem_Field>();
+  auto field_default_value = glom_sharedptr_clone(m_Field);
   field_default_value->set_name("glom_temp_default_value");
   field_default_value->set_title_original(_("Default Value"));
   layout_item->set_full_field_details(field_default_value);
@@ -213,9 +213,9 @@ void Dialog_FieldDefinition::set_field(const std::shared_ptr<const Field>& field
 
 std::shared_ptr<Field> Dialog_FieldDefinition::get_field() const
 {
-  std::shared_ptr<Field> field = glom_sharedptr_clone(m_Field); //Start with the old details, to preserve 
anything that is not in our UI.
+  auto field = glom_sharedptr_clone(m_Field); //Start with the old details, to preserve anything that is not 
in our UI.
   // const_cast is necessary and save here for the window (jhs)
-  std::shared_ptr<SharedConnection> sharedcnc = connect_to_server(const_cast<Dialog_FieldDefinition*>(this));
+  auto sharedcnc = connect_to_server(const_cast<Dialog_FieldDefinition*>(this));
   Glib::RefPtr<Gnome::Gda::Connection> cnc = sharedcnc->get_gda_connection();
 
   //Get the field info from the widgets:
@@ -339,7 +339,7 @@ void Dialog_FieldDefinition::on_combo_lookup_relationship_changed()
   m_pCombo_LookupField->remove_all();
 
   //Get the relationship name:
-  std::shared_ptr<const Relationship> relationship = 
m_pCombo_LookupRelationship->get_selected_relationship();
+  auto relationship = m_pCombo_LookupRelationship->get_selected_relationship();
   if(relationship)
   {
     //Get the relationship details:
diff --git a/glom/mode_design/layout/combobox_fields.cc b/glom/mode_design/layout/combobox_fields.cc
index ada2329..4040eb0 100644
--- a/glom/mode_design/layout/combobox_fields.cc
+++ b/glom/mode_design/layout/combobox_fields.cc
@@ -62,7 +62,7 @@ std::shared_ptr<Field> ComboBox_Fields::get_selected_field() const
 
 Glib::ustring ComboBox_Fields::get_selected_field_name() const
 {
-  std::shared_ptr<Field> field = get_selected_field();
+  auto field = get_selected_field();
   return glom_get_sharedptr_name(field);
 }
 
@@ -118,7 +118,7 @@ void ComboBox_Fields::set_fields(Document* document, const Glib::ustring parent_
     auto tree_iter = m_model->append();
     Gtk::TreeModel::Row row = *tree_iter;
 
-    std::shared_ptr<Field> rel = field;
+    auto rel = field;
     row[m_model_columns.m_field] = rel;
     row[m_model_columns.m_separator] = false;
   }
diff --git a/glom/mode_design/layout/dialog_choose_field.cc b/glom/mode_design/layout/dialog_choose_field.cc
index d278a91..ecbdd30 100644
--- a/glom/mode_design/layout/dialog_choose_field.cc
+++ b/glom/mode_design/layout/dialog_choose_field.cc
@@ -235,7 +235,7 @@ Dialog_ChooseField::type_list_field_items Dialog_ChooseField::get_fields_chosen(
   //Relationship:
   //Note that a null relationship means that the parent table was selected instead.
   std::shared_ptr<Relationship> related_relationship;
-  std::shared_ptr<Relationship> relationship = 
m_combo_relationship->get_selected_relationship(related_relationship);
+  auto relationship = m_combo_relationship->get_selected_relationship(related_relationship);
 
   for(const auto& path : refTreeSelection->get_selected_rows())
   {
@@ -246,7 +246,7 @@ Dialog_ChooseField::type_list_field_items Dialog_ChooseField::get_fields_chosen(
 
     // Setup a LayoutItem_Field for the Field, 
     // so is_same_field() can work:
-    std::shared_ptr<LayoutItem_Field> field = std::make_shared<LayoutItem_Field>();
+    auto field = std::make_shared<LayoutItem_Field>();
     field->set_relationship(relationship);
     field->set_related_relationship(related_relationship);
       
@@ -289,7 +289,7 @@ void Dialog_ChooseField::on_checkbutton_related_relationships_toggled()
 
   //Preserve the selection:
   std::shared_ptr<Relationship> related_relationship;
-  std::shared_ptr<Relationship> relationship = 
m_combo_relationship->get_selected_relationship(related_relationship);
+  auto relationship = m_combo_relationship->get_selected_relationship(related_relationship);
 
   //Refresh the list, hiding or showing the child relationships:
   m_combo_relationship->set_relationships(m_document, m_table_name, show_related_relationships);
@@ -299,7 +299,7 @@ void Dialog_ChooseField::on_checkbutton_related_relationships_toggled()
 
 void Dialog_ChooseField::on_combo_relationship_changed()
 {
-  std::shared_ptr<Relationship> relationship = m_combo_relationship->get_selected_relationship();
+  auto relationship = m_combo_relationship->get_selected_relationship();
 
   auto pDocument = m_document;
   if(pDocument)
diff --git a/glom/mode_design/layout/dialog_layout_calendar_related.cc 
b/glom/mode_design/layout/dialog_layout_calendar_related.cc
index f0173d4..5a54a5e 100644
--- a/glom/mode_design/layout/dialog_layout_calendar_related.cc
+++ b/glom/mode_design/layout/dialog_layout_calendar_related.cc
@@ -163,7 +163,7 @@ void Dialog_Layout_Calendar_Related::update_ui(bool including_relationship_list)
     }
 
     //Set the table name and title:
-    //std::shared_ptr<LayoutItem_CalendarPortal> portal_temp = m_portal;
+    //auto portal_temp = m_portal;
     m_combo_relationship->set_selected_relationship(m_portal->get_relationship(), 
m_portal->get_related_relationship());
 
     Document::type_list_layout_groups mapGroups;
@@ -180,12 +180,12 @@ void Dialog_Layout_Calendar_Related::update_ui(bool including_relationship_list)
 
     for(const auto& group : mapGroups)
     {
-      std::shared_ptr<const LayoutGroup> portal = std::dynamic_pointer_cast<const 
LayoutItem_CalendarPortal>(group);
+      auto portal = std::dynamic_pointer_cast<const LayoutItem_CalendarPortal>(group);
       if(portal)
       {
         for(const auto& item : group->m_list_items)
         {
-          std::shared_ptr<const LayoutGroup> groupInner = std::dynamic_pointer_cast<const LayoutGroup>(item);
+          auto groupInner = std::dynamic_pointer_cast<const LayoutGroup>(item);
 
           if(groupInner)
             add_group(Gtk::TreeModel::iterator() /* null == top-level */, groupInner);
@@ -209,7 +209,7 @@ void Dialog_Layout_Calendar_Related::update_ui(bool including_relationship_list)
   bool navigation_is_automatic = false;
   if(m_portal->get_navigation_type() == LayoutItem_Portal::navigation_type::SPECIFIC)
   {
-    std::shared_ptr<UsesRelationship> navrel = m_portal->get_navigation_relationship_specific();
+    auto navrel = m_portal->get_navigation_relationship_specific();
     //std::cout << "debug navrel=" << navrel->get_relationship()->get_name() << std::endl;
     m_combo_navigation_specify->set_selected_relationship(navrel->get_relationship(), 
navrel->get_related_relationship());
   }
@@ -244,7 +244,7 @@ void Dialog_Layout_Calendar_Related::update_ui(bool including_relationship_list)
 
   m_label_navigation_automatic->set_text(automatic_navigation_description);
 
-  std::shared_ptr<Field> debugfield = m_portal->get_date_field();
+  auto debugfield = m_portal->get_date_field();
   if(!debugfield)
     std::cout << "debug: " << G_STRFUNC << ": date field is NULL" << std::endl;
   else
@@ -289,7 +289,7 @@ void Dialog_Layout_Calendar_Related::save_to_document()
       std::shared_ptr<Relationship> rel, rel_related;
       rel = m_combo_navigation_specify->get_selected_relationship(rel_related);
 
-      std::shared_ptr<UsesRelationship> uses_rel = std::make_shared<UsesRelationship>();
+      auto uses_rel = std::make_shared<UsesRelationship>();
       uses_rel->set_relationship(rel);
       uses_rel->set_related_relationship(rel_related);
 
@@ -306,7 +306,7 @@ void Dialog_Layout_Calendar_Related::save_to_document()
 
     m_portal->set_date_field( m_combobox_date_field->get_selected_field() );
 
-    std::shared_ptr<Field> debugfield = m_portal->get_date_field();
+    auto debugfield = m_portal->get_date_field();
     if(!debugfield)
       std::cout << "debug: " << G_STRFUNC << ": date field is NULL" << std::endl;
     else
@@ -325,7 +325,7 @@ void Dialog_Layout_Calendar_Related::on_combo_relationship_changed()
     return;
 
   std::shared_ptr<Relationship> relationship_related;
-  std::shared_ptr<Relationship> relationship = 
m_combo_relationship->get_selected_relationship(relationship_related);
+  auto relationship = m_combo_relationship->get_selected_relationship(relationship_related);
   if(relationship)
   {
     //Clear the list of fields if the relationship has changed, because the fields could not possible be 
correct for the new table:
@@ -405,10 +405,10 @@ void Dialog_Layout_Calendar_Related::on_button_edit()
     {
       Gtk::TreeModel::Row row = *iter;
       std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
-      std::shared_ptr<LayoutItem_Field> field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+      auto field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
 
       //Get the chosen field:
-      std::shared_ptr<LayoutItem_Field> field_chosen = offer_field_list_select_one_field(field, 
m_portal->get_table_used(m_table_name), this);
+      auto field_chosen = offer_field_list_select_one_field(field, m_portal->get_table_used(m_table_name), 
this);
       if(field_chosen)
       {
         //Set the field details in the layout treeview:
diff --git a/glom/mode_design/layout/dialog_layout_details.cc 
b/glom/mode_design/layout/dialog_layout_details.cc
index 390739a..e1a3694 100644
--- a/glom/mode_design/layout/dialog_layout_details.cc
+++ b/glom/mode_design/layout/dialog_layout_details.cc
@@ -207,7 +207,7 @@ Dialog_Layout_Details::Dialog_Layout_Details(BaseObjectType* cobject, const Glib
 
 void Dialog_Layout_Details::fill_group(const Gtk::TreeModel::iterator& iter, std::shared_ptr<LayoutGroup>& 
group)
 {
-  std::shared_ptr<LayoutItem_Portal> portal = std::dynamic_pointer_cast<LayoutItem_Portal>(group);
+  auto portal = std::dynamic_pointer_cast<LayoutItem_Portal>(group);
   if(portal)
     return; //This method is not for portals.
 
@@ -215,11 +215,11 @@ void Dialog_Layout_Details::fill_group(const Gtk::TreeModel::iterator& iter, std
   {
     Gtk::TreeModel::Row row = *iter;
     std::shared_ptr<LayoutItem> layout_item_top = row[m_model_items->m_columns.m_col_layout_item];
-    std::shared_ptr<LayoutGroup> group_row = std::dynamic_pointer_cast<LayoutGroup>(layout_item_top);
+    auto group_row = std::dynamic_pointer_cast<LayoutGroup>(layout_item_top);
     if(!group_row)
       return;
 
-    std::shared_ptr<LayoutItem_Portal> portal_row = std::dynamic_pointer_cast<LayoutItem_Portal>(group_row);
+    auto portal_row = std::dynamic_pointer_cast<LayoutItem_Portal>(group_row);
     if(portal_row) //This is only for groups.
       return;
 
@@ -231,7 +231,7 @@ void Dialog_Layout_Details::fill_group(const Gtk::TreeModel::iterator& iter, std
     {
       std::shared_ptr<LayoutItem> layout_item = rowChild[m_model_items->m_columns.m_col_layout_item];
 
-      std::shared_ptr<LayoutItem_Portal> layout_portal = 
std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
+      auto layout_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
       if(layout_portal)
       {
         //std::cout << "debug: " << G_STRFUNC << ": adding portal." << std::endl;
@@ -240,11 +240,11 @@ void Dialog_Layout_Details::fill_group(const Gtk::TreeModel::iterator& iter, std
       else
       {
         //std::cout << "debug: " << G_STRFUNC << ": adding group." << std::endl;
-        std::shared_ptr<LayoutGroup> layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
+        auto layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
         if(layout_group && !layout_portal)
         {
           //Recurse:
-          std::shared_ptr<LayoutGroup> group_child = glom_sharedptr_clone(layout_group);
+          auto group_child = glom_sharedptr_clone(layout_group);
           fill_group(rowChild, group_child);
           group->add_item(group_child);
         }
@@ -253,7 +253,7 @@ void Dialog_Layout_Details::fill_group(const Gtk::TreeModel::iterator& iter, std
           //std::cout << "debug: " << G_STRFUNC << ": adding item." << std::endl;
 
           //Add field or button:
-          std::shared_ptr<LayoutItem> item = glom_sharedptr_clone(layout_item);
+          auto item = glom_sharedptr_clone(layout_item);
           group->add_item(item);
         }
       }
@@ -267,7 +267,7 @@ void Dialog_Layout_Details::add_group(const Gtk::TreeModel::iterator& parent, co
   if(!group)
    return;
 
-  std::shared_ptr<const LayoutItem_Portal> parent_portal = std::dynamic_pointer_cast<const 
LayoutItem_Portal>(group);
+  auto parent_portal = std::dynamic_pointer_cast<const LayoutItem_Portal>(group);
   if(parent_portal)
     return; //This method is not for portals.
 
@@ -286,7 +286,7 @@ void Dialog_Layout_Details::add_group(const Gtk::TreeModel::iterator& parent, co
   {
     Gtk::TreeModel::Row rowGroup = *iterNewGroup;
 
-    std::shared_ptr<LayoutGroup> group_inserted = glom_sharedptr_clone(group);
+    auto group_inserted = glom_sharedptr_clone(group);
     group_inserted->remove_all_items();
     rowGroup[m_model_items->m_columns.m_col_layout_item] = group_inserted;
 
@@ -294,7 +294,7 @@ void Dialog_Layout_Details::add_group(const Gtk::TreeModel::iterator& parent, co
     LayoutGroup::type_list_const_items items = group->get_items();
     for(const auto& item : items)
     {
-      std::shared_ptr<const LayoutItem_Portal> portal = std::dynamic_pointer_cast<const 
LayoutItem_Portal>(item);
+      auto portal = std::dynamic_pointer_cast<const LayoutItem_Portal>(item);
       if(portal) //If it is a portal
       {
         //Handle this differently to regular groups, so we do not also add its children:
@@ -304,7 +304,7 @@ void Dialog_Layout_Details::add_group(const Gtk::TreeModel::iterator& parent, co
       }
       else
       {
-        std::shared_ptr<const LayoutGroup> child_group = std::dynamic_pointer_cast<const LayoutGroup>(item);
+        auto child_group = std::dynamic_pointer_cast<const LayoutGroup>(item);
         if(child_group) //If it is a group:
           add_group(iterNewGroup, child_group); //recursive
         else
@@ -341,7 +341,7 @@ void Dialog_Layout_Details::init(const Glib::ustring& layout_name, const Glib::u
 
     if(list_groups.empty())
     {
-      std::shared_ptr<LayoutGroup> group = std::make_shared<LayoutGroup>();
+      auto group = std::make_shared<LayoutGroup>();
       group->set_name("main");
       group->set_columns_count(1);
 
@@ -355,7 +355,7 @@ void Dialog_Layout_Details::init(const Glib::ustring& layout_name, const Glib::u
 
     for(const auto& group : list_groups)
     {
-      std::shared_ptr<const LayoutGroup> portal = std::dynamic_pointer_cast<const LayoutItem_Portal>(group);
+      auto portal = std::dynamic_pointer_cast<const LayoutItem_Portal>(group);
       if(group && !portal)
         add_group(Gtk::TreeModel::iterator() /* null == top-level */, group);
     }
@@ -421,7 +421,7 @@ void Dialog_Layout_Details::enable_buttons()
 
       //Only some items have formatting:
       std::shared_ptr<LayoutItem> layout_item = (*iter)[m_model_items->m_columns.m_col_layout_item];
-      std::shared_ptr<LayoutItem_WithFormatting> layoutitem_withformatting = 
std::dynamic_pointer_cast<LayoutItem_WithFormatting>(layout_item);
+      auto layoutitem_withformatting = std::dynamic_pointer_cast<LayoutItem_WithFormatting>(layout_item);
       const bool is_field = (bool)layoutitem_withformatting;
       m_button_formatting->set_sensitive(is_field);
     }
@@ -578,7 +578,7 @@ std::shared_ptr<Relationship> Dialog_Layout_Details::offer_relationship_list()
 
 std::shared_ptr<Relationship> Dialog_Layout_Details::offer_relationship_list(const std::shared_ptr<const 
Relationship>& item)
 {
-  std::shared_ptr<Relationship> result = glom_sharedptr_clone(item);
+  auto result = glom_sharedptr_clone(item);
 
   Dialog_ChooseRelationship* dialog = nullptr;
   Utils::get_glade_widget_derived_with_warning(dialog);
@@ -621,8 +621,8 @@ Gtk::TreeModel::iterator Dialog_Layout_Details::append_appropriate_row()
       Gtk::TreeModel::Row row = *iter_first;
 
       std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
-      std::shared_ptr<LayoutGroup> layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
-      std::shared_ptr<LayoutItem_Portal> layout_portal = 
std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
+      auto layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
+      auto layout_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
 
       if(layout_group && !layout_portal)
         result = m_model_items->append(iter_first->children());
@@ -646,7 +646,7 @@ void Dialog_Layout_Details::on_button_add_button()
     Gtk::TreeModel::Row row = *iter;
 
     //Add a new button:
-    std::shared_ptr<LayoutItem_Button> button = std::make_shared<LayoutItem_Button>();
+    auto button = std::make_shared<LayoutItem_Button>();
     button->set_title_original(_("New Button")); //Give the button a default title, so it is big enough, and 
so people see that they should change it.
     row[m_model_items->m_columns.m_col_layout_item] = button;
 
@@ -671,7 +671,7 @@ void Dialog_Layout_Details::on_button_add_text()
     Gtk::TreeModel::Row row = *iter;
 
     //Add a new button:
-    std::shared_ptr<LayoutItem_Text> textobject = std::make_shared<LayoutItem_Text>();
+    auto textobject = std::make_shared<LayoutItem_Text>();
     textobject->set_title_original(_("Text Title")); //Give the button a default title, so it is big enough, 
and so people see that they should change it.
     row[m_model_items->m_columns.m_col_layout_item] = textobject;
 
@@ -696,7 +696,7 @@ void Dialog_Layout_Details::on_button_add_image()
     Gtk::TreeModel::Row row = *iter;
 
     //Add a new button:
-    std::shared_ptr<LayoutItem_Image> imageobject = std::make_shared<LayoutItem_Image>();
+    auto imageobject = std::make_shared<LayoutItem_Image>();
     imageobject->set_title_original(_("Image Title")); //Give the item a default title, so it is big enough, 
and so people see that they should change it.
     row[m_model_items->m_columns.m_col_layout_item] = imageobject;
 
@@ -720,7 +720,7 @@ void Dialog_Layout_Details::on_button_add_notebook()
   {
     Gtk::TreeModel::Row row = *iter;
 
-    std::shared_ptr<LayoutItem_Notebook> notebook = std::make_shared<LayoutItem_Notebook>();
+    auto notebook = std::make_shared<LayoutItem_Notebook>();
     notebook->set_name(_("notebook"));
     row[m_model_items->m_columns.m_col_layout_item] = notebook;
 
@@ -740,7 +740,7 @@ void Dialog_Layout_Details::on_button_add_notebook()
 void Dialog_Layout_Details::on_button_add_related()
 {
   /* We don't need to ask this because the portal layout dialog can now handle an empty portal:
-  std::shared_ptr<Relationship> relationship = offer_relationship_list();
+  auto relationship = offer_relationship_list();
   if(relationship)
   {
   */
@@ -749,7 +749,7 @@ void Dialog_Layout_Details::on_button_add_related()
     {
       Gtk::TreeModel::Row row = *iter;
 
-      std::shared_ptr<LayoutItem_Portal> portal = std::make_shared<LayoutItem_Portal>();
+      auto portal = std::make_shared<LayoutItem_Portal>();
       //portal->set_relationship(relationship);
       row[m_model_items->m_columns.m_col_layout_item] = portal;
 
@@ -772,7 +772,7 @@ void Dialog_Layout_Details::on_button_add_related()
 void Dialog_Layout_Details::on_button_add_related_calendar()
 {
   /* We don't need to ask this because the portal layout dialog can now handle an empty portal:
-  std::shared_ptr<Relationship> relationship = offer_relationship_list();
+  auto relationship = offer_relationship_list();
   if(relationship)
   {
   */
@@ -781,7 +781,7 @@ void Dialog_Layout_Details::on_button_add_related_calendar()
     {
       Gtk::TreeModel::Row row = *iter;
 
-      std::shared_ptr<LayoutItem_Portal> portal = std::make_shared<LayoutItem_CalendarPortal>();
+      auto portal = std::make_shared<LayoutItem_CalendarPortal>();
       //portal->set_relationship(relationship);
       row[m_model_items->m_columns.m_col_layout_item] = portal;
 
@@ -814,8 +814,8 @@ Gtk::TreeModel::iterator Dialog_Layout_Details::get_selected_group_parent() cons
       Gtk::TreeModel::Row row = *iter;
 
       std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
-      std::shared_ptr<LayoutGroup> layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
-      std::shared_ptr<LayoutItem_Portal> layout_portal = 
std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
+      auto layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
+      auto layout_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
 
       if(layout_group && !layout_portal)
       {
@@ -851,7 +851,7 @@ void Dialog_Layout_Details::on_button_add_group()
   if(iterNewGroup)
   {
     Gtk::TreeModel::Row row = *iterNewGroup;
-    std::shared_ptr<LayoutGroup> layout_item = std::make_shared<LayoutGroup>();
+    auto layout_item = std::make_shared<LayoutGroup>();
     layout_item->set_name(_("group"));
     row[m_model_items->m_columns.m_col_layout_item] = layout_item;
 
@@ -882,11 +882,11 @@ void Dialog_Layout_Details::on_button_formatting()
       Gtk::TreeModel::Row row = *iter;
 
       std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
-      std::shared_ptr<LayoutItem_Field> field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+      auto field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
       if(field)
       {
         //Handle field formatting, which includes more than the generic formatting stuff:
-        std::shared_ptr<LayoutItem_Field> chosenitem = offer_field_formatting(field, get_fields_table(), 
this, m_editable_layout);
+        auto chosenitem = offer_field_formatting(field, get_fields_table(), this, m_editable_layout);
         if(chosenitem)
         {
           *field = *chosenitem; //TODO_Performance.
@@ -897,7 +897,7 @@ void Dialog_Layout_Details::on_button_formatting()
       else
       {
         //Handle any other items that can have formatting:
-        std::shared_ptr<LayoutItem_WithFormatting> withformatting = 
std::dynamic_pointer_cast<LayoutItem_WithFormatting>(layout_item);
+        auto withformatting = std::dynamic_pointer_cast<LayoutItem_WithFormatting>(layout_item);
         if(withformatting)
         {
           const auto changed = offer_non_field_item_formatting(withformatting, this);
@@ -925,10 +925,10 @@ void Dialog_Layout_Details::on_button_edit()
 
       std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
 
-      std::shared_ptr<LayoutItem_Portal> layout_portal = 
std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
+      auto layout_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
       if(layout_portal)
       {
-        std::shared_ptr<Relationship> relationship = 
offer_relationship_list(layout_portal->get_relationship());
+        auto relationship = offer_relationship_list(layout_portal->get_relationship());
         if(relationship)
         {
           layout_portal->set_relationship(relationship);
@@ -941,14 +941,14 @@ void Dialog_Layout_Details::on_button_edit()
       }
       else
       {
-        std::shared_ptr<LayoutItem_Notebook> layout_notebook = 
std::dynamic_pointer_cast<LayoutItem_Notebook>(layout_item);
+        auto layout_notebook = std::dynamic_pointer_cast<LayoutItem_Notebook>(layout_item);
         if(layout_notebook)
         {
           Frame_Glom::show_ok_dialog(_("Notebook Tabs"), _("Add child groups to the notebook to add tabs."), 
*this);
         }
         else
         {
-          std::shared_ptr<LayoutGroup> layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
+          auto layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
           if(layout_group)
           {
             Gtk::TreeModel::Path path = m_model_items->get_path(iter);
@@ -956,10 +956,10 @@ void Dialog_Layout_Details::on_button_edit()
           }
           else
           {
-            std::shared_ptr<LayoutItem_Field> layout_item_field = 
std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+            auto layout_item_field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
             if(layout_item_field)
             {
-              std::shared_ptr<LayoutItem_Field> chosenitem = 
offer_field_list_select_one_field(layout_item_field, m_table_name, this);
+              auto chosenitem = offer_field_list_select_one_field(layout_item_field, m_table_name, this);
               if(chosenitem)
               {
                 *layout_item_field = *chosenitem;
@@ -969,10 +969,10 @@ void Dialog_Layout_Details::on_button_edit()
             }
             else
             {
-              std::shared_ptr<LayoutItem_Button> layout_item_button = 
std::dynamic_pointer_cast<LayoutItem_Button>(layout_item);
+              auto layout_item_button = std::dynamic_pointer_cast<LayoutItem_Button>(layout_item);
               if(layout_item_button)
               {
-                std::shared_ptr<LayoutItem_Button> chosen = offer_button_script_edit(layout_item_button);
+                auto chosen = offer_button_script_edit(layout_item_button);
                 if(chosen)
                 {
                   *layout_item_button = *chosen;
@@ -983,10 +983,10 @@ void Dialog_Layout_Details::on_button_edit()
               }
               else
               {
-                std::shared_ptr<LayoutItem_Text> layout_item_text = 
std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
+                auto layout_item_text = std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
                 if(layout_item_text)
                 {
-                  std::shared_ptr<LayoutItem_Text> chosen = offer_textobject(layout_item_text);
+                  auto chosen = offer_textobject(layout_item_text);
                   if(chosen)
                   {
                     *layout_item_text = *chosen;
@@ -997,10 +997,10 @@ void Dialog_Layout_Details::on_button_edit()
                 }
                 else
                 {
-                  std::shared_ptr<LayoutItem_Image> layout_item_image = 
std::dynamic_pointer_cast<LayoutItem_Image>(layout_item);
+                  auto layout_item_image = std::dynamic_pointer_cast<LayoutItem_Image>(layout_item);
                   if(layout_item_image)
                   {
-                    std::shared_ptr<LayoutItem_Image> chosen = offer_imageobject(layout_item_image);
+                    auto chosen = offer_imageobject(layout_item_image);
                     if(chosen)
                     {
                       *layout_item_image = *chosen;
@@ -1049,11 +1049,11 @@ void Dialog_Layout_Details::save_to_document()
     for(const auto& row : m_model_items->children())
     {
       std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
-      std::shared_ptr<LayoutGroup> layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
-      std::shared_ptr<LayoutItem_Portal> layout_portal = 
std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
+      auto layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
+      auto layout_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
       if(layout_group && !layout_portal) //There may be top-level groups, but no top-level fields, because 
the fields must be in a group (so that they are in columns)
       {
-        std::shared_ptr<LayoutGroup> group = std::make_shared<LayoutGroup>();
+        auto group = std::make_shared<LayoutGroup>();
         fill_group(row, group);
 
         list_groups.push_back(group);
@@ -1092,10 +1092,10 @@ void Dialog_Layout_Details::on_cell_data_name(Gtk::CellRenderer* renderer, const
 
       bool is_group = false;
 
-      std::shared_ptr<LayoutItem_Portal> layout_portal = 
std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
+      auto layout_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
       if(layout_portal)
       {
-        std::shared_ptr<LayoutItem_CalendarPortal> layout_calendar = 
std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(layout_portal);
+        auto layout_calendar = std::dynamic_pointer_cast<LayoutItem_CalendarPortal>(layout_portal);
         if(layout_calendar)
           markup = Glib::ustring::compose(_("Related Calendar: %1"), layout_portal->get_relationship_name());
         else
@@ -1103,7 +1103,7 @@ void Dialog_Layout_Details::on_cell_data_name(Gtk::CellRenderer* renderer, const
       }
       else
       {
-        std::shared_ptr<LayoutGroup> layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
+        auto layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
         if(layout_group)
         {
           is_group = true;
@@ -1113,7 +1113,7 @@ void Dialog_Layout_Details::on_cell_data_name(Gtk::CellRenderer* renderer, const
         }
         else
         {
-          std::shared_ptr<LayoutItem_Field> layout_item_field = 
std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+          auto layout_item_field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
           if(layout_item_field)
           {
             markup = Glib::ustring::compose(_("Field: %1"), layout_item_field->get_layout_display_name());
@@ -1124,21 +1124,21 @@ void Dialog_Layout_Details::on_cell_data_name(Gtk::CellRenderer* renderer, const
           }
           else
           {
-            std::shared_ptr<LayoutItem_Button> layout_item_button = 
std::dynamic_pointer_cast<LayoutItem_Button>(layout_item);
+            auto layout_item_button = std::dynamic_pointer_cast<LayoutItem_Button>(layout_item);
             if(layout_item_button)
             {
               markup = _("Button"); //Buttons don't have names - just titles. TODO: Would they be useful?
             }
             else
             {
-              std::shared_ptr<LayoutItem_Text> layout_item_text = 
std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
+              auto layout_item_text = std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
               if(layout_item_text)
               {
                 markup = _("Text"); //Text objects don't have names - just titles. TODO: Would they be 
useful?
               }
               else
               {
-                std::shared_ptr<LayoutItem_Image> layout_item_image = 
std::dynamic_pointer_cast<LayoutItem_Image>(layout_item);
+                auto layout_item_image = std::dynamic_pointer_cast<LayoutItem_Image>(layout_item);
                 if(layout_item_image)
                 {
                   markup = _("Image"); //Image objects don't have names - just titles. TODO: Would they be 
useful?
@@ -1173,7 +1173,7 @@ void Dialog_Layout_Details::on_cell_data_title(Gtk::CellRenderer* renderer, cons
     {
       Gtk::TreeModel::Row row = *iter;
       std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
-      std::shared_ptr<LayoutItem_Notebook> layout_notebook = 
std::dynamic_pointer_cast<LayoutItem_Notebook>(layout_item);
+      auto layout_notebook = std::dynamic_pointer_cast<LayoutItem_Notebook>(layout_item);
       if(layout_notebook)
         renderer_text->property_text() = _("(Notebook)");
       else if(layout_item)
@@ -1181,10 +1181,10 @@ void Dialog_Layout_Details::on_cell_data_title(Gtk::CellRenderer* renderer, cons
       else
         renderer_text->property_text() = Glib::ustring();
 
-      std::shared_ptr<LayoutGroup> layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
-      std::shared_ptr<LayoutItem_Portal> layout_portal = 
std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
-      std::shared_ptr<LayoutItem_Button> layout_button = 
std::dynamic_pointer_cast<LayoutItem_Button>(layout_item);
-      std::shared_ptr<LayoutItem_Text> layout_text = std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
+      auto layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
+      auto layout_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
+      auto layout_button = std::dynamic_pointer_cast<LayoutItem_Button>(layout_item);
+      auto layout_text = std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
       const bool editable = (layout_group && !layout_portal) || layout_button || layout_text; //Only groups, 
buttons, and text objects have titles that can be edited.
       renderer_text->property_editable() = editable;
     }
@@ -1205,9 +1205,9 @@ void Dialog_Layout_Details::on_cell_data_column_width(Gtk::CellRenderer* rendere
       guint column_width = 0;
       if(layout_item)
       {
-        std::shared_ptr<LayoutItem_Button> layout_button = 
std::dynamic_pointer_cast<LayoutItem_Button>(layout_item);
-        std::shared_ptr<LayoutItem_Text> layout_text = 
std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
-        std::shared_ptr<LayoutItem_Field> layout_field = 
std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+        auto layout_button = std::dynamic_pointer_cast<LayoutItem_Button>(layout_item);
+        auto layout_text = std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
+        auto layout_field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
         const bool editable = (layout_field || layout_button || layout_text); //Only these have column 
widths that can be edited.
         renderer_text->property_editable() = editable;
 
@@ -1234,8 +1234,8 @@ void Dialog_Layout_Details::on_cell_data_group_columns(Gtk::CellRenderer* render
       Gtk::TreeModel::Row row = *iter;
       std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
 
-      std::shared_ptr<LayoutGroup> layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
-      std::shared_ptr<LayoutItem_Portal> layout_portal = 
std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
+      auto layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
+      auto layout_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
 
       const bool is_group = layout_group && !layout_portal; //Only groups have column_counts.
 
@@ -1343,8 +1343,8 @@ void Dialog_Layout_Details::on_treeview_cell_edited_group_columns(const Glib::us
   {
     Gtk::TreeModel::Row row = *iter;
     std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
-    std::shared_ptr<LayoutGroup> layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
-    std::shared_ptr<LayoutItem_Portal> layout_portal = 
std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
+    auto layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
+    auto layout_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
     if(layout_group && !layout_portal)
     {
       //std::istringstream astream(new_text); //Put it in a stream.
diff --git a/glom/mode_design/layout/dialog_layout_export.cc b/glom/mode_design/layout/dialog_layout_export.cc
index 720c833..0592dbf 100644
--- a/glom/mode_design/layout/dialog_layout_export.cc
+++ b/glom/mode_design/layout/dialog_layout_export.cc
@@ -143,7 +143,7 @@ void Dialog_Layout_Export::set_layout_groups(Document::type_list_layout_groups&
       //Add the group's fields:
       for(const auto& base_item : group->get_items())
       {
-        std::shared_ptr<const LayoutItem_Field> item = std::dynamic_pointer_cast<const 
LayoutItem_Field>(base_item); 
+        auto item = std::dynamic_pointer_cast<const LayoutItem_Field>(base_item); 
         if(item)
         {
           auto iterTree = m_model_fields->append();
@@ -222,7 +222,7 @@ void Dialog_Layout_Export::get_layout_groups(Document::type_list_layout_groups&
   Document::type_list_layout_groups groups;
 
   //Add the fields to the one group:
-  std::shared_ptr<LayoutGroup> others = std::make_shared<LayoutGroup>();
+  auto others = std::make_shared<LayoutGroup>();
   others->set_name("main");
 
   guint field_sequence = 1; //0 means no sequence
@@ -330,7 +330,7 @@ void Dialog_Layout_Export::on_button_edit_field()
       std::shared_ptr<LayoutItem_Field> field = row[m_ColumnsFields.m_col_layout_item];
 
       //Get the chosen field:
-      std::shared_ptr<LayoutItem_Field> field_chosen = offer_field_list_select_one_field(field, 
m_table_name, this);
+      auto field_chosen = offer_field_list_select_one_field(field, m_table_name, this);
       if(field_chosen)
       {
         //Set the field details in the layout treeview:
diff --git a/glom/mode_design/layout/dialog_layout_list_related.cc 
b/glom/mode_design/layout/dialog_layout_list_related.cc
index a2e24dd..eafd173 100644
--- a/glom/mode_design/layout/dialog_layout_list_related.cc
+++ b/glom/mode_design/layout/dialog_layout_list_related.cc
@@ -219,7 +219,7 @@ void Dialog_Layout_List_Related::update_ui(bool including_relationship_list)
     }
 
     //Set the table name and title:
-    //std::shared_ptr<LayoutItem_Portal> portal_temp = m_portal;
+    //auto portal_temp = m_portal;
     Document::type_list_layout_groups mapGroups;
     if(m_portal)
     {
@@ -236,12 +236,12 @@ void Dialog_Layout_List_Related::update_ui(bool including_relationship_list)
 
     for(const auto& group : mapGroups)
     {
-      std::shared_ptr<const LayoutGroup> portal = std::dynamic_pointer_cast<const LayoutItem_Portal>(group);
+      auto portal = std::dynamic_pointer_cast<const LayoutItem_Portal>(group);
       if(portal)
       {
         for(const auto& item : group->m_list_items)
         {
-          std::shared_ptr<const LayoutGroup> groupInner = std::dynamic_pointer_cast<const LayoutGroup>(item);
+          auto groupInner = std::dynamic_pointer_cast<const LayoutGroup>(item);
 
           if(groupInner)
             add_group(Gtk::TreeModel::iterator() /* null == top-level */, groupInner);
@@ -264,7 +264,7 @@ void Dialog_Layout_List_Related::update_ui(bool including_relationship_list)
 
   if(m_portal->get_navigation_type() == LayoutItem_Portal::navigation_type::SPECIFIC)
   {
-    std::shared_ptr<UsesRelationship> navrel = m_portal->get_navigation_relationship_specific();
+    auto navrel = m_portal->get_navigation_relationship_specific();
     //std::cout << "debug navrel=" << navrel->get_relationship()->get_name() << std::endl;
     m_combo_navigation_specify->set_selected_relationship(navrel->get_relationship(), 
navrel->get_related_relationship());
   }
@@ -292,7 +292,7 @@ void Dialog_Layout_List_Related::update_ui(bool including_relationship_list)
   }
 
   //Describe the automatic navigation:
-  std::shared_ptr<const UsesRelationship> relationship_navigation_automatic = 
+  auto relationship_navigation_automatic = 
     m_portal->get_portal_navigation_relationship_automatic(document);
   Glib::ustring automatic_navigation_description = 
     m_portal->get_relationship_name_used(); //TODO: Use get_relationship_display_name() instead?
@@ -345,7 +345,7 @@ void Dialog_Layout_List_Related::save_to_document()
       std::shared_ptr<Relationship> rel, rel_related;
       rel = m_combo_navigation_specify->get_selected_relationship(rel_related);
 
-      std::shared_ptr<UsesRelationship> uses_rel = std::make_shared<UsesRelationship>();
+      auto uses_rel = std::make_shared<UsesRelationship>();
       uses_rel->set_relationship(rel);
       uses_rel->set_related_relationship(rel_related);
 
@@ -368,7 +368,7 @@ void Dialog_Layout_List_Related::save_to_document()
 
     if(m_radio_navigation_none->get_active())
     {
-      std::shared_ptr<UsesRelationship> uses_rel = std::make_shared<UsesRelationship>();
+      auto uses_rel = std::make_shared<UsesRelationship>();
       uses_rel->set_related_relationship(std::shared_ptr<Relationship>());
       m_portal->set_navigation_type(LayoutItem_Portal::navigation_type::NONE);
     }
@@ -400,14 +400,14 @@ void Dialog_Layout_List_Related::on_combo_relationship_changed()
     return;
 
   std::shared_ptr<Relationship> relationship_related;
-  std::shared_ptr<Relationship> relationship = 
m_combo_relationship->get_selected_relationship(relationship_related);
+  auto relationship = m_combo_relationship->get_selected_relationship(relationship_related);
   if(!relationship)
     return;
 
   //Check that the relationship is appropriate for use in a related records portal.
   //The relationship's to field may not be a unique field, because that would
   //prevent the portal from having multiple records.
-  std::shared_ptr<Field> to_key_field =
+  auto to_key_field =
     DbUtils::get_fields_for_table_one_field(get_document(), 
       relationship->get_to_table(), relationship->get_to_field());
   bool relationship_invalid = false;
@@ -527,10 +527,10 @@ void Dialog_Layout_List_Related::on_button_edit()
     {
       Gtk::TreeModel::Row row = *iter;
       std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
-      std::shared_ptr<LayoutItem_Field> field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+      auto field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
 
       //Get the chosen field:
-      std::shared_ptr<LayoutItem_Field> field_chosen = offer_field_list_select_one_field(field, 
m_portal->get_table_used(m_table_name), this);
+      auto field_chosen = offer_field_list_select_one_field(field, m_portal->get_table_used(m_table_name), 
this);
       if(field_chosen)
       {
         //Set the field details in the layout treeview:
diff --git a/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc 
b/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
index 441b8f5..e01e1dd 100644
--- a/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/box_formatting.cc
@@ -391,11 +391,11 @@ bool Box_Formatting::get_formatting(Formatting& format) const
       m_checkbutton_choices_restricted->get_active(),
       m_checkbutton_choices_restricted_as_radio_buttons->get_active());
 
-    const std::shared_ptr<const Relationship> choices_relationship = 
m_combo_choices_relationship->get_selected_relationship();
-    std::shared_ptr<LayoutItem_Field> layout_choice_first = std::make_shared<LayoutItem_Field>();
+    const auto choices_relationship = m_combo_choices_relationship->get_selected_relationship();
+    auto layout_choice_first = std::make_shared<LayoutItem_Field>();
     layout_choice_first->set_name(m_combo_choices_field->get_selected_field_name());
 
-    std::shared_ptr<LayoutGroup> layout_choice_extra = std::make_shared<LayoutGroup>();
+    auto layout_choice_extra = std::make_shared<LayoutGroup>();
     layout_choice_extra->m_list_items = m_dialog_choices_extra_fields->get_fields();
 
     const auto sort_fields = m_dialog_choices_sortby->get_fields();
@@ -420,7 +420,7 @@ bool Box_Formatting::get_formatting(Formatting& format) const
 
           if(success)
           {
-            std::shared_ptr<ChoiceValue> choicevalue = std::make_shared<ChoiceValue>();
+            auto choicevalue = std::make_shared<ChoiceValue>();
             choicevalue->set_value(value);
             list_choice_values.push_back(choicevalue);
           }
@@ -439,7 +439,7 @@ bool Box_Formatting::get_formatting(Formatting& format) const
 
 void Box_Formatting::on_combo_choices_relationship_changed()
 {
-  std::shared_ptr<Relationship> relationship = m_combo_choices_relationship->get_selected_relationship();
+  auto relationship = m_combo_choices_relationship->get_selected_relationship();
 
   auto pDocument = get_document();
   if(pDocument)
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc 
b/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc
index d105969..1ebb75f 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_buttonscript.cc
@@ -86,7 +86,7 @@ void Dialog_ButtonScript::set_script(const std::shared_ptr<const LayoutItem_Butt
 
 std::shared_ptr<LayoutItem_Button> Dialog_ButtonScript::get_script() const
 {
-  std::shared_ptr<LayoutItem_Button> result = glom_sharedptr_clone(m_script); //Start with the old details, 
to preserve anything that is not in our UI.
+  auto result = glom_sharedptr_clone(m_script); //Start with the old details, to preserve anything that is 
not in our UI.
 
   get_script(result);
 
@@ -118,7 +118,7 @@ void Dialog_ButtonScript::on_button_test_script()
   }
 
   //We need the connection when we run the script, so that the script may use it.
-  std::shared_ptr<SharedConnection> sharedconnection = ConnectionPool::get_and_connect();
+  auto sharedconnection = ConnectionPool::get_and_connect();
 
   Glib::ustring error_message;
   PythonUICallbacks callbacks;
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.cc 
b/glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.cc
index dbce887..02adcc8 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_field_layout.cc
@@ -79,7 +79,7 @@ void Dialog_FieldLayout::set_field(const std::shared_ptr<const LayoutItem_Field>
   m_checkbutton_editable->set_active( field->get_editable() );
 
   //Calculated fields can never be edited:
-  std::shared_ptr<const Field> field_details = field->get_full_field_details();
+  auto field_details = field->get_full_field_details();
   const bool editable_allowed = field_details && !field_details->get_has_calculation();
   m_checkbutton_editable->set_sensitive(editable_allowed);
 
@@ -111,7 +111,7 @@ std::shared_ptr<LayoutItem_Field> Dialog_FieldLayout::get_field_chosen() const
   m_layout_item->set_formatting_use_default( !m_radiobutton_custom_formatting->get_active() );
   m_box_formatting->get_formatting(m_layout_item->m_formatting);
 
-  std::shared_ptr<CustomTitle> title_custom = std::make_shared<CustomTitle>();
+  auto title_custom = std::make_shared<CustomTitle>();
   title_custom->set_use_custom_title(m_radiobutton_title_custom->get_active()); //For instance, tell it to 
really use a blank title.
   title_custom->set_title(m_entry_title_custom->get_text(), AppWindow::get_current_locale());
 
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_field_summary.cc 
b/glom/mode_design/layout/layout_item_dialogs/dialog_field_summary.cc
index 8cf9d5b..a5744a8 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_field_summary.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_field_summary.cc
@@ -56,7 +56,7 @@ void Dialog_FieldSummary::set_item(const std::shared_ptr<const LayoutItem_FieldS
 
 std::shared_ptr<LayoutItem_FieldSummary> Dialog_FieldSummary::get_item() const
 {
-  std::shared_ptr<LayoutItem_FieldSummary> result = glom_sharedptr_clone(m_layout_item);
+  auto result = glom_sharedptr_clone(m_layout_item);
   result->set_summary_type( m_combo_summarytype->get_summary_type() );
 
   return result;
@@ -64,7 +64,7 @@ std::shared_ptr<LayoutItem_FieldSummary> Dialog_FieldSummary::get_item() const
 
 void Dialog_FieldSummary::on_button_field()
 {
-  std::shared_ptr<LayoutItem_Field> field = offer_field_list_select_one_field(m_layout_item, m_table_name, 
this);
+  auto field = offer_field_list_select_one_field(m_layout_item, m_table_name, this);
   if(field)
   {
     m_layout_item->set_field(field);
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 9eab1ad..d035583 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_fieldslist.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_fieldslist.cc
@@ -113,7 +113,7 @@ void Dialog_FieldsList::set_fields(const Glib::ustring& table_name, const Layout
     guint field_sequence = 0;
     for(const auto& base_item : fields)
     {
-      std::shared_ptr<const LayoutItem_Field> item = std::dynamic_pointer_cast<const 
LayoutItem_Field>(base_item);
+      auto item = std::dynamic_pointer_cast<const LayoutItem_Field>(base_item);
       if(!item)
         continue;
 
@@ -196,7 +196,7 @@ LayoutGroup::type_list_items Dialog_FieldsList::get_fields() const
     const auto field_name = item->get_name();
     if(!field_name.empty())
     {
-      std::shared_ptr<LayoutItem_Field> field_copy = glom_sharedptr_clone(item);
+      auto 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;
@@ -320,7 +320,7 @@ void Dialog_FieldsList::on_button_edit_field()
       std::shared_ptr<const LayoutItem_Field> field = row[m_ColumnsFields.m_col_layout_item];
 
       //Get the chosen field:
-      std::shared_ptr<LayoutItem_Field> field_chosen =
+      auto field_chosen =
         offer_field_list_select_one_field(field, m_table_name, this);
 
       //Set the field details in the layout treeview:
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc 
b/glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc
index 1fbbdaa..34165cb 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_group_by.cc
@@ -108,7 +108,7 @@ std::shared_ptr<LayoutItem_GroupBy> Dialog_GroupBy::get_item() const
 
 void Dialog_GroupBy::on_button_field_group_by()
 {
-  std::shared_ptr<LayoutItem_Field> field = 
offer_field_list_select_one_field(m_layout_item->get_field_group_by(), m_table_name, this);
+  auto field = offer_field_list_select_one_field(m_layout_item->get_field_group_by(), m_table_name, this);
   if(field)
   {
     m_layout_item->set_field_group_by(field);
@@ -120,7 +120,7 @@ void Dialog_GroupBy::on_button_formatting_group_by()
 {
   if(m_layout_item)
   {
-    std::shared_ptr<LayoutItem_Field> field = offer_field_formatting(m_layout_item->get_field_group_by(), 
m_table_name, this, false /* no editing options. */);
+    auto field = offer_field_formatting(m_layout_item->get_field_group_by(), m_table_name, this, false /* no 
editing options. */);
     if(field)
     {
       m_layout_item->set_field_group_by(field);
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_imageobject.cc 
b/glom/mode_design/layout/layout_item_dialogs/dialog_imageobject.cc
index ddb664d..91d9c6f 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_imageobject.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_imageobject.cc
@@ -81,7 +81,7 @@ void Dialog_ImageObject::set_imageobject(const std::shared_ptr<const LayoutItem_
 
 std::shared_ptr<LayoutItem_Image> Dialog_ImageObject::get_imageobject() const
 {
-  std::shared_ptr<LayoutItem_Image> result = glom_sharedptr_clone(m_imageobject); //Start with the old 
details, to preserve anything that is not in our UI.
+  auto result = glom_sharedptr_clone(m_imageobject); //Start with the old details, to preserve anything that 
is not in our UI.
 
   result->set_title(m_entry_title->get_text(), AppWindow::get_current_locale());
   result->set_image( m_image->get_value() );
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_line.cc 
b/glom/mode_design/layout/layout_item_dialogs/dialog_line.cc
index 901abf1..5a6b5b6 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_line.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_line.cc
@@ -75,7 +75,7 @@ std::shared_ptr<LayoutItem_Line> Dialog_Line::get_line() const
     std::cerr << G_STRFUNC <<  ": m_line is null" << std::endl;
   }
   
-  std::shared_ptr<LayoutItem_Line> result = glom_sharedptr_clone(m_line); //Start with the old details, to 
preserve anything that is not in our UI.
+  auto result = glom_sharedptr_clone(m_line); //Start with the old details, to preserve anything that is not 
in our UI.
 
   if(!result)
   {
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_sortfields.cc 
b/glom/mode_design/layout/layout_item_dialogs/dialog_sortfields.cc
index 1c11110..0ad3ef8 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_sortfields.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_sortfields.cc
@@ -110,7 +110,7 @@ void Dialog_SortFields::set_fields(const Glib::ustring& table_name, const Layout
     guint field_sequence = 0;
     for(const auto& the_pair : fields)
     {
-      std::shared_ptr<const LayoutItem_Field> item = std::dynamic_pointer_cast<const 
LayoutItem_Field>(the_pair.first);
+      auto item = std::dynamic_pointer_cast<const LayoutItem_Field>(the_pair.first);
 
       auto iterTree = m_model_fields->append();
       Gtk::TreeModel::Row row = *iterTree;
@@ -190,7 +190,7 @@ LayoutItem_GroupBy::type_list_sort_fields Dialog_SortFields::get_fields() const
     const auto field_name = item->get_name();
     if(!field_name.empty())
     {
-      std::shared_ptr<LayoutItem_Field> field_copy = glom_sharedptr_clone(item);
+      auto field_copy = glom_sharedptr_clone(item);
 
       const bool ascending = row[m_ColumnsFields.m_col_ascending];
       result.push_back( LayoutItem_GroupBy::type_pair_sort_field(field_copy, ascending) );
@@ -285,7 +285,7 @@ void Dialog_SortFields::on_button_edit_field()
       std::shared_ptr<const LayoutItem_Field> field = row[m_ColumnsFields.m_col_layout_item];
 
       //Get the chosen field:
-      std::shared_ptr<LayoutItem_Field> field_chosen = 
+      auto field_chosen = 
         offer_field_list_select_one_field(field, m_table_name, this);
       if(field_chosen)
 
diff --git a/glom/mode_design/layout/layout_item_dialogs/dialog_textobject.cc 
b/glom/mode_design/layout/layout_item_dialogs/dialog_textobject.cc
index 47f76e7..834bb77 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_textobject.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_textobject.cc
@@ -71,7 +71,7 @@ void Dialog_TextObject::set_textobject(const std::shared_ptr<const LayoutItem_Te
 
 std::shared_ptr<LayoutItem_Text> Dialog_TextObject::get_textobject() const
 {
-  std::shared_ptr<LayoutItem_Text> result = glom_sharedptr_clone(m_textobject); //Start with the old 
details, to preserve anything that is not in our UI.
+  auto result = glom_sharedptr_clone(m_textobject); //Start with the old details, to preserve anything that 
is not in our UI.
 
   get_textobject(result);
 
diff --git a/glom/mode_design/layout/treestore_layout.cc b/glom/mode_design/layout/treestore_layout.cc
index 1f01739..fd2e30b 100644
--- a/glom/mode_design/layout/treestore_layout.cc
+++ b/glom/mode_design/layout/treestore_layout.cc
@@ -81,7 +81,7 @@ bool TreeStore_Layout::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest,
       Gtk::TreeModel::Row row = *iter_dragged;
 
       std::shared_ptr<LayoutItem> layout_item = row[m_columns.m_col_layout_item];
-      std::shared_ptr<LayoutGroup> layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
+      auto layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
       const bool is_group = (bool)layout_group;
 
       return is_group; //Only groups can be dragged to the top-level.
@@ -102,7 +102,7 @@ bool TreeStore_Layout::row_drop_possible_vfunc(const Gtk::TreeModel::Path& dest,
       Gtk::TreeModel::Row row_parent = *iter_dest_parent;
 
       std::shared_ptr<LayoutItem> layout_item = row_parent[m_columns.m_col_layout_item];
-      std::shared_ptr<LayoutGroup> layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
+      auto layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
       const bool is_group = (bool)layout_group;
 
       return is_group; //Only groups can contain other items.
diff --git a/glom/mode_design/print_layouts/box_print_layouts.cc 
b/glom/mode_design/print_layouts/box_print_layouts.cc
index d9d40f9..c58b055 100644
--- a/glom/mode_design/print_layouts/box_print_layouts.cc
+++ b/glom/mode_design/print_layouts/box_print_layouts.cc
@@ -100,7 +100,7 @@ bool Box_Print_Layouts::fill_from_database()
   {
     for(const auto& print_layout_name : document->get_print_layout_names(m_table_name))
     {
-      std::shared_ptr<PrintLayout> item = document->get_print_layout(m_table_name, print_layout_name);
+      auto item = document->get_print_layout(m_table_name, print_layout_name);
       if(item)
       {
         auto row = m_AddDel.add_item(item->get_name());
@@ -121,7 +121,7 @@ bool Box_Print_Layouts::fill_from_database()
 
 void Box_Print_Layouts::on_adddel_user_added(const Gtk::TreeModel::iterator& row)
 {
-  std::shared_ptr<PrintLayout> item = std::make_shared<PrintLayout>();
+  auto item = std::make_shared<PrintLayout>();
 
   const auto name = m_AddDel.get_value(row, m_colName);
   if(!name.empty())
@@ -203,7 +203,7 @@ void Box_Print_Layouts::on_adddel_user_changed(const Gtk::TreeModel::iterator& r
     const auto name = m_AddDel.get_value_key(row);
     auto document = get_document();
 
-    std::shared_ptr<PrintLayout> item = document->get_print_layout(m_table_name, name);
+    auto item = document->get_print_layout(m_table_name, name);
     if(item)
     {
       if(column == m_colTitle)
diff --git a/glom/mode_design/print_layouts/window_print_layout_edit.cc 
b/glom/mode_design/print_layouts/window_print_layout_edit.cc
index 870557e..12e9fd4 100644
--- a/glom/mode_design/print_layouts/window_print_layout_edit.cc
+++ b/glom/mode_design/print_layouts/window_print_layout_edit.cc
@@ -369,7 +369,7 @@ std::shared_ptr<LayoutItem> Window_PrintLayout_Edit::create_empty_item(PrintLayo
 
   if(item_type == PrintLayoutToolbarButton::enumItems::FIELD)
   {
-    std::shared_ptr<LayoutItem_Field> layout_item_derived  = std::make_shared<LayoutItem_Field>();
+    auto layout_item_derived  = std::make_shared<LayoutItem_Field>();
     layout_item = layout_item_derived;
     layout_item->set_print_layout_position(0, 0,
       PrintLayoutUtils::ITEM_WIDTH_WIDE, PrintLayoutUtils::ITEM_HEIGHT);
@@ -379,7 +379,7 @@ std::shared_ptr<LayoutItem> Window_PrintLayout_Edit::create_empty_item(PrintLayo
   }
   else if(item_type == PrintLayoutToolbarButton::enumItems::TEXT)
   {
-    std::shared_ptr<LayoutItem_Text> layout_item_derived = std::make_shared<LayoutItem_Text>();
+    auto layout_item_derived = std::make_shared<LayoutItem_Text>();
 
     // Note to translators: This is the default contents of a text item on a print layout: 
     layout_item_derived->set_text_original(_("text")); //TODO: Choose some other longer default because this 
is hidden under the drag icon?
@@ -395,20 +395,20 @@ std::shared_ptr<LayoutItem> Window_PrintLayout_Edit::create_empty_item(PrintLayo
   }
   else if(item_type == PrintLayoutToolbarButton::enumItems::LINE_HORIZONTAL)
   {
-    std::shared_ptr<LayoutItem_Line> layout_item_derived = std::make_shared<LayoutItem_Line>();
+    auto layout_item_derived = std::make_shared<LayoutItem_Line>();
     layout_item_derived->set_coordinates(0, 0,
       PrintLayoutUtils::ITEM_WIDTH_WIDE * 2, 0);
     layout_item = layout_item_derived;
   }
   else if(item_type == PrintLayoutToolbarButton::enumItems::LINE_VERTICAL)
   {
-    std::shared_ptr<LayoutItem_Line> layout_item_derived = std::make_shared<LayoutItem_Line>();
+    auto layout_item_derived = std::make_shared<LayoutItem_Line>();
     layout_item_derived->set_coordinates(0, 0, 0, PrintLayoutUtils::ITEM_WIDTH_WIDE * 2);
     layout_item = layout_item_derived;
   }
   else if(item_type == PrintLayoutToolbarButton::enumItems::PORTAL)
   {
-    std::shared_ptr<LayoutItem_Portal> portal = std::make_shared<LayoutItem_Portal>();
+    auto portal = std::make_shared<LayoutItem_Portal>();
     portal->set_print_layout_row_height(10); //Otherwise it will be 0, which is useless.
     layout_item = portal;
     layout_item->set_print_layout_position(0, 0,
@@ -422,7 +422,7 @@ std::shared_ptr<LayoutItem> Window_PrintLayout_Edit::create_empty_item(PrintLayo
   //Set a default text style and size:
   //12pt text seems sane. It is what OpenOffice/LibreOffice and Abiword use:
   //Serif (rather than sans-serif) is sane for body text:
-  std::shared_ptr<LayoutItem_WithFormatting> with_formatting = 
+  auto with_formatting = 
     std::dynamic_pointer_cast<LayoutItem_WithFormatting>(layout_item);
   if(with_formatting)
     with_formatting->m_formatting.set_text_format_font("Serif 12");
@@ -493,7 +493,7 @@ void Window_PrintLayout_Edit::on_canvas_drag_data_received(const Glib::RefPtr<Gd
     //Create the temporary drag item if necessary:
     if(!m_layout_item_dropping)
     {
-      std::shared_ptr<LayoutItem> layout_item = create_empty_item(item_type);
+      auto layout_item = create_empty_item(item_type);
 
       //Show it on the canvas, at the position:
       if(layout_item)
@@ -516,7 +516,7 @@ void Window_PrintLayout_Edit::on_canvas_drag_data_received(const Glib::RefPtr<Gd
     m_canvas.drag_unhighlight();
 
     //Add the item to the canvas:
-    std::shared_ptr<LayoutItem> layout_item = create_empty_item(item_type);
+    auto layout_item = create_empty_item(item_type);
     if(!layout_item)
     {
       std::cerr << G_STRFUNC << ": layout_item is null." << std::endl;
@@ -652,15 +652,15 @@ std::shared_ptr<PrintLayout> Window_PrintLayout_Edit::get_print_layout()
   m_print_layout->get_layout_group()->remove_all_items();
 
   //The Header and Footer parts are implicit (they are the whole header or footer treeview)
-  std::shared_ptr<LayoutItem_Header> header = std::make_shared<LayoutItem_Header>();
-  std::shared_ptr<LayoutGroup> group_temp = header;
+  auto header = std::make_shared<LayoutItem_Header>();
+  auto group_temp = header;
   fill_print_layout_parts(group_temp, m_model_parts_header);
   if(header->get_items_count())
     m_print_layout->get_layout_group()->add_item(header);
 
   fill_print_layout_parts(m_print_layout->get_layout_group(), m_model_parts_main);
 
-  std::shared_ptr<LayoutItem_Footer> footer = std::make_shared<LayoutItem_Footer>();
+  auto footer = std::make_shared<LayoutItem_Footer>();
   group_temp = footer;
   fill_print_layout_parts(group_temp, m_model_parts_footer);
   if(footer->get_items_count())
@@ -771,7 +771,7 @@ void Window_PrintLayout_Edit::set_default_position(const std::shared_ptr<LayoutI
 
 void Window_PrintLayout_Edit::on_menu_insert_field()
 {
-  std::shared_ptr<LayoutItem> layout_item = create_empty_item(PrintLayoutToolbarButton::enumItems::FIELD);
+  auto layout_item = create_empty_item(PrintLayoutToolbarButton::enumItems::FIELD);
 
   // Note to translators: This is the default contents of a text item on a print layout: 
   set_default_position(layout_item);
@@ -781,7 +781,7 @@ void Window_PrintLayout_Edit::on_menu_insert_field()
 
 void Window_PrintLayout_Edit::on_menu_insert_text()
 {
-  std::shared_ptr<LayoutItem> layout_item = create_empty_item(PrintLayoutToolbarButton::enumItems::TEXT);
+  auto layout_item = create_empty_item(PrintLayoutToolbarButton::enumItems::TEXT);
   set_default_position(layout_item);
 
   create_canvas_layout_item_and_add(layout_item);
@@ -789,7 +789,7 @@ void Window_PrintLayout_Edit::on_menu_insert_text()
 
 void Window_PrintLayout_Edit::on_menu_insert_image()
 {
-  std::shared_ptr<LayoutItem> layout_item = create_empty_item(PrintLayoutToolbarButton::enumItems::IMAGE);
+  auto layout_item = create_empty_item(PrintLayoutToolbarButton::enumItems::IMAGE);
   // Note to translators: This is the default contents of a text item on a print layout: 
   //layout_item->set_text_original(_("text"));
   set_default_position(layout_item);
@@ -799,7 +799,7 @@ void Window_PrintLayout_Edit::on_menu_insert_image()
 
 void Window_PrintLayout_Edit::on_menu_insert_relatedrecords()
 {
-  std::shared_ptr<LayoutItem> layout_item = create_empty_item(PrintLayoutToolbarButton::enumItems::PORTAL);
+  auto layout_item = create_empty_item(PrintLayoutToolbarButton::enumItems::PORTAL);
   set_default_position(layout_item);
 
   create_canvas_layout_item_and_add(layout_item);
@@ -807,7 +807,7 @@ void Window_PrintLayout_Edit::on_menu_insert_relatedrecords()
 
 void Window_PrintLayout_Edit::on_menu_insert_line_horizontal()
 {
-  std::shared_ptr<LayoutItem> layout_item = 
create_empty_item(PrintLayoutToolbarButton::enumItems::LINE_HORIZONTAL);
+  auto layout_item = create_empty_item(PrintLayoutToolbarButton::enumItems::LINE_HORIZONTAL);
 
   /*
   double item_x = m_drop_x;
@@ -824,7 +824,7 @@ void Window_PrintLayout_Edit::on_menu_insert_line_horizontal()
 
 void Window_PrintLayout_Edit::on_menu_insert_line_vertical()
 {
-  std::shared_ptr<LayoutItem> layout_item = 
create_empty_item(PrintLayoutToolbarButton::enumItems::LINE_VERTICAL);
+  auto layout_item = create_empty_item(PrintLayoutToolbarButton::enumItems::LINE_VERTICAL);
 
   create_canvas_layout_item_and_add(layout_item);
 }
@@ -1025,7 +1025,7 @@ void Window_PrintLayout_Edit::on_menu_file_print_preview()
     return;
 
   const auto original_name = get_original_name();
-  std::shared_ptr<PrintLayout> print_layout = get_print_layout();
+  auto print_layout = get_print_layout();
   if(print_layout && (original_name != get_name()))
     document->remove_print_layout(m_table_name, original_name);
 
@@ -1055,7 +1055,7 @@ void Window_PrintLayout_Edit::on_menu_edit_copy()
     if(item)
       item->update_layout_position_from_canvas();
 
-    std::shared_ptr<LayoutItem> cloned = 
+    auto cloned = 
       glom_sharedptr_clone(item->get_layout_item());
 
     m_layout_items_to_paste.push_back(cloned);
diff --git a/glom/mode_design/report_layout/dialog_layout_report.cc 
b/glom/mode_design/report_layout/dialog_layout_report.cc
index 161f481..3093157 100644
--- a/glom/mode_design/report_layout/dialog_layout_report.cc
+++ b/glom/mode_design/report_layout/dialog_layout_report.cc
@@ -242,7 +242,7 @@ std::shared_ptr<LayoutGroup> Dialog_Layout_Report::fill_group(const Gtk::TreeMod
     Gtk::TreeModel::Row row = *iter;
 
     std::shared_ptr<LayoutItem> pItem = row[model->m_columns.m_col_item];
-    std::shared_ptr<LayoutGroup> pGroup = std::dynamic_pointer_cast<LayoutGroup>(pItem);
+    auto pGroup = std::dynamic_pointer_cast<LayoutGroup>(pItem);
     if(pGroup)
     {
       //Make sure that it contains the child items:
@@ -267,7 +267,7 @@ void Dialog_Layout_Report::fill_group_children(const std::shared_ptr<LayoutGroup
       std::shared_ptr<LayoutItem> item = child_row[model->m_columns.m_col_item];
 
       //Recurse:
-      std::shared_ptr<LayoutGroup> child_group = std::dynamic_pointer_cast<LayoutGroup>(item);
+      auto child_group = std::dynamic_pointer_cast<LayoutGroup>(item);
       if(child_group)
         fill_group_children(child_group, child_row, model);
 
@@ -282,11 +282,11 @@ void Dialog_Layout_Report::add_group_children(const Glib::RefPtr<type_model>& mo
 {
   for(const auto& item : group->m_list_items)
   {
-    std::shared_ptr<const LayoutGroup> child_group = std::dynamic_pointer_cast<const LayoutGroup>(item);
+    auto child_group = std::dynamic_pointer_cast<const LayoutGroup>(item);
     if(child_group)
     {
-      std::shared_ptr<const LayoutItem_Header> header = std::dynamic_pointer_cast<const 
LayoutItem_Header>(item);
-      std::shared_ptr<const LayoutItem_Footer> footer = std::dynamic_pointer_cast<const 
LayoutItem_Footer>(item);
+      auto header = std::dynamic_pointer_cast<const LayoutItem_Header>(item);
+      auto footer = std::dynamic_pointer_cast<const LayoutItem_Footer>(item);
 
       //Special-case the header and footer so that their items go into the separate treeviews:
       if(header)
@@ -446,7 +446,7 @@ void Dialog_Layout_Report::enable_buttons()
 
       //The [Formatting] button:
       bool enable_formatting = false;
-      std::shared_ptr<LayoutItem_Field> item_field = 
std::dynamic_pointer_cast<LayoutItem_Field>(layout_item_parent);
+      auto item_field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item_parent);
       if(item_field)
         enable_formatting = true;
 
@@ -786,10 +786,10 @@ void Dialog_Layout_Report::on_button_formatting()
       Gtk::TreeModel::Row row = *iter;
       std::shared_ptr<LayoutItem> item = row[model->m_columns.m_col_item];
 
-      std::shared_ptr<LayoutItem_Field> field = std::dynamic_pointer_cast<LayoutItem_Field>(item);
+      auto field = std::dynamic_pointer_cast<LayoutItem_Field>(item);
       if(field)
       {
-        std::shared_ptr<LayoutItem_Field> field_chosen = offer_field_formatting(field, m_table_name, this, 
false /* no editing options */);
+        auto field_chosen = offer_field_formatting(field, m_table_name, this, false /* no editing options 
*/);
         if(field_chosen)
         {
           *field = *field_chosen;
@@ -819,7 +819,7 @@ void Dialog_Layout_Report::on_button_edit()
       Gtk::TreeModel::Row row = *iter;
       std::shared_ptr<LayoutItem> item = row[model->m_columns.m_col_item];
 
-      std::shared_ptr<LayoutItem_FieldSummary> fieldsummary = 
std::dynamic_pointer_cast<LayoutItem_FieldSummary>(item);
+      auto fieldsummary = std::dynamic_pointer_cast<LayoutItem_FieldSummary>(item);
       if(fieldsummary)
       {
         Dialog_FieldSummary* dialog = nullptr;
@@ -834,7 +834,7 @@ void Dialog_Layout_Report::on_button_edit()
         if(dialog_response == Gtk::RESPONSE_OK)
         {
           //Get the chosen relationship:
-          std::shared_ptr<LayoutItem_FieldSummary> chosenitem = dialog->get_item();
+          auto chosenitem = dialog->get_item();
           if(chosenitem)
           {
             *fieldsummary = *chosenitem; //TODO_Performance.
@@ -849,10 +849,10 @@ void Dialog_Layout_Report::on_button_edit()
       }
       else
       {
-        std::shared_ptr<LayoutItem_Field> field = std::dynamic_pointer_cast<LayoutItem_Field>(item);
+        auto field = std::dynamic_pointer_cast<LayoutItem_Field>(item);
         if(field)
         {
-          std::shared_ptr<LayoutItem_Field> chosenitem = offer_field_list_select_one_field(field, 
m_table_name, this);
+          auto chosenitem = offer_field_list_select_one_field(field, m_table_name, this);
           if(chosenitem)
           {
             *field = *chosenitem; //TODO_Performance.
@@ -862,10 +862,10 @@ void Dialog_Layout_Report::on_button_edit()
         }
         else
         {
-          std::shared_ptr<LayoutItem_Text> layout_item_text = 
std::dynamic_pointer_cast<LayoutItem_Text>(item);
+          auto layout_item_text = std::dynamic_pointer_cast<LayoutItem_Text>(item);
           if(layout_item_text)
           {
-            std::shared_ptr<LayoutItem_Text> chosen = offer_textobject(layout_item_text);
+            auto chosen = offer_textobject(layout_item_text);
             if(chosen)
             {
               *layout_item_text = *chosen;
@@ -875,10 +875,10 @@ void Dialog_Layout_Report::on_button_edit()
           }
           else
           {
-            std::shared_ptr<LayoutItem_Image> layout_item_image = 
std::dynamic_pointer_cast<LayoutItem_Image>(item);
+            auto layout_item_image = std::dynamic_pointer_cast<LayoutItem_Image>(item);
             if(layout_item_image)
             {
-              std::shared_ptr<LayoutItem_Image> chosen = offer_imageobject(layout_item_image);
+              auto chosen = offer_imageobject(layout_item_image);
               if(chosen)
               {
                 *layout_item_image = *chosen;
@@ -888,7 +888,7 @@ void Dialog_Layout_Report::on_button_edit()
             }
             else
             {
-              std::shared_ptr<LayoutItem_GroupBy> group_by = 
std::dynamic_pointer_cast<LayoutItem_GroupBy>(item);
+              auto group_by = std::dynamic_pointer_cast<LayoutItem_GroupBy>(item);
               if(group_by)
               {
                 Dialog_GroupBy* dialog = nullptr;
@@ -906,7 +906,7 @@ void Dialog_Layout_Report::on_button_edit()
                 if(dialog_response == Gtk::RESPONSE_OK)
                 {
                   //Get the chosen relationship:
-                  std::shared_ptr<LayoutItem_GroupBy> chosenitem = dialog->get_item();
+                  auto chosenitem = dialog->get_item();
                   if(chosenitem)
                   {
                     *group_by = *chosenitem;
@@ -1013,11 +1013,11 @@ std::shared_ptr<Report> Dialog_Layout_Report::get_report()
   m_report->set_title( m_entry_title->get_text() , AppWindow::get_current_locale());
   m_report->set_show_table_title( m_checkbutton_table_title->get_active() );
 
-  std::shared_ptr<LayoutGroup> group = m_report->get_layout_group();
+  auto group = m_report->get_layout_group();
   group->remove_all_items();
 
   //The Header and Footer parts are implicit (they are the whole header or footer treeview)
-  std::shared_ptr<LayoutItem_Header> header = std::make_shared<LayoutItem_Header>();
+  auto header = std::make_shared<LayoutItem_Header>();
   std::shared_ptr<LayoutGroup> group_temp = header;
   fill_report_parts(group_temp, m_model_parts_header);
   if(header->get_items_count())
@@ -1039,7 +1039,7 @@ void Dialog_Layout_Report::fill_report_parts(std::shared_ptr<LayoutGroup>& group
   for(const auto& row : parts_model->children())
   {
     //Recurse into a group if necessary:
-    std::shared_ptr<LayoutGroup> group_child = fill_group(row, parts_model);
+    auto group_child = fill_group(row, parts_model);
     if(group_child)
     {
       //Add the group:
diff --git a/glom/mode_design/report_layout/treestore_report_layout.cc 
b/glom/mode_design/report_layout/treestore_report_layout.cc
index 1ae7629..908a7fc 100644
--- a/glom/mode_design/report_layout/treestore_report_layout.cc
+++ b/glom/mode_design/report_layout/treestore_report_layout.cc
@@ -142,7 +142,7 @@ bool TreeStore_ReportLayout::may_be_child_of(const std::shared_ptr<const LayoutI
 
   const bool child_fieldsummary = (bool)std::dynamic_pointer_cast<const 
LayoutItem_FieldSummary>(suggested_child);
 
-  std::shared_ptr<const LayoutItem_Summary> summary = std::dynamic_pointer_cast<const 
LayoutItem_Summary>(parent);
+  auto summary = std::dynamic_pointer_cast<const LayoutItem_Summary>(parent);
 
   //A Summary may only have FieldSummary children:
   if(summary && !(bool)child_fieldsummary)
diff --git a/glom/mode_design/users/dialog_groups_list.cc b/glom/mode_design/users/dialog_groups_list.cc
index 550de7e..e5e4c81 100644
--- a/glom/mode_design/users/dialog_groups_list.cc
+++ b/glom/mode_design/users/dialog_groups_list.cc
@@ -155,7 +155,7 @@ void Dialog_GroupsList::set_document(const Glib::ustring& layout, Document* docu
 
     for(const auto& the_pair : mapGroups)
     {
-      std::shared_ptr<const LayoutGroup> group = the_pairsecond;
+      auto group = the_pairsecond;
 
       add_group(Gtk::TreeModel::iterator(), group);
     }
diff --git a/glom/navigation/box_tables.cc b/glom/navigation/box_tables.cc
index ad2b4e8..69f6bff 100644
--- a/glom/navigation/box_tables.cc
+++ b/glom/navigation/box_tables.cc
@@ -149,7 +149,7 @@ bool Box_Tables::fill_from_database()
     std::cerr << G_STRFUNC << ": document is null" << std::endl;
 
   //Get the list of tables in the database, from the server:
-  std::shared_ptr<SharedConnection> sharedconnection = connect_to_server(AppWindow::get_appwindow());
+  auto sharedconnection = connect_to_server(AppWindow::get_appwindow());
 
   if(sharedconnection)
   {
@@ -251,7 +251,7 @@ void Box_Tables::on_adddel_Add(const Gtk::TreeModel::iterator& row)
     auto document = get_document();
     if(document)
     {
-      std::shared_ptr<TableInfo> table_info = document->get_table(table_name);
+      auto table_info = document->get_table(table_name);
       fill_table_row(row, table_info);
 
       //Save the field information directly into the database, because we cannot get all the correct 
information from the database.
@@ -461,7 +461,7 @@ void Box_Tables::save_to_document()
     for(const auto& row : m_AddDel.get_model()->children())
     {
       const auto table_name = m_AddDel.get_value(row, m_colTableName); //The name has already been changed 
in the document.
-      std::shared_ptr<TableInfo> table_info = document->get_table(table_name); //Start with the existing 
table_info, to preserve extra information, such as translations.
+      auto table_info = document->get_table(table_name); //Start with the existing table_info, to preserve 
extra information, such as translations.
       if(table_info)
       {
         table_info->set_name( m_AddDel.get_value(row, m_colTableName) );
diff --git a/glom/print_layout/canvas_layout_item.cc b/glom/print_layout/canvas_layout_item.cc
index 2e26673..bb0cbc8 100644
--- a/glom/print_layout/canvas_layout_item.cc
+++ b/glom/print_layout/canvas_layout_item.cc
@@ -157,7 +157,7 @@ Glib::RefPtr<CanvasItemMovable> CanvasLayoutItem::create_canvas_item_for_layout_
 {
   Glib::RefPtr<CanvasItemMovable> child;
   Glib::RefPtr<Goocanvas::Item> child_item;
-  std::shared_ptr<LayoutItem_Text> text = std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
+  auto text = std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
   if(text)
   {
     Glib::RefPtr<CanvasTextMovable> canvas_item = CanvasTextMovable::create();
@@ -171,7 +171,7 @@ Glib::RefPtr<CanvasItemMovable> CanvasLayoutItem::create_canvas_item_for_layout_
   }
   else
   {
-    std::shared_ptr<LayoutItem_Image> image = std::dynamic_pointer_cast<LayoutItem_Image>(layout_item);
+    auto image = std::dynamic_pointer_cast<LayoutItem_Image>(layout_item);
     if(image)
     {
       Glib::RefPtr<CanvasImageMovable> canvas_item = CanvasImageMovable::create();
@@ -189,7 +189,7 @@ Glib::RefPtr<CanvasItemMovable> CanvasLayoutItem::create_canvas_item_for_layout_
     }
     else
     {
-      std::shared_ptr<LayoutItem_Line> line = std::dynamic_pointer_cast<LayoutItem_Line>(layout_item);
+      auto line = std::dynamic_pointer_cast<LayoutItem_Line>(layout_item);
       if(line)
       {
         double start_x = 0;
@@ -211,7 +211,7 @@ Glib::RefPtr<CanvasItemMovable> CanvasLayoutItem::create_canvas_item_for_layout_
       }
       else
       {
-        std::shared_ptr<LayoutItem_Field> field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+        auto field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
         if(field)
         {
           //Create an appropriate canvas item for the field type:
@@ -241,7 +241,7 @@ Glib::RefPtr<CanvasItemMovable> CanvasLayoutItem::create_canvas_item_for_layout_
         }
         else
         {
-          std::shared_ptr<LayoutItem_Portal> portal = 
std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
+          auto portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
           if(portal)
           {
             Glib::RefPtr<CanvasTableMovable> canvas_item = CanvasTableMovable::create();
@@ -314,7 +314,7 @@ void CanvasLayoutItem::add_portal_rows_if_necessary(guint rows_count)
   if(!canvas_table)
     return;
 
-  std::shared_ptr<LayoutItem_Portal> portal = 
+  auto portal = 
     std::dynamic_pointer_cast<LayoutItem_Portal>(get_layout_item());
   if(!portal)
   {
@@ -414,7 +414,7 @@ void CanvasLayoutItem::add_portal_rows_if_necessary(const Glib::RefPtr<CanvasTab
 
 void CanvasLayoutItem::set_db_data(const Gnome::Gda::Value& value)
 {
-  std::shared_ptr<LayoutItem_Field> field = std::dynamic_pointer_cast<LayoutItem_Field>(m_layout_item);
+  auto field = std::dynamic_pointer_cast<LayoutItem_Field>(m_layout_item);
   if(!field)
     return;
 
@@ -491,7 +491,7 @@ void CanvasLayoutItem::remove_empty_indicators()
 
 void CanvasLayoutItem::update_layout_position_from_canvas()
 {
-  std::shared_ptr<LayoutItem> layout_item = get_layout_item();
+  auto layout_item = get_layout_item();
   if(!layout_item)
     return;
 
diff --git a/glom/print_layout/canvas_print_layout.cc b/glom/print_layout/canvas_print_layout.cc
index 2d32204..9708730 100644
--- a/glom/print_layout/canvas_print_layout.cc
+++ b/glom/print_layout/canvas_print_layout.cc
@@ -117,7 +117,7 @@ void Canvas_PrintLayout::set_print_layout(const Glib::ustring& table_name, const
 
 std::shared_ptr<PrintLayout> Canvas_PrintLayout::get_print_layout()
 {
-  std::shared_ptr<PrintLayout> result = std::make_shared<PrintLayout>();
+  auto result = std::make_shared<PrintLayout>();
   fill_layout_group(result->get_layout_group());
 
   //Page Setup:
@@ -155,8 +155,8 @@ void Canvas_PrintLayout::add_layout_group_children(const std::shared_ptr<LayoutG
   //TODO: Add them inside the group item (when we actually use this code):
   for(const auto& child_item : group->m_list_items)
   {
-    std::shared_ptr<LayoutItem_Portal> child_portal = 
std::dynamic_pointer_cast<LayoutItem_Portal>(child_item);
-    std::shared_ptr<LayoutGroup> child_group = std::dynamic_pointer_cast<LayoutGroup>(child_item);
+    auto child_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(child_item);
+    auto child_group = std::dynamic_pointer_cast<LayoutGroup>(child_item);
     if(child_group && !child_portal)
     {
       add_layout_group(child_group);
@@ -299,7 +299,7 @@ void Canvas_PrintLayout::on_item_show_context_menu(guint button, guint32 activat
   m_context_item = item;
   
   //Do not enable the Formatting menu item for all types of items:
-  std::shared_ptr<LayoutItem> layout_item = m_context_item->get_layout_item();
+  auto layout_item = m_context_item->get_layout_item();
   bool enable_formatting = false;
   if(std::dynamic_pointer_cast<LayoutItem_WithFormatting>(layout_item))
   {
@@ -320,7 +320,7 @@ bool Canvas_PrintLayout::on_background_button_press_event(const Glib::RefPtr<Goo
 
 std::shared_ptr<LayoutItem_Portal> Canvas_PrintLayout::offer_related_records(const 
std::shared_ptr<LayoutItem_Portal>& portal, Gtk::Window* parent)
 {
-  std::shared_ptr<LayoutItem_Portal> result = portal;
+  auto result = portal;
 
   Dialog_Layout_List_Related* dialog = nullptr;
   Utils::get_glade_widget_derived_with_warning(dialog);
@@ -348,7 +348,7 @@ std::shared_ptr<LayoutItem_Portal> Canvas_PrintLayout::offer_related_records(con
 
 std::shared_ptr<LayoutItem_Line> Canvas_PrintLayout::offer_line(const std::shared_ptr<LayoutItem_Line>& 
line, Gtk::Window* parent)
 {
-  std::shared_ptr<LayoutItem_Line> result = line;
+  auto result = line;
 
   Dialog_Line* dialog = nullptr;
   Utils::get_glade_widget_derived_with_warning(dialog);
@@ -379,12 +379,12 @@ void Canvas_PrintLayout::on_context_menu_edit()
 
   m_context_item->update_layout_position_from_canvas();
 
-  std::shared_ptr<LayoutItem> layout_item = m_context_item->get_layout_item();
-  std::shared_ptr<LayoutItem_Field> field = 
+  auto layout_item = m_context_item->get_layout_item();
+  auto field = 
     std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
   if(field)
   {
-    std::shared_ptr<LayoutItem_Field> field_chosen = offer_field_list_select_one_field(field, m_table_name, 
parent);
+    auto field_chosen = offer_field_list_select_one_field(field, m_table_name, parent);
     if(field_chosen)
     {
       //Never use the default formatting for print layouts:
@@ -396,7 +396,7 @@ void Canvas_PrintLayout::on_context_menu_edit()
   }
   else
   {
-    std::shared_ptr<LayoutItem_Text> text = std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
+    auto text = std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
     if(text)
     {
       text = Base_DB::offer_textobject(text, parent, false /* don't show title */);
@@ -404,7 +404,7 @@ void Canvas_PrintLayout::on_context_menu_edit()
     }
     else
     {
-      std::shared_ptr<LayoutItem_Image> image = std::dynamic_pointer_cast<LayoutItem_Image>(layout_item);
+      auto image = std::dynamic_pointer_cast<LayoutItem_Image>(layout_item);
       if(image)
       {
         image = Base_DB::offer_imageobject(image, parent, false /* don't show title */);
@@ -412,7 +412,7 @@ void Canvas_PrintLayout::on_context_menu_edit()
       }
       else
       {
-        std::shared_ptr<LayoutItem_Portal> portal = 
std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
+        auto portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
         if(portal)
         {
           portal = offer_related_records(portal, parent);
@@ -420,7 +420,7 @@ void Canvas_PrintLayout::on_context_menu_edit()
         }
         else
         {
-         std::shared_ptr<LayoutItem_Line> line = std::dynamic_pointer_cast<LayoutItem_Line>(layout_item);
+         auto line = std::dynamic_pointer_cast<LayoutItem_Line>(layout_item);
          if(line)
          {
            line = offer_line(line, parent);
@@ -443,9 +443,9 @@ void Canvas_PrintLayout::on_context_menu_formatting()
 
   m_context_item->update_layout_position_from_canvas();
 
-  std::shared_ptr<LayoutItem> layout_item = m_context_item->get_layout_item();
-  std::shared_ptr<LayoutItem_Field> layout_item_field = 
std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
-  std::shared_ptr<LayoutItem_Text> layout_item_text = 
std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
+  auto layout_item = m_context_item->get_layout_item();
+  auto layout_item_field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+  auto layout_item_text = std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
   if(!layout_item_field && !layout_item_text)
     return;
 
@@ -516,9 +516,9 @@ void Canvas_PrintLayout::on_dialog_format_hide()
   if(!m_dialog_format || !m_context_item)
     return;
 
-  std::shared_ptr<LayoutItem> layout_item = m_context_item->get_layout_item();
-  std::shared_ptr<LayoutItem_Field> layout_item_field = 
std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
-  std::shared_ptr<LayoutItem_Text> layout_item_text = 
std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
+  auto layout_item = m_context_item->get_layout_item();
+  auto layout_item_field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+  auto layout_item_text = std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
   if(!layout_item_field && !layout_item_text)
     return;
 
@@ -700,7 +700,7 @@ void Canvas_PrintLayout::fill_with_data(const FoundSet& found_set, bool avoid_pa
 
 void Canvas_PrintLayout::fill_with_data_system_preferences(const Glib::RefPtr<CanvasLayoutItem>& 
canvas_item, Document* document)
 {
-  std::shared_ptr<LayoutItem_Field> layoutitem_field = 
+  auto layoutitem_field = 
     std::dynamic_pointer_cast<LayoutItem_Field>(canvas_item->get_layout_item());
   if(!layoutitem_field)
     return;
@@ -708,7 +708,7 @@ void Canvas_PrintLayout::fill_with_data_system_preferences(const Glib::RefPtr<Ca
   bool empty = true;
   if(!layoutitem_field->get_name().empty())
   {
-    const std::shared_ptr<const Relationship> relationship = 
+    const auto relationship = 
       layoutitem_field->get_relationship();
 
     if(!document)
@@ -754,11 +754,11 @@ void Canvas_PrintLayout::fill_with_data(const Glib::RefPtr<Goocanvas::Group>& ca
     if(!canvas_item)
       continue;
 
-    std::shared_ptr<LayoutItem> layout_item = canvas_item->get_layout_item();
+    auto layout_item = canvas_item->get_layout_item();
     if(!layout_item)
       continue;
 
-    std::shared_ptr<LayoutItem_Field> layoutitem_field = 
std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+    auto layoutitem_field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
     if(layoutitem_field && !(layoutitem_field->get_name().empty()))
     {
       fieldsToGet.push_back(layoutitem_field);
@@ -770,11 +770,11 @@ void Canvas_PrintLayout::fill_with_data(const Glib::RefPtr<Goocanvas::Group>& ca
     }
     else
     {
-      std::shared_ptr<LayoutItem_Portal> layoutitem_portal = 
std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
+      auto layoutitem_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
       if(layoutitem_portal)
       {
         //Fill the related records table:
-        std::shared_ptr<const Relationship> relationship = layoutitem_portal->get_relationship();
+        auto relationship = layoutitem_portal->get_relationship();
         if(relationship)
         {
           const auto document = get_document();
@@ -829,11 +829,11 @@ void Canvas_PrintLayout::fill_with_data(const Glib::RefPtr<Goocanvas::Group>& ca
     if(!canvas_item)
       continue;
 
-    std::shared_ptr<LayoutItem> layout_item = canvas_item->get_layout_item();
+    auto layout_item = canvas_item->get_layout_item();
     if(!layout_item)
       continue;
 
-    std::shared_ptr<LayoutItem_Field> layoutitem_field = 
std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+    auto layoutitem_field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
     if(layoutitem_field)
     {
       const auto iterFind = map_fields_index.find( layoutitem_field->get_layout_display_name() );
@@ -880,8 +880,8 @@ void Canvas_PrintLayout::fill_with_data_portal(const Glib::RefPtr<CanvasLayoutIt
   if(!canvas_item)
     return;
 
-  std::shared_ptr<LayoutItem> layout_item = canvas_item->get_layout_item();
-  std::shared_ptr<LayoutItem_Portal> portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
+  auto layout_item = canvas_item->get_layout_item();
+  auto portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
   if(!portal)
     return;
 
@@ -961,8 +961,8 @@ void Canvas_PrintLayout::fill_with_data_portal(const Glib::RefPtr<CanvasLayoutIt
       if(iter_child_layout_items == child_layout_items.end())
         continue;
 
-      std::shared_ptr<LayoutItem> child_layout_item = *iter_child_layout_items;
-      std::shared_ptr<LayoutItem_Field> field = 
std::dynamic_pointer_cast<LayoutItem_Field>(child_layout_item);
+      auto child_layout_item = *iter_child_layout_items;
+      auto field = std::dynamic_pointer_cast<LayoutItem_Field>(child_layout_item);
       if(field)
       {
         Gnome::Gda::Value db_value; //This default also wipes the placeholder field name text of empty rows.
@@ -1007,7 +1007,7 @@ void Canvas_PrintLayout::set_canvas_item_field_value(const Glib::RefPtr<Goocanva
 
     Glib::ustring text;
 
-    std::shared_ptr<const LayoutItem_WithFormatting> with_formatting = 
+    auto with_formatting = 
       std::dynamic_pointer_cast<const LayoutItem_WithFormatting>(field);
     if(with_formatting)
     {
@@ -1066,7 +1066,7 @@ Base_DB::type_vecConstLayoutFields Canvas_PrintLayout::get_portal_fields_to_show
     Document::type_list_layout_groups mapGroups;
     mapGroups.push_back(portal);
 
-    std::shared_ptr<const Relationship> relationship = portal->get_relationship();
+    auto relationship = portal->get_relationship();
     if(relationship)
     {
       type_vecConstLayoutFields result = 
get_table_fields_to_show_for_sequence(portal->get_table_used(Glib::ustring() /* not relevant */), mapGroups);
diff --git a/glom/print_layout/print_layout_utils.cc b/glom/print_layout/print_layout_utils.cc
index 522cabb..69cc6f0 100644
--- a/glom/print_layout/print_layout_utils.cc
+++ b/glom/print_layout/print_layout_utils.cc
@@ -187,7 +187,7 @@ static void create_standard(const std::shared_ptr<const LayoutGroup>& layout_gro
   const auto title = item_get_title(layout_group);
   if(!title.empty())
   {
-    std::shared_ptr<LayoutItem_Text> text = std::make_shared<LayoutItem_Text>();
+    auto text = std::make_shared<LayoutItem_Text>();
     text->set_text(title, AppWindow::get_current_locale());
     text->m_formatting.set_text_format_font("Sans Bold 10");
 
@@ -201,10 +201,10 @@ static void create_standard(const std::shared_ptr<const LayoutGroup>& layout_gro
   }
 
   //Deal with a portal group: 
-  const std::shared_ptr<const LayoutItem_Portal> portal = std::dynamic_pointer_cast<const 
LayoutItem_Portal>(layout_group); 
+  const auto portal = std::dynamic_pointer_cast<const LayoutItem_Portal>(layout_group); 
   if(portal)
   {
-    std::shared_ptr<LayoutItem_Portal> portal_clone = glom_sharedptr_clone(portal);
+    auto portal_clone = glom_sharedptr_clone(portal);
     portal_clone->set_print_layout_row_height(field_height); //Otherwise it will be 0, which is useless.
 
     //We ignore the rows count for the details layout's portal,
@@ -232,7 +232,7 @@ static void create_standard(const std::shared_ptr<const LayoutGroup>& layout_gro
     if(!item)
       continue;
 
-    const std::shared_ptr<const LayoutGroup> group = std::dynamic_pointer_cast<const LayoutGroup>(item);
+    const auto group = std::dynamic_pointer_cast<const LayoutGroup>(item);
     if(group && !portal)
     {
       //Recurse:
@@ -243,7 +243,7 @@ static void create_standard(const std::shared_ptr<const LayoutGroup>& layout_gro
       //Add field titles, if necessary:
       std::shared_ptr<LayoutItem_Text> text_title;
       const double title_width = ITEM_WIDTH_WIDE; //TODO: Calculate it based on the widest in the column. Or 
just halve the column to start.
-      const std::shared_ptr<const LayoutItem_Field> field = std::dynamic_pointer_cast<const 
LayoutItem_Field>(item);
+      const auto field = std::dynamic_pointer_cast<const LayoutItem_Field>(item);
       if(field)
       {
         text_title = std::make_shared<LayoutItem_Text>();
@@ -260,7 +260,7 @@ static void create_standard(const std::shared_ptr<const LayoutGroup>& layout_gro
       }
 
       //Add the item, such as a field:
-      std::shared_ptr<LayoutItem> clone = glom_sharedptr_clone(item);
+      auto clone = glom_sharedptr_clone(item);
 
       double item_x = x;
       if(field)
@@ -313,7 +313,7 @@ guint get_page_for_y(const Glib::RefPtr<const Gtk::PageSetup>& page_setup, Gtk::
 std::shared_ptr<PrintLayout> create_standard(const Glib::RefPtr<const Gtk::PageSetup>& page_setup, const 
Glib::ustring& table_name, const Document* document, bool avoid_page_margins)
 {
   const Gtk::Unit units = Gtk::UNIT_MM;
-  std::shared_ptr<PrintLayout> print_layout = std::make_shared<PrintLayout>();  
+  auto print_layout = std::make_shared<PrintLayout>();  
   
   //Start inside the border, on the next grid line:
   double y = 0;
@@ -331,7 +331,7 @@ std::shared_ptr<PrintLayout> create_standard(const Glib::RefPtr<const Gtk::PageS
   const auto title = document->get_table_title_singular(table_name, AppWindow::get_current_locale());
   if(!title.empty())
   {
-    std::shared_ptr<LayoutItem_Text> text = std::make_shared<LayoutItem_Text>();
+    auto text = std::make_shared<LayoutItem_Text>();
     text->set_text(title, AppWindow::get_current_locale());
     text->m_formatting.set_text_format_font("Sans Bold 12");
 
@@ -390,7 +390,7 @@ void do_print_layout(const std::shared_ptr<const PrintLayout>& print_layout, con
   canvas.set_document(const_cast<Document*>(document)); //We const_cast because, for this use, it will not 
be changed.
 
   //We cast to unconst because we know that the layout will not be changed by this use: 
-  std::shared_ptr<PrintLayout> unconst = std::const_pointer_cast<PrintLayout>(print_layout);
+  auto unconst = std::const_pointer_cast<PrintLayout>(print_layout);
   canvas.set_print_layout(found_set.m_table_name, unconst);
 
   //Do not show things that are only for editing the print layout:
diff --git a/glom/utility_widgets/imageglom.cc b/glom/utility_widgets/imageglom.cc
index bf1a3d2..791004e 100644
--- a/glom/utility_widgets/imageglom.cc
+++ b/glom/utility_widgets/imageglom.cc
@@ -784,7 +784,7 @@ void ImageGlom::on_menupopup_activate_select_file()
         if(dialog_progress->run() == Gtk::RESPONSE_ACCEPT)
         {
           GdaBinary* bin = g_new(GdaBinary, 1);
-          std::shared_ptr<GdaBinary> image_data = dialog_progress->get_image_data();
+          auto image_data = dialog_progress->get_image_data();
           bin->data = image_data->data;
           bin->binary_length = image_data->binary_length;
 
diff --git a/glom/utility_widgets/layoutwidgetmenu.cc b/glom/utility_widgets/layoutwidgetmenu.cc
index 275cc7e..3554f64 100644
--- a/glom/utility_widgets/layoutwidgetmenu.cc
+++ b/glom/utility_widgets/layoutwidgetmenu.cc
@@ -174,7 +174,7 @@ void LayoutWidgetMenu::on_menupopup_activate_delete()
 
   if(base)
   {
-    std::shared_ptr<LayoutGroup> group = 
+    auto group = 
       std::dynamic_pointer_cast<LayoutGroup>(base->get_layout_item());
     if(!group)
       return; 
diff --git a/glom/utility_widgets/layoutwidgetutils.cc b/glom/utility_widgets/layoutwidgetutils.cc
index ed6172f..b4e2087 100644
--- a/glom/utility_widgets/layoutwidgetutils.cc
+++ b/glom/utility_widgets/layoutwidgetutils.cc
@@ -81,7 +81,7 @@ void LayoutWidgetUtils::on_menu_delete_activate()
 
   if(base)
   {
-    std::shared_ptr<LayoutGroup> group = 
+    auto group = 
       std::dynamic_pointer_cast<LayoutGroup>(base->get_layout_item());
     if(!group)
       return;
diff --git a/glom/utility_widgets/notebooklabelglom.cc b/glom/utility_widgets/notebooklabelglom.cc
index 0398320..5b86e0e 100644
--- a/glom/utility_widgets/notebooklabelglom.cc
+++ b/glom/utility_widgets/notebooklabelglom.cc
@@ -72,7 +72,7 @@ void NotebookLabel::on_menu_new_group_activate()
   group->set_title_original(_("New Group"));
   group->set_name(_("Group"));
   
-  std::shared_ptr<LayoutGroup> notebook_group = 
std::dynamic_pointer_cast<LayoutGroup>(m_notebook->get_layout_item());
+  auto notebook_group = std::dynamic_pointer_cast<LayoutGroup>(m_notebook->get_layout_item());
   notebook_group->add_item(group);
   
   m_notebook->signal_layout_changed().emit();
diff --git a/tests/python/test_python_execute_func_with_record.cc 
b/tests/python/test_python_execute_func_with_record.cc
index b361256..f72d6c1 100644
--- a/tests/python/test_python_execute_func_with_record.cc
+++ b/tests/python/test_python_execute_func_with_record.cc
@@ -79,7 +79,7 @@ int main()
   }
   g_assert(started == Glom::ConnectionPool::Backend::StartupErrors::NONE);
 
-  std::shared_ptr<Glom::SharedConnection> connection = connection_pool->connect();
+  auto connection = connection_pool->connect();
   g_assert(connection);
 
   Glib::RefPtr<Gnome::Gda::Connection> gda_connection = connection->get_gda_connection();
diff --git a/tests/python/test_python_execute_func_with_record_field_types.cc 
b/tests/python/test_python_execute_func_with_record_field_types.cc
index b22a6e5..1601b10 100644
--- a/tests/python/test_python_execute_func_with_record_field_types.cc
+++ b/tests/python/test_python_execute_func_with_record_field_types.cc
@@ -105,7 +105,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   }
 
   auto connection_pool = Glom::ConnectionPool::get_instance();
-  std::shared_ptr<Glom::SharedConnection> connection = connection_pool->connect();
+  auto connection = connection_pool->connect();
   g_assert(connection);
 
   const auto gda_connection = connection->get_gda_connection();
@@ -114,7 +114,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
 
   //Some python code just to exercise our PyGlomRecord API:
   const Glib::ustring table_name = "products";
-  const std::shared_ptr<const Glom::Field> primary_key_field =
+  const auto primary_key_field =
     document.get_field_primary_key(table_name);
   if(!primary_key_field)
   {
diff --git a/tests/test_document_load.cc b/tests/test_document_load.cc
index cb8a4b1..918aabd 100644
--- a/tests/test_document_load.cc
+++ b/tests/test_document_load.cc
@@ -75,7 +75,7 @@ static bool get_group_named(const Glom::Document::type_list_groups& container, c
 
 static bool needs_navigation(Glom::Document& document, const Glib::ustring& table_name, const Glib::ustring& 
field_name)
 {
-  std::shared_ptr<Glom::LayoutItem_Field> layout_item = std::make_shared<Glom::LayoutItem_Field>();
+  auto layout_item = std::make_shared<Glom::LayoutItem_Field>();
   layout_item->set_name(field_name);
   layout_item->set_full_field_details(
     document.get_field(table_name, field_name));
@@ -98,12 +98,12 @@ static std::shared_ptr<const Glom::LayoutItem_Portal> get_portal_from_details_la
   {
     for(const auto& layout_item : group->get_items_recursive_with_groups())
     { 
-      const std::shared_ptr<const Glom::LayoutGroup> child_group =
+      const auto child_group =
         std::dynamic_pointer_cast<const Glom::LayoutGroup>(layout_item);
       if(!child_group)
         continue;
 
-      const std::shared_ptr<const Glom::LayoutItem_Portal> portal =
+      const auto portal =
         std::dynamic_pointer_cast<const Glom::LayoutItem_Portal>(layout_item);
       if(!portal)
         continue;
@@ -167,7 +167,7 @@ int main()
   g_assert(contains(table_names, "scenes"));
   g_assert(!contains(table_names, "Scenes")); //The title, not the name.
 
-  std::shared_ptr<Glom::TableInfo> table = document.get_table("scenes");
+  auto table = document.get_table("scenes");
   g_assert(table);
   g_assert( table->get_title_original() == "Scenes" );
   g_assert( table->get_title_singular_original() == "Scene" );
@@ -186,7 +186,7 @@ int main()
   g_assert(contains_named(relationships, "scene_cast"));
 
   //Check some fields:
-  std::shared_ptr<const Glom::Field> field = document.get_field("contacts", "contact_id");
+  auto field = document.get_field("contacts", "contact_id");
   g_assert(field);
   g_assert( field->get_title_original() == "Contact ID" );
   g_assert(field->get_glom_type() == Glom::Field::glom_field_type::NUMERIC);
@@ -199,7 +199,7 @@ int main()
   g_assert(!field->get_unique_key());
 
   //Check a relationship:
-  const std::shared_ptr<const Glom::Relationship> relationship = document.get_relationship("characters", 
"contacts_actor");
+  const auto relationship = document.get_relationship("characters", "contacts_actor");
   g_assert(relationship);
   g_assert(relationship->get_from_field() == "contact_id");
   g_assert(relationship->get_to_table() == "contacts");
@@ -222,7 +222,7 @@ int main()
   g_assert(items_with_groups.size() == 15);
 
   //Check that expected fields can be found on a layout.
-  std::shared_ptr<const Glom::LayoutItem_Field> field_on_layout = 
+  auto field_on_layout = 
     get_field_on_layout(document, "scenes", "locations", "address_town");
   g_assert(field_on_layout);
   g_assert(field_on_layout->get_table_used("scenes") == "locations");
@@ -281,7 +281,7 @@ int main()
     return false;
   }
   
-  const std::shared_ptr<const Glom::PrintLayout> print_layout = document.get_print_layout("contacts", 
"contact_details");
+  const auto print_layout = document.get_print_layout("contacts", "contact_details");
   if(!print_layout)
   {
     std::cerr << G_STRFUNC << ": Failure: Could not get an expected print layout." << std::endl;
@@ -315,7 +315,7 @@ int main()
     return false;
   }
 
-  const std::shared_ptr<const Glom::Report> report = document.get_report("contacts", "by_country_by_town");
+  const auto report = document.get_report("contacts", "by_country_by_town");
   if(!report)
   {
     std::cerr << G_STRFUNC << ": Failure: Could not get an expected report." << std::endl;
@@ -370,7 +370,7 @@ int main()
   //Note that related records portals don't have names.
   //This example portal shows the scenes_cast table, but should navigate though that to the cast table.
   const Glib::ustring portal_relationship_name = "scene_cast";
-  std::shared_ptr<const Glom::LayoutItem_Portal> portal =
+  auto portal =
     get_portal_from_details_layout(document, "scenes", portal_relationship_name);
   if(!portal)
   {
diff --git a/tests/test_document_load_and_change.cc b/tests/test_document_load_and_change.cc
index bc6f69b..5a5437f 100644
--- a/tests/test_document_load_and_change.cc
+++ b/tests/test_document_load_and_change.cc
@@ -115,7 +115,7 @@ int main()
   }
 
   //Check that the original field name is no longer used in the relationship:
-  std::shared_ptr<const Glom::Relationship> relationship = document.get_relationship("invoice_lines", 
"products");
+  auto relationship = document.get_relationship("invoice_lines", "products");
   if(!relationship)
   {
     std::cerr << G_STRFUNC << ": Failure: The relationship could not be found in the document." << std::endl;
@@ -155,7 +155,7 @@ int main()
     }
 
     //Check that the old relationship name is not used.
-    std::shared_ptr<const Glom::LayoutItem_Field> field_on_layout = 
+    auto field_on_layout = 
       get_field_on_layout(document, table_name, "contacts", "name_full");
     g_assert(field_on_layout);
     if(field_on_layout->get_relationship_name() != relationship_name_new)
@@ -213,7 +213,7 @@ int main()
 
  
   //Remove a print layout:
-  std::shared_ptr<const Glom::PrintLayout> print_layout = 
+  auto print_layout = 
     document.get_print_layout("contacts", "contact_details");
   if(!print_layout)
   {
diff --git a/tests/test_document_load_image.cc b/tests/test_document_load_image.cc
index b78d274..8b7c99c 100644
--- a/tests/test_document_load_image.cc
+++ b/tests/test_document_load_image.cc
@@ -83,7 +83,7 @@ int main()
   g_assert(items.size() == 3);
   std::shared_ptr<const Glom::LayoutItem> item = items[2];
   g_assert(item);
-  std::shared_ptr<const Glom::LayoutItem_Image> image_item =
+  auto image_item =
     std::dynamic_pointer_cast<const Glom::LayoutItem_Image>(item);
   g_assert(image_item);
 
diff --git a/tests/test_document_load_translations.cc b/tests/test_document_load_translations.cc
index eac3a3d..b633d3b 100644
--- a/tests/test_document_load_translations.cc
+++ b/tests/test_document_load_translations.cc
@@ -62,8 +62,8 @@ bool contains_item_type(const Glom::Document::type_list_translatables& container
   return Glom::Utils::find_if_exists(container,
     [] (const Glom::Document::type_list_translatables::value_type& element)
     {
-      std::shared_ptr<Glom::TranslatableItem> item = element.first;
-      std::shared_ptr<T_TypeToFind> derived = std::dynamic_pointer_cast<T_TypeToFind>(item);
+      auto item element.first;
+      auto derived std::dynamic_pointer_cast<T_TypeToFind>(item);
       if(derived)
         return true;
       else
@@ -81,7 +81,7 @@ static std::shared_ptr<const Glom::LayoutItem_Field> get_field_on_layout(const G
     
     for(const auto& layout_item : group->get_items_recursive())
     {
-      const std::shared_ptr<const Glom::LayoutItem_Field> layout_item_field =
+      const auto layout_item_field =
         std::dynamic_pointer_cast<const Glom::LayoutItem_Field>(layout_item);
       if(!layout_item_field)
         continue;
@@ -107,7 +107,7 @@ void check_title(const T_Item& item, const char* title_en, const char* title_de)
   //The get_title_original() and get_title_translation() should not be called 
   //on items that delegate to a child item:
   bool has_own_title = true;
-  std::shared_ptr<const Glom::LayoutItem_Field> field = 
+  auto field = 
     std::dynamic_pointer_cast<const Glom::LayoutItem_Field>(item);
   if(field)
      has_own_title = false;
@@ -197,7 +197,7 @@ int main()
   g_assert( document.get_table_title_singular("scenes", locale_de) == "Szene" );
 
   //Check a field:
-  std::shared_ptr<const Glom::Field> field = document.get_field("contacts", "contact_id");
+  auto field = document.get_field("contacts", "contact_id");
   g_assert(field);
   check_title(field, "Contact ID", "Kontaktkennung");
 
@@ -210,7 +210,7 @@ int main()
   g_assert(formatting.get_has_custom_choices());
   Glom::Formatting::type_list_values values = formatting.get_choices_custom();
   //g_assert(contains(values, "Day"));
-  std::shared_ptr<Glom::ChoiceValue> value = get_titled(values, "Day");
+  auto value = get_titled(values, "Day");
   g_assert(value);
   check_title(value, "Day", "Tag");
   g_assert(value->get_value() == Gnome::Gda::Value("Day"));
@@ -223,12 +223,12 @@ int main()
   g_assert( value->get_title_original() == "Day" );
 
   //Check a relationship:
-  const std::shared_ptr<const Glom::Relationship> relationship = document.get_relationship("characters", 
"contacts_actor");
+  const auto relationship = document.get_relationship("characters", "contacts_actor");
   g_assert(relationship);
   check_title(relationship, "Actor", "Schauspieler");
 
   //Check a LayoutItemField's CustomTitle:
-  std::shared_ptr<const Glom::LayoutItem_Field> field_on_layout = 
+  auto field_on_layout = 
     get_field_on_layout(document, "characters", "contacts", "name_full");
   g_assert(field_on_layout);
   g_assert(field_on_layout->get_has_relationship_name());
@@ -248,7 +248,7 @@ int main()
   g_assert(field_on_layout->get_formatting_used_has_translatable_choices());
 
   //Check a print layout:
-  const std::shared_ptr<const Glom::PrintLayout> print_layout = document.get_print_layout("contacts", 
"contact_details");
+  const auto print_layout = document.get_print_layout("contacts", "contact_details");
   g_assert(print_layout);
   check_title(print_layout, "Contact Details", "Kontakt Details" );
 
diff --git a/tests/test_fake_connection.cc b/tests/test_fake_connection.cc
index f2f74bc..2c2c83f 100644
--- a/tests/test_fake_connection.cc
+++ b/tests/test_fake_connection.cc
@@ -66,13 +66,13 @@ int main()
 
   //Build a SQL query and get the string for it:
   const Gnome::Gda::Value value("Born To Run");
-  std::shared_ptr<const Glom::Field> where_field = document.get_field("albums", "name");
+  auto where_field = document.get_field("albums", "name");
   const Gnome::Gda::SqlExpr where_clause = 
     Glom::Utils::build_simple_where_expression("albums", where_field, value);
   
   Glom::Utils::type_vecLayoutFields fieldsToGet;
-  std::shared_ptr<const Glom::Field> field = document.get_field("albums", "album_id");
-  std::shared_ptr<Glom::LayoutItem_Field> layoutitem = std::make_shared<Glom::LayoutItem_Field>();
+  auto field = document.get_field("albums", "album_id");
+  auto layoutitem = std::make_shared<Glom::LayoutItem_Field>();
   layoutitem->set_full_field_details(field);
   fieldsToGet.push_back(layoutitem);
   field = document.get_field("albums", "name");
diff --git a/tests/test_field_file_format.cc b/tests/test_field_file_format.cc
index f19e25a..1893e3f 100644
--- a/tests/test_field_file_format.cc
+++ b/tests/test_field_file_format.cc
@@ -39,7 +39,7 @@ static bool test_value(Glom::Field::glom_field_type field_type, const Gnome::Gda
 
   if(value != value_retrieved)
   {
-    std::shared_ptr<Glom::Field> field = std::make_shared<Glom::Field>();
+    auto field = std::make_shared<Glom::Field>();
     std::cerr << "  value_retrieved type=" << g_type_name(value_retrieved.get_value_type()) << ", value 
type=" << g_type_name(value.get_value_type()) << std::endl;
     return false;
   }
diff --git a/tests/test_selfhosting_new_from_example_defaultvalues.cc 
b/tests/test_selfhosting_new_from_example_defaultvalues.cc
index e0b3548..605df43 100644
--- a/tests/test_selfhosting_new_from_example_defaultvalues.cc
+++ b/tests/test_selfhosting_new_from_example_defaultvalues.cc
@@ -46,7 +46,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
     return false;
   }
 
-  std::shared_ptr<const Glom::Field> field = document.get_field(table_name, "count");
+  auto field = document.get_field(table_name, "count");
   if(!field)
   {
     std::cerr << G_STRFUNC << ": Failure: Could not get field." << std::endl;
diff --git a/tests/test_selfhosting_new_from_example_float.cc 
b/tests/test_selfhosting_new_from_example_float.cc
index 5baaab3..febc5aa 100644
--- a/tests/test_selfhosting_new_from_example_float.cc
+++ b/tests/test_selfhosting_new_from_example_float.cc
@@ -42,7 +42,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   }
   
   const Glib::ustring table_name = "products";
-  std::shared_ptr<const Glom::Field> primary_key_field = document.get_field_primary_key(table_name);
+  auto primary_key_field = document.get_field_primary_key(table_name);
   if(!primary_key_field)
   {
     std::cerr << G_STRFUNC << ": Failure: primary_key_field is empty." << std::endl;
@@ -55,8 +55,8 @@ static bool test(Glom::Document::HostingMode hosting_mode)
     Glom::Utils::build_simple_where_expression(table_name, primary_key_field, pk_value);
   
   Glom::Utils::type_vecLayoutFields fieldsToGet;
-  std::shared_ptr<const Glom::Field> field = document.get_field(table_name, "price");
-  std::shared_ptr<Glom::LayoutItem_Field> layoutitem = std::make_shared<Glom::LayoutItem_Field>();
+  auto field = document.get_field(table_name, "price");
+  auto layoutitem = std::make_shared<Glom::LayoutItem_Field>();
   layoutitem->set_full_field_details(field);
   fieldsToGet.push_back(layoutitem);
 
diff --git a/tests/test_selfhosting_new_then_change_columns.cc 
b/tests/test_selfhosting_new_then_change_columns.cc
index 58230d3..584b3dd 100644
--- a/tests/test_selfhosting_new_then_change_columns.cc
+++ b/tests/test_selfhosting_new_then_change_columns.cc
@@ -45,14 +45,14 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   
   const Glib::ustring table_name = "contacts";
   const Glib::ustring field_name_original = "date_of_birth";
-  std::shared_ptr<const Glom::Field> field_original = document.get_field(table_name, field_name_original);
+  auto field_original = document.get_field(table_name, field_name_original);
   if(!field_original)
   {
     std::cerr << G_STRFUNC << ": Failure: Could not get field." << std::endl;
     return false;
   }
 
-  std::shared_ptr<Glom::Field> field_new = Glom::glom_sharedptr_clone(field_original);
+  auto field_new = Glom::glom_sharedptr_clone(field_original);
   if(!field_new)
   {
     std::cerr << G_STRFUNC << ": Failure: field_new is null." << std::endl;
@@ -156,7 +156,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   try
   {
     //TODO: Avoid the need for this awkward use of set_g_type():
-    std::shared_ptr<Glom::Field> field_numeric = std::make_shared<Glom::Field>();
+    auto field_numeric = std::make_shared<Glom::Field>();
     field_numeric->set_name("newfield");
     field_numeric->set_glom_type(Glom::Field::glom_field_type::NUMERIC);
     Glib::RefPtr<Gnome::Gda::Column> field_info = field_numeric->get_field_info();
diff --git a/tests/test_selfhosting_new_then_choices.cc b/tests/test_selfhosting_new_then_choices.cc
index f65b68a..d40f369 100644
--- a/tests/test_selfhosting_new_then_choices.cc
+++ b/tests/test_selfhosting_new_then_choices.cc
@@ -45,7 +45,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   
   const Glib::ustring table_name = "invoice_lines";
  
-  const std::shared_ptr<const Glom::LayoutItem_Field> field_with_choice = 
+  const auto field_with_choice = 
     get_field_on_layout(document, table_name, table_name, "product_id");
   if(!field_with_choice)
   {
diff --git a/tests/test_selfhosting_new_then_image.cc b/tests/test_selfhosting_new_then_image.cc
index 4ff886f..6298494 100644
--- a/tests/test_selfhosting_new_then_image.cc
+++ b/tests/test_selfhosting_new_then_image.cc
@@ -47,10 +47,10 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   //Where clause:
 
   const Glib::ustring table_name = "contacts";
-  const std::shared_ptr<const Glom::Field> field = document.get_field(table_name, "picture");
+  const auto field = document.get_field(table_name, "picture");
 
   //Where clause:
-  const std::shared_ptr<const Glom::Field> key_field = document.get_field(table_name, "contact_id");
+  const auto key_field = document.get_field(table_name, "contact_id");
   if(!key_field)
   {
     std::cerr << G_STRFUNC << ": Failure: Could not get key field." << std::endl;
@@ -76,7 +76,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
 
   //Get the value:
   Glom::Utils::type_vecLayoutFields fieldsToGet;
-  std::shared_ptr<Glom::LayoutItem_Field> layoutitem = std::make_shared<Glom::LayoutItem_Field>();
+  auto layoutitem = std::make_shared<Glom::LayoutItem_Field>();
   layoutitem->set_full_field_details(field);
   fieldsToGet.push_back(layoutitem);
 
diff --git a/tests/test_selfhosting_new_then_lookup.cc b/tests/test_selfhosting_new_then_lookup.cc
index 9e15bd0..5a7b9d4 100644
--- a/tests/test_selfhosting_new_then_lookup.cc
+++ b/tests/test_selfhosting_new_then_lookup.cc
@@ -37,11 +37,11 @@ static std::shared_ptr<const Glom::LayoutItem_Field> get_lookup_field(const Glom
 
   for(const auto& the_pair : container)
   {
-    const std::shared_ptr<const Glom::LayoutItem_Field> layout_item = the_pair.first;
+    const auto layout_item = the_pair.first;
     if(!layout_item)
       return result;
 
-    const std::shared_ptr<const Glom::Relationship> this_relationship = the_pair.second;
+    const auto this_relationship = the_pair.second;
     if(!this_relationship)
       return result;
 
@@ -76,7 +76,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
   }
   
   const Glib::ustring table_name = "invoice_lines";
-  std::shared_ptr<const Glom::Field> primary_key_field = document.get_field_primary_key(table_name);
+  auto primary_key_field = document.get_field_primary_key(table_name);
   if(!primary_key_field)
   {
     std::cerr << G_STRFUNC << ": Failure: primary_key_field is empty." << std::endl;
@@ -112,7 +112,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
 
   const Glib::ustring field_name = "product_price";
   std::shared_ptr<const Glom::Relationship> relationship;
-  const std::shared_ptr<const Glom::LayoutItem_Field> layout_field = 
+  const auto layout_field = 
     get_lookup_field(lookups, table_name, field_name, relationship);
   if(!layout_field)
   {
@@ -144,7 +144,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
     return false;
   }
 
-  const std::shared_ptr<const Glom::Field> field = layout_field->get_full_field_details();
+  const auto field = layout_field->get_full_field_details();
   if(!field)
   {
     std::cerr << G_STRFUNC << ": Failure: The lookup item's field is empty." << std::endl;
diff --git a/tests/test_selfhosting_new_then_report.cc b/tests/test_selfhosting_new_then_report.cc
index 0b06000..9d02aef 100644
--- a/tests/test_selfhosting_new_then_report.cc
+++ b/tests/test_selfhosting_new_then_report.cc
@@ -37,7 +37,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
     return false;
   }
 
-  const std::shared_ptr<const Glom::Report> report_temp = 
+  const auto report_temp = 
     Glom::ReportBuilder::create_standard_list_report(&document, "albums");
 
   Glom::FoundSet found_set; //TODO: Test a where clause.
diff --git a/tests/test_selfhosting_new_then_report_summary.cc 
b/tests/test_selfhosting_new_then_report_summary.cc
index 2c8a68b..69d94b1 100644
--- a/tests/test_selfhosting_new_then_report_summary.cc
+++ b/tests/test_selfhosting_new_then_report_summary.cc
@@ -37,7 +37,7 @@ static bool test(Glom::Document::HostingMode hosting_mode)
     return false;
   }
 
-  const std::shared_ptr<const Glom::Report> report = 
+  const auto report = 
     document.get_report("invoices", "by_customer");
   if(!report)
   {
diff --git a/tests/test_selfhosting_sqlinjection.cc b/tests/test_selfhosting_sqlinjection.cc
index 6ec3610..4b5bc18 100644
--- a/tests/test_selfhosting_sqlinjection.cc
+++ b/tests/test_selfhosting_sqlinjection.cc
@@ -33,13 +33,13 @@ static bool check_get_extra_rows(const Glib::ustring& quote_char)
 {
   //Try to get more rows than intended:
   const Gnome::Gda::Value value("Born To Run" + quote_char + " OR " + quote_char + "x" + quote_char + "=" + 
quote_char + "x");
-  std::shared_ptr<const Glom::Field> where_field = document.get_field("albums", "name");
+  auto where_field = document.get_field("albums", "name");
   const Gnome::Gda::SqlExpr where_clause = 
     Glom::Utils::build_simple_where_expression("albums", where_field, value);
   
   Glom::Utils::type_vecLayoutFields fieldsToGet;
-  std::shared_ptr<const Glom::Field> field = document.get_field("albums", "album_id");
-  std::shared_ptr<Glom::LayoutItem_Field> layoutitem = std::make_shared<Glom::LayoutItem_Field>();
+  auto field = document.get_field("albums", "album_id");
+  auto layoutitem = std::make_shared<Glom::LayoutItem_Field>();
   layoutitem->set_full_field_details(field);
   fieldsToGet.push_back(layoutitem);
   field = document.get_field("albums", "name");
@@ -65,14 +65,14 @@ static bool check_drop_table(const Glib::ustring& quote_char)
 {
   //Try to drop the table in a second SQL statement:
   const Gnome::Gda::Value value("True Blue" + quote_char + "; DROP TABLE songs; --");
-  std::shared_ptr<const Glom::Field> where_field = 
+  auto where_field = 
     document.get_field("albums", "name");
   const Gnome::Gda::SqlExpr where_clause = 
     Glom::Utils::build_simple_where_expression("albums", where_field, value);
   
   Glom::Utils::type_vecLayoutFields fieldsToGet;
-  std::shared_ptr<const Glom::Field> field = document.get_field("albums", "album_id");
-  std::shared_ptr<Glom::LayoutItem_Field> layoutitem = std::make_shared<Glom::LayoutItem_Field>();
+  auto field = document.get_field("albums", "album_id");
+  auto layoutitem = std::make_shared<Glom::LayoutItem_Field>();
   layoutitem->set_full_field_details(field);
   fieldsToGet.push_back(layoutitem);
   field = document.get_field("albums", "name");
@@ -105,14 +105,14 @@ static bool check_avoid_quotes_and_drop_table_with_false_value_type()
   //Try to drop the table in a second SQL statement,
   //by using a text value for a field whose type should not need quoting:
   const Gnome::Gda::Value value("1;DROP TABLE songs");
-  std::shared_ptr<const Glom::Field> where_field = 
+  auto where_field = 
     document.get_field("albums", "album_id");
   const Gnome::Gda::SqlExpr where_clause = 
     Glom::Utils::build_simple_where_expression("albums", where_field, value);
   
   Glom::Utils::type_vecLayoutFields fieldsToGet;
-  std::shared_ptr<const Glom::Field> field = document.get_field("albums", "album_id");
-  std::shared_ptr<Glom::LayoutItem_Field> layoutitem = std::make_shared<Glom::LayoutItem_Field>();
+  auto field = document.get_field("albums", "album_id");
+  auto layoutitem = std::make_shared<Glom::LayoutItem_Field>();
   layoutitem->set_full_field_details(field);
   fieldsToGet.push_back(layoutitem);
   field = document.get_field("albums", "name");
@@ -162,7 +162,7 @@ static bool check_avoid_quotes_and_drop_table_with_false_field_type()
   const Gnome::Gda::Value value("\"Born To Run\";DROP TABLE songs");
 
   //Specify a field with incorrect type information:
-  std::shared_ptr<Glom::Field> where_field = 
+  auto where_field = 
     document.get_field("albums", "name");
   where_field->set_glom_type(Glom::Field::glom_field_type::NUMERIC);
   //const GType gda_type = Glom::Field::get_gda_type_for_glom_type(Glom::TYPE_NUMERIC); 
@@ -171,8 +171,8 @@ static bool check_avoid_quotes_and_drop_table_with_false_field_type()
     Glom::Utils::build_simple_where_expression("albums", where_field, value);
  
   Glom::Utils::type_vecLayoutFields fieldsToGet;
-  std::shared_ptr<const Glom::Field> field = document.get_field("albums", "album_id");
-  std::shared_ptr<Glom::LayoutItem_Field> layoutitem = std::make_shared<Glom::LayoutItem_Field>();
+  auto field = document.get_field("albums", "album_id");
+  auto layoutitem = std::make_shared<Glom::LayoutItem_Field>();
   layoutitem->set_full_field_details(field);
   fieldsToGet.push_back(layoutitem);
   field = document.get_field("albums", "name");
diff --git a/tests/test_selfhosting_utils.cc b/tests/test_selfhosting_utils.cc
index b305f49..22a492a 100644
--- a/tests/test_selfhosting_utils.cc
+++ b/tests/test_selfhosting_utils.cc
@@ -419,14 +419,14 @@ bool test_table_exists(const Glib::ustring& table_name, const Glom::Document& do
 {
   //Try to get more rows than intended:
   Glom::Utils::type_vecLayoutFields fieldsToGet;
-  std::shared_ptr<const Glom::Field> field = document.get_field_primary_key(table_name); //To to get some 
field.
+  auto field = document.get_field_primary_key(table_name); //To to get some field.
   if(!field)
   {
     std::cerr << G_STRFUNC << "Failure: Could not get primary key for table=" << table_name << std::endl;
     return false;
   }
 
-  std::shared_ptr<Glom::LayoutItem_Field> layoutitem = std::make_shared<Glom::LayoutItem_Field>();
+  auto layoutitem = std::make_shared<Glom::LayoutItem_Field>();
   layoutitem->set_full_field_details(field);
   fieldsToGet.push_back(layoutitem);
 
@@ -455,11 +455,11 @@ static bool test_example_musiccollection_data_related(const Glom::Document* docu
   Glom::Utils::type_vecLayoutFields fieldsToGet;
 
   //Normal fields:
-  std::shared_ptr<const Glom::Field> field_album_id = document->get_field("albums", "album_id");
-  std::shared_ptr<Glom::LayoutItem_Field> layoutitem = std::make_shared<Glom::LayoutItem_Field>();
+  auto field_album_id = document->get_field("albums", "album_id");
+  auto layoutitem = std::make_shared<Glom::LayoutItem_Field>();
   layoutitem->set_full_field_details(field_album_id);
   fieldsToGet.push_back(layoutitem);
-  std::shared_ptr<const Glom::Field> field = document->get_field("albums", "name");
+  auto field = document->get_field("albums", "name");
   if(!field)
   {
     std::cerr << G_STRFUNC << "Failure: Could not get field." << std::endl;
@@ -515,8 +515,8 @@ bool test_example_musiccollection_data(const Glom::Document* document)
     Glom::Utils::get_find_where_clause_quick(document, "albums", value);
   
   Glom::Utils::type_vecLayoutFields fieldsToGet;
-  std::shared_ptr<const Glom::Field> field = document->get_field("albums", "album_id");
-  std::shared_ptr<Glom::LayoutItem_Field> layoutitem = std::make_shared<Glom::LayoutItem_Field>();
+  auto field = document->get_field("albums", "album_id");
+  auto layoutitem = std::make_shared<Glom::LayoutItem_Field>();
   layoutitem->set_full_field_details(field);
   fieldsToGet.push_back(layoutitem);
 
diff --git a/tests/test_utils.cc b/tests/test_utils.cc
index 4f04ddc..48f99a3 100644
--- a/tests/test_utils.cc
+++ b/tests/test_utils.cc
@@ -32,7 +32,7 @@ std::shared_ptr<const Glom::LayoutItem_Field> get_field_on_layout(const Glom::Do
     
     for(const auto& layout_item : group->get_items_recursive())
     {
-      const std::shared_ptr<const Glom::LayoutItem_Field> layout_item_field =
+      const auto layout_item_field =
         std::dynamic_pointer_cast<const Glom::LayoutItem_Field>(layout_item);
       if(!layout_item_field)
         continue;
diff --git a/tests/translations_po/test_document_import_po.cc 
b/tests/translations_po/test_document_import_po.cc
index ae19f3b..925ce8c 100644
--- a/tests/translations_po/test_document_import_po.cc
+++ b/tests/translations_po/test_document_import_po.cc
@@ -100,7 +100,7 @@ int main()
 
 
   //Check that some expected translated titles are now in the document:
-  std::shared_ptr<const Glom::TableInfo> table = document.get_table("scenes");
+  auto table = document.get_table("scenes");
   g_assert(table);
   g_assert( table->get_title_original() == "Scenes" ); //The original title should be unchanged:
 
@@ -111,7 +111,7 @@ int main()
     return EXIT_FAILURE;
   }
 
-  const std::shared_ptr<const Glom::Report> report = document.get_report("crew", "crew_list");
+  const auto report = document.get_report("crew", "crew_list");
   g_assert(report);
   g_assert(report->get_title_original() == "Crew List"); //The original title should be unchanged:
 



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