[glom] if(): Prefer return/continue shortcut instead of nesting.



commit 4682ec49981371ce479470ec8155c20dfdaab686
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Nov 10 09:42:49 2016 +0100

    if(): Prefer return/continue shortcut instead of nesting.

 glom/base_db_table_data.cc                         |  158 ++--
 glom/libglom/document/document.cc                  |  760 ++++++++++----------
 glom/mode_data/notebook_data.cc                    |   43 +-
 glom/mode_design/iso_codes.cc                      |  106 ++--
 glom/mode_design/layout/dialog_layout_details.cc   |  388 +++++-----
 glom/mode_design/layout/dialog_layout_export.cc    |   72 +-
 .../layout_item_dialogs/dialog_fieldslist.cc       |  110 ++--
 .../layout_item_dialogs/dialog_sortfields.cc       |   69 +-
 .../report_layout/dialog_layout_report.cc          |   68 +-
 .../mode_design/translation/window_translations.cc |   50 +-
 glom/mode_design/users/dialog_groups_list.cc       |   18 +-
 glom/notebook_glom.cc                              |   53 +-
 glom/utility_widgets/adddel/adddel.cc              |    9 +-
 glom/variablesmap.cc                               |   16 +-
 14 files changed, 958 insertions(+), 962 deletions(-)
---
diff --git a/glom/base_db_table_data.cc b/glom/base_db_table_data.cc
index a627783..0476dbb 100644
--- a/glom/base_db_table_data.cc
+++ b/glom/base_db_table_data.cc
@@ -96,89 +96,89 @@ bool Base_DB_Table_Data::record_new(bool use_entered_data, const Gnome::Gda::Val
   for(const auto& layout_item : fieldsToAdd)
   {
     const Glib::ustring field_name = layout_item->get_name();
-    if(!layout_item->get_has_relationship_name()) //TODO: Allow people to add a related record also by 
entering new data in a related field of the related record.
-    {
-      if (!map_added.count(field_name)) //If it was not added already.
-      {
-        Gnome::Gda::Value value;
+    if(layout_item->get_has_relationship_name()) //TODO: Allow people to add a related record also by 
entering new data in a related field of the related record.
+      continue;
 
-        const auto field = layout_item->get_full_field_details();
-        if(!field)
-          continue;
+    if (map_added.count(field_name)) //If it was added already.
+      continue;
 
-        //Use the specified (generated) primary key value, if there is one:
-        if(primary_key_name == field_name && !Conversions::value_is_empty(primary_key_value))
-        {
-          value = primary_key_value;
-        }
-        else
-        {
-          if(use_entered_data)
-            value = get_entered_field_data(*layout_item);
-        }
+    Gnome::Gda::Value value;
 
-        if(Conversions::value_is_empty(value)) //This deals with empty strings too.
-        {
-          //If the default value should be calculated, then calculate it:
-          if(field->get_has_calculation())
-          {
-            const auto calculation = field->get_calculation();
-            const auto field_values = get_record_field_values_for_calculation(m_table_name, fieldPrimaryKey, 
primary_key_value);
-
-            //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?
-            auto sharedconnection = connect_to_server(AppWindow::get_appwindow());
-
-            Glib::ustring error_message; //TODO: Check this.
-            value =
-              glom_evaluate_python_function_implementation(
-                field->get_glom_type(),
-                calculation,
-                field_values,
-                document,
-                m_table_name,
-                fieldPrimaryKey, primary_key_value,
-                sharedconnection->get_gda_connection(),
-                error_message);
-          }
-        }
+    const auto field = layout_item->get_full_field_details();
+    if(!field)
+      continue;
 
-        //Use default values (These are also specified in postgres as part of the field definition,
-        //so we could theoretically just not specify it here.)
-        //TODO_Performance: Add has_default_value()?
-        if(Conversions::value_is_empty(value))
-        {
-          value = field->get_default_value();
-        }
+    //Use the specified (generated) primary key value, if there is one:
+    if(primary_key_name == field_name && !Conversions::value_is_empty(primary_key_value))
+    {
+      value = primary_key_value;
+    }
+    else
+    {
+      if(use_entered_data)
+        value = get_entered_field_data(*layout_item);
+    }
 
-        //Use auto-increment values:
-        if(field->get_auto_increment() && Conversions::value_is_empty(value))
-        {
-          value =
-            DbUtils::get_next_auto_increment_value(m_table_name, field->get_name());
-        }
+    if(Conversions::value_is_empty(value)) //This deals with empty strings too.
+    {
+      //If the default value should be calculated, then calculate it:
+      if(field->get_has_calculation())
+      {
+        const auto calculation = field->get_calculation();
+        const auto field_values = get_record_field_values_for_calculation(m_table_name, fieldPrimaryKey, 
primary_key_value);
+
+        //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?
+        auto sharedconnection = connect_to_server(AppWindow::get_appwindow());
+
+        Glib::ustring error_message; //TODO: Check this.
+        value =
+          glom_evaluate_python_function_implementation(
+            field->get_glom_type(),
+            calculation,
+            field_values,
+            document,
+            m_table_name,
+            fieldPrimaryKey, primary_key_value,
+            sharedconnection->get_gda_connection(),
+            error_message);
+      }
+    }
 
-        /* //TODO: This would be too many small queries when adding one record.
-        //Check whether the value meets uniqueness constraints:
-        if(field->get_primary_key() || field->get_unique_key())
-        {
-          if(!get_field_value_is_unique(m_table_name, layout_item, value))
-          {
-            //Ignore this field value. TODO: Warn the user about it.
-          }
-        }
-        */
-        if(!value.is_null())
-        {
-          builder->add_field_value(field_name, value);
-          map_added.emplace(field_name);
-        }
-        else
-        {
-          std::cerr << G_STRFUNC << ": value is null for field: " << field_name << std::endl;
-        }
+    //Use default values (These are also specified in postgres as part of the field definition,
+    //so we could theoretically just not specify it here.)
+    //TODO_Performance: Add has_default_value()?
+    if(Conversions::value_is_empty(value))
+    {
+      value = field->get_default_value();
+    }
+
+    //Use auto-increment values:
+    if(field->get_auto_increment() && Conversions::value_is_empty(value))
+    {
+      value =
+        DbUtils::get_next_auto_increment_value(m_table_name, field->get_name());
+    }
+
+    /* //TODO: This would be too many small queries when adding one record.
+    //Check whether the value meets uniqueness constraints:
+    if(field->get_primary_key() || field->get_unique_key())
+    {
+      if(!get_field_value_is_unique(m_table_name, layout_item, value))
+      {
+        //Ignore this field value. TODO: Warn the user about it.
       }
     }
+    */
+    if(!value.is_null())
+    {
+      builder->add_field_value(field_name, value);
+      map_added.emplace(field_name);
+    }
+    else
+    {
+      std::cerr << G_STRFUNC << ": value is null for field: " << field_name << std::endl;
+    }
   }
 
   //Put it all together to create the record with these field values:
diff --git a/glom/libglom/document/document.cc b/glom/libglom/document/document.cc
index 44a7601..2acb48a 100644
--- a/glom/libglom/document/document.cc
+++ b/glom/libglom/document/document.cc
@@ -1963,22 +1963,22 @@ void Document::load_after_layout_item_formatting(const xmlpp::Element* element,
         for(const auto& node_choices : nodeChoiceList->get_children(GLOM_NODE_FORMAT_CUSTOM_CHOICE))
         {
           const auto element_custom_choices = dynamic_cast<const xmlpp::Element*>(node_choices);
-          if(element_custom_choices)
-          {
-            if(field_type == Field::glom_field_type::INVALID)
-            {
-              //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 auto field_temp = get_field(table_name, field_name);
-              if(field_temp)
-                field_type = field_temp->get_glom_type();
-            }
+          if (!element_custom_choices)
+            continue;
 
-            auto value = std::make_shared<ChoiceValue>();
-            load_after_choicevalue(element_custom_choices, value, field_type);
-            list_values.emplace_back(value);
+          if(field_type == Field::glom_field_type::INVALID)
+          {
+            //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 auto field_temp = get_field(table_name, field_name);
+            if(field_temp)
+              field_type = field_temp->get_glom_type();
           }
+
+          auto value = std::make_shared<ChoiceValue>();
+          load_after_choicevalue(element_custom_choices, value, field_type);
+          list_values.emplace_back(value);
         }
 
         format.set_choices_custom(list_values);
@@ -2130,17 +2130,17 @@ void Document::load_after_sort_by(const xmlpp::Element* node, const Glib::ustrin
   for(const auto& node_item_field : node->get_children(GLOM_NODE_DATA_LAYOUT_ITEM_FIELD))
   {
     const auto element = dynamic_cast<const xmlpp::Element*>(node_item_field);
-    if(element)
-    {
-      auto item = std::make_shared<LayoutItem_Field>();
-      //item.set_full_field_details_empty();
-      load_after_layout_item_field(element, table_name, item);
-      item->set_full_field_details( get_field(item->get_table_used(table_name), item->get_name()) );
+    if(!element)
+      continue;
 
-      const auto ascending = XmlUtils::get_node_attribute_value_as_bool(element, 
GLOM_ATTRIBUTE_SORT_ASCENDING);
+    auto item = std::make_shared<LayoutItem_Field>();
+    //item.set_full_field_details_empty();
+    load_after_layout_item_field(element, table_name, item);
+    item->set_full_field_details( get_field(item->get_table_used(table_name), item->get_name()) );
 
-      list_fields.emplace_back( LayoutItem_GroupBy::type_pair_sort_field(item, ascending) );
-    }
+    const auto ascending = XmlUtils::get_node_attribute_value_as_bool(element, 
GLOM_ATTRIBUTE_SORT_ASCENDING);
+
+    list_fields.emplace_back( LayoutItem_GroupBy::type_pair_sort_field(item, ascending) );
   }
 }
 
@@ -2468,16 +2468,16 @@ void Document::load_after_translations(const xmlpp::Element* element, const std:
     for(const auto& node_translation : nodeTranslations->get_children(GLOM_NODE_TRANSLATION))
     {
       const auto element_translation = dynamic_cast<const xmlpp::Element*>(node_translation);
-      if(element_translation)
-      {
-        const auto locale = XmlUtils::get_node_attribute_value(element_translation, 
GLOM_ATTRIBUTE_TRANSLATION_LOCALE);
-        const auto translation = XmlUtils::get_node_attribute_value(element_translation, 
GLOM_ATTRIBUTE_TRANSLATION_VALUE);
-        item->set_title(translation, locale);
+      if(!element_translation)
+        continue;
 
-        //Remember any new translation locales in our cached list:
-        //TODO: Use a set instead?
-        Utils::add_unique(m_translation_available_locales, locale);
-      }
+      const auto locale = XmlUtils::get_node_attribute_value(element_translation, 
GLOM_ATTRIBUTE_TRANSLATION_LOCALE);
+      const auto translation = XmlUtils::get_node_attribute_value(element_translation, 
GLOM_ATTRIBUTE_TRANSLATION_VALUE);
+      item->set_title(translation, locale);
+
+      //Remember any new translation locales in our cached list:
+      //TODO: Use a set instead?
+      Utils::add_unique(m_translation_available_locales, locale);
     }
   }
 
@@ -2634,176 +2634,172 @@ bool Document::load_after(int& failure_code)
       for(const auto& node_table : list_nodes_tables)
       {
         auto nodeTable = dynamic_cast<xmlpp::Element*>(node_table);
-        if(nodeTable)
-        {
-          const auto table_name = XmlUtils::get_node_attribute_value(nodeTable, GLOM_ATTRIBUTE_NAME);
+        if(!nodeTable)
+          continue;
 
-          const auto doctableinfo = std::make_shared<DocumentTableInfo>();
-          m_tables[table_name] = doctableinfo;
+        const auto table_name = XmlUtils::get_node_attribute_value(nodeTable, GLOM_ATTRIBUTE_NAME);
 
-          auto table_info = std::make_shared<TableInfo>();
-          table_info->set_name(table_name);
-          table_info->set_hidden( XmlUtils::get_node_attribute_value_as_bool(nodeTable, 
GLOM_ATTRIBUTE_HIDDEN) );
-          table_info->set_default( XmlUtils::get_node_attribute_value_as_bool(nodeTable, 
GLOM_ATTRIBUTE_DEFAULT) );
+        const auto doctableinfo = std::make_shared<DocumentTableInfo>();
+        m_tables[table_name] = doctableinfo;
 
-          doctableinfo->m_info = table_info;
+        auto table_info = std::make_shared<TableInfo>();
+        table_info->set_name(table_name);
+        table_info->set_hidden( XmlUtils::get_node_attribute_value_as_bool(nodeTable, GLOM_ATTRIBUTE_HIDDEN) 
);
+        table_info->set_default( XmlUtils::get_node_attribute_value_as_bool(nodeTable, 
GLOM_ATTRIBUTE_DEFAULT) );
 
-          doctableinfo->m_overviewx = XmlUtils::get_node_attribute_value_as_float(nodeTable, 
GLOM_ATTRIBUTE_OVERVIEW_X);
-          doctableinfo->m_overviewy = XmlUtils::get_node_attribute_value_as_float(nodeTable, 
GLOM_ATTRIBUTE_OVERVIEW_Y);
+        doctableinfo->m_info = table_info;
 
-          //Translations:
-          load_after_translations(nodeTable, doctableinfo->m_info);
+        doctableinfo->m_overviewx = XmlUtils::get_node_attribute_value_as_float(nodeTable, 
GLOM_ATTRIBUTE_OVERVIEW_X);
+        doctableinfo->m_overviewy = XmlUtils::get_node_attribute_value_as_float(nodeTable, 
GLOM_ATTRIBUTE_OVERVIEW_Y);
 
-          //Relationships:
-          //These should be loaded before the fields, because the fields use them.
-          const auto nodeRelationships = XmlUtils::get_node_child_named(nodeTable, GLOM_NODE_RELATIONSHIPS);
-          if(nodeRelationships)
-          {
-            for(const auto& item_rel : nodeRelationships->get_children(GLOM_NODE_RELATIONSHIP))
-            {
-              const auto node_rel = dynamic_cast<xmlpp::Element*>(item_rel);
-              if(node_rel)
-              {
-                auto relationship = std::make_shared<Relationship>();
-                const auto relationship_name = XmlUtils::get_node_attribute_value(node_rel, 
GLOM_ATTRIBUTE_NAME);
+        //Translations:
+        load_after_translations(nodeTable, doctableinfo->m_info);
 
-                relationship->set_from_table(table_name);
-                relationship->set_name(relationship_name);;
+        //Relationships:
+        //These should be loaded before the fields, because the fields use them.
+        const auto nodeRelationships = XmlUtils::get_node_child_named(nodeTable, GLOM_NODE_RELATIONSHIPS);
+        if(nodeRelationships)
+        {
+          for(const auto& item_rel : nodeRelationships->get_children(GLOM_NODE_RELATIONSHIP)) {
+            const auto node_rel = dynamic_cast<xmlpp::Element*>(item_rel);
+            if (!node_rel)
+              continue;
 
-                relationship->set_from_field( XmlUtils::get_node_attribute_value(node_rel, 
GLOM_ATTRIBUTE_KEY) );
-                relationship->set_to_table( XmlUtils::get_node_attribute_value(node_rel, 
GLOM_ATTRIBUTE_OTHER_TABLE) );
-                relationship->set_to_field( XmlUtils::get_node_attribute_value(node_rel, 
GLOM_ATTRIBUTE_OTHER_KEY) );
-                relationship->set_auto_create( XmlUtils::get_node_attribute_value_as_bool(node_rel, 
GLOM_ATTRIBUTE_AUTO_CREATE) );
-                relationship->set_allow_edit( XmlUtils::get_node_attribute_value_as_bool(node_rel, 
GLOM_ATTRIBUTE_ALLOW_EDIT) );
+            auto relationship = std::make_shared<Relationship>();
+            const auto relationship_name = XmlUtils::get_node_attribute_value(node_rel, GLOM_ATTRIBUTE_NAME);
 
-                //Translations:
-                load_after_translations(node_rel, relationship);
+            relationship->set_from_table(table_name);
+            relationship->set_name(relationship_name);;
 
-                doctableinfo->m_relationships.emplace_back(relationship);
-              }
-            }
+            relationship->set_from_field(XmlUtils::get_node_attribute_value(node_rel, GLOM_ATTRIBUTE_KEY));
+            relationship->set_to_table(XmlUtils::get_node_attribute_value(node_rel, 
GLOM_ATTRIBUTE_OTHER_TABLE));
+            relationship->set_to_field(XmlUtils::get_node_attribute_value(node_rel, 
GLOM_ATTRIBUTE_OTHER_KEY));
+            relationship->set_auto_create(
+              XmlUtils::get_node_attribute_value_as_bool(node_rel, GLOM_ATTRIBUTE_AUTO_CREATE));
+            relationship->set_allow_edit(
+              XmlUtils::get_node_attribute_value_as_bool(node_rel, GLOM_ATTRIBUTE_ALLOW_EDIT));
+
+            //Translations:
+            load_after_translations(node_rel, relationship);
+
+            doctableinfo->m_relationships.emplace_back(relationship);
           }
+        }
 
-          //Fields:
-          const auto nodeFields = XmlUtils::get_node_child_named(nodeTable, GLOM_NODE_FIELDS);
-          if(nodeFields)
+        //Fields:
+        const auto nodeFields = XmlUtils::get_node_child_named(nodeTable, GLOM_NODE_FIELDS);
+        if(nodeFields)
+        {
+          const auto type_names = Field::get_type_names();
+
+          //Loop through Field child nodes:
+          for(const auto& item_field : nodeFields->get_children(GLOM_NODE_FIELD))
           {
-            const auto type_names = Field::get_type_names();
+            const auto node_field = dynamic_cast<xmlpp::Element*>(item_field);
+            if(!node_field)
+              continue;
 
-            //Loop through Field child nodes:
-            for(const auto& item_field : nodeFields->get_children(GLOM_NODE_FIELD))
-            {
-              const auto node_field = dynamic_cast<xmlpp::Element*>(item_field);
-              if(node_field)
-              {
-                auto field = std::make_shared<Field>();
+            auto field = std::make_shared<Field>();
 
-                const auto strName = XmlUtils::get_node_attribute_value(node_field, GLOM_ATTRIBUTE_NAME);
-                field->set_name( strName );
+            const auto strName = XmlUtils::get_node_attribute_value(node_field, GLOM_ATTRIBUTE_NAME);
+            field->set_name( strName );
 
-                field->set_primary_key( XmlUtils::get_node_attribute_value_as_bool(node_field, 
GLOM_ATTRIBUTE_PRIMARY_KEY) );
-                field->set_unique_key( XmlUtils::get_node_attribute_value_as_bool(node_field, 
GLOM_ATTRIBUTE_UNIQUE) );
-                field->set_auto_increment( XmlUtils::get_node_attribute_value_as_bool(node_field, 
GLOM_ATTRIBUTE_AUTOINCREMENT) );
+            field->set_primary_key( XmlUtils::get_node_attribute_value_as_bool(node_field, 
GLOM_ATTRIBUTE_PRIMARY_KEY) );
+            field->set_unique_key( XmlUtils::get_node_attribute_value_as_bool(node_field, 
GLOM_ATTRIBUTE_UNIQUE) );
+            field->set_auto_increment( XmlUtils::get_node_attribute_value_as_bool(node_field, 
GLOM_ATTRIBUTE_AUTOINCREMENT) );
 
-                //Get lookup information, if present.
-                auto nodeLookup = XmlUtils::get_node_child_named(node_field, GLOM_NODE_FIELD_LOOKUP);
-                if(nodeLookup)
-                {
-                  const auto lookup_relationship_name = XmlUtils::get_node_attribute_value(nodeLookup, 
GLOM_ATTRIBUTE_RELATIONSHIP_NAME);
-                  auto lookup_relationship = get_relationship(table_name, lookup_relationship_name);
-                  field->set_lookup_relationship(lookup_relationship);
+            //Get lookup information, if present.
+            auto nodeLookup = XmlUtils::get_node_child_named(node_field, GLOM_NODE_FIELD_LOOKUP);
+            if(nodeLookup)
+            {
+              const auto lookup_relationship_name = XmlUtils::get_node_attribute_value(nodeLookup, 
GLOM_ATTRIBUTE_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) );
-                }
+              field->set_lookup_field( XmlUtils::get_node_attribute_value(nodeLookup, GLOM_ATTRIBUTE_FIELD) 
);
+            }
 
-                field->set_calculation( XmlUtils::get_child_text_node(node_field, GLOM_NODE_CALCULATION) );
-                if(!(field->get_has_calculation())) //Try the deprecated attribute instead
-                  field->set_calculation( XmlUtils::get_node_attribute_value(node_field, 
GLOM_DEPRECATED_ATTRIBUTE_CALCULATION) );
+            field->set_calculation( XmlUtils::get_child_text_node(node_field, GLOM_NODE_CALCULATION) );
+            if(!(field->get_has_calculation())) //Try the deprecated attribute instead
+              field->set_calculation( XmlUtils::get_node_attribute_value(node_field, 
GLOM_DEPRECATED_ATTRIBUTE_CALCULATION) );
 
-                //Field Type:
-                const auto field_type = XmlUtils::get_node_attribute_value(node_field, GLOM_ATTRIBUTE_TYPE);
+            //Field Type:
+            const auto field_type = XmlUtils::get_node_attribute_value(node_field, GLOM_ATTRIBUTE_TYPE);
 
-                //Get the type enum for this string representation of the type:
-                auto field_type_enum = Field::glom_field_type::INVALID;
-                for(const auto& type_pair : type_names)
-                {
-                  if(type_pair.second == field_type)
-                  {
-                    field_type_enum = type_pair.first;
-                    break;
-                  }
-                }
+            //Get the type enum for this string representation of the type:
+            auto field_type_enum = Field::glom_field_type::INVALID;
+            for(const auto& type_pair : type_names)
+            {
+              if(type_pair.second == field_type)
+              {
+                field_type_enum = type_pair.first;
+                break;
+              }
+            }
 
 
-                //We set this after set_field_info(), because that gets a glom type from the (not-specified) 
gdatype. Yes, that's strange, and should probably be more explicit.
-                field->set_glom_type(field_type_enum);
+            //We set this after set_field_info(), because that gets a glom type from the (not-specified) 
gdatype. Yes, that's strange, and should probably be more explicit.
+            field->set_glom_type(field_type_enum);
 
-                field->set_default_value( XmlUtils::get_node_attribute_value_as_value(node_field, 
GLOM_ATTRIBUTE_DEFAULT_VALUE, field_type_enum) );
+            field->set_default_value( XmlUtils::get_node_attribute_value_as_value(node_field, 
GLOM_ATTRIBUTE_DEFAULT_VALUE, field_type_enum) );
 
-                //Default Formatting:
-                const auto elementFormatting = XmlUtils::get_node_child_named(node_field, GLOM_NODE_FORMAT);
-                if(elementFormatting)
-                  load_after_layout_item_formatting(elementFormatting, field->m_default_formatting, 
field_type_enum, table_name, strName);
+            //Default Formatting:
+            const auto elementFormatting = XmlUtils::get_node_child_named(node_field, GLOM_NODE_FORMAT);
+            if(elementFormatting)
+              load_after_layout_item_formatting(elementFormatting, field->m_default_formatting, 
field_type_enum, table_name, strName);
 
-                //Translations:
-                load_after_translations(node_field, field);
+            //Translations:
+            load_after_translations(node_field, field);
 
-                doctableinfo->m_fields.emplace_back(field);
-              }
-            }
-          } //Fields
-
-          // Load Example Rows after fields have been loaded, because they
-          // need the fields to be able to associate a value to a named field.
-          // TODO: Allow this to be loaded progressively from disk later,
-          // instead of storing in it all in memory?
-          const auto nodeExampleRows = XmlUtils::get_node_child_named(nodeTable, GLOM_NODE_EXAMPLE_ROWS);
-          if(nodeExampleRows)
-          {
-            //Loop through example_row child nodes:
-            for(const auto& item_row : nodeExampleRows->get_children(GLOM_NODE_EXAMPLE_ROW))
-            {
-              const auto node_row = dynamic_cast<xmlpp::Element*>(item_row);
-              if(node_row)
-              {
-                type_row_data field_values(doctableinfo->m_fields.size());
-                //Loop through value child nodes
-                for(const auto& item_value : node_row->get_children(GLOM_NODE_VALUE))
-                {
-                  const auto node_value = dynamic_cast<xmlpp::Element*>(item_value);
-                  if(node_value)
-                  {
-                    const auto column_name = node_value->get_attribute(GLOM_ATTRIBUTE_COLUMN);
-                    if(column_name)
-                    {
-                      //std::cout << "DEBUG: column_name = " << column_name->get_value() << " fields size=" 
<< doctableinfo->m_fields.size() << std::endl;
-
-                      // TODO_Performance: If it's too many rows we could
-                      // consider a map to find the column more quickly.
-                      for(unsigned int i = 0; i < doctableinfo->m_fields.size(); ++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()))
-                        {
-                          field_values[i] = XmlUtils::get_node_text_child_as_value(node_value, 
field->get_glom_type());
-                          //std::cout << "    DEBUG: document example value: field=" << field->get_name() << 
", value=" << field_values[i].to_string() << std::endl;
-                          break;
-                        }
-                      }
-                    }
-                  }
+            doctableinfo->m_fields.emplace_back(field);
+          }
+        } //Fields
+
+        // Load Example Rows after fields have been loaded, because they
+        // need the fields to be able to associate a value to a named field.
+        // TODO: Allow this to be loaded progressively from disk later,
+        // instead of storing in it all in memory?
+        const auto nodeExampleRows = XmlUtils::get_node_child_named(nodeTable, GLOM_NODE_EXAMPLE_ROWS);
+        if(nodeExampleRows)
+        {
+          //Loop through example_row child nodes:
+          for(const auto& item_row : nodeExampleRows->get_children(GLOM_NODE_EXAMPLE_ROW)) {
+            const auto node_row = dynamic_cast<xmlpp::Element*>(item_row);
+            if (!node_row)
+              continue;
+
+            type_row_data field_values(doctableinfo->m_fields.size());
+            //Loop through value child nodes
+            for (const auto& item_value : node_row->get_children(GLOM_NODE_VALUE)) {
+              const auto node_value = dynamic_cast<xmlpp::Element*>(item_value);
+              if (!node_value)
+                continue;
+
+              const auto column_name = node_value->get_attribute(GLOM_ATTRIBUTE_COLUMN);
+              if (!column_name)
+                continue;
+
+              //std::cout << "DEBUG: column_name = " << column_name->get_value() << " fields size=" << 
doctableinfo->m_fields.size() << std::endl;
+
+              // TODO_Performance: If it's too many rows we could
+              // consider a map to find the column more quickly.
+              for (unsigned int i = 0; i < doctableinfo->m_fields.size(); ++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())) {
+                  field_values[i] = XmlUtils::get_node_text_child_as_value(node_value, 
field->get_glom_type());
+                  //std::cout << "    DEBUG: document example value: field=" << field->get_name() << ", 
value=" << field_values[i].to_string() << std::endl;
+                  break;
                 }
-
-                // Append line to doctableinfo->m_example_rows
-                doctableinfo->m_example_rows.emplace_back(field_values);
               }
             }
-          } // Example Rows
 
-          //std::cout << "  debug: loading: table=" << table_name << ", m_example_rows.size()=" << 
doctableinfo->m_example_rows.size() << std::endl;
+            // Append line to doctableinfo->m_example_rows
+            doctableinfo->m_example_rows.emplace_back(field_values);
+          }
+        } // Example Rows
 
-        } //if(table)
+        //std::cout << "  debug: loading: table=" << table_name << ", m_example_rows.size()=" << 
doctableinfo->m_example_rows.size() << std::endl;
       } //Tables.
 
       //Look at each "table" node.
@@ -2812,254 +2808,254 @@ bool Document::load_after(int& failure_code)
       for(const auto& node_table : list_nodes_tables)
       {
         auto nodeTable = dynamic_cast<xmlpp::Element*>(node_table);
-        if(nodeTable)
-        {
-          const auto table_name = XmlUtils::get_node_attribute_value(nodeTable, GLOM_ATTRIBUTE_NAME);
-          const auto doctableinfo = m_tables[table_name];
+        if(!nodeTable)
+          continue;
+
+        const auto table_name = XmlUtils::get_node_attribute_value(nodeTable, GLOM_ATTRIBUTE_NAME);
+        const auto doctableinfo = m_tables[table_name];
 
-          //Layouts:
-          const auto nodeDataLayouts = XmlUtils::get_node_child_named(nodeTable, GLOM_NODE_DATA_LAYOUTS);
-          if(nodeDataLayouts)
+        //Layouts:
+        const auto nodeDataLayouts = XmlUtils::get_node_child_named(nodeTable, GLOM_NODE_DATA_LAYOUTS);
+        if(nodeDataLayouts)
+        {
+          for(const auto& item : nodeDataLayouts->get_children(GLOM_NODE_DATA_LAYOUT))
           {
-            for(const auto& item : nodeDataLayouts->get_children(GLOM_NODE_DATA_LAYOUT))
+            auto node_data_layout = dynamic_cast<xmlpp::Element*>(item);
+            if(!node_data_layout)
+              continue;
+
+            const auto layout_name = XmlUtils::get_node_attribute_value(node_data_layout, 
GLOM_ATTRIBUTE_NAME);
+            const auto layout_platform = XmlUtils::get_node_attribute_value(node_data_layout, 
GLOM_ATTRIBUTE_LAYOUT_PLATFORM);
+
+            type_list_layout_groups layout_groups;
+
+            const auto node_group = XmlUtils::get_node_child_named(node_data_layout, 
GLOM_NODE_DATA_LAYOUT_GROUPS);
+            if(!node_group)
+              continue;
+
+            //Look at all its children:
+            for(const auto& item_group : node_group->get_children(GLOM_NODE_DATA_LAYOUT_GROUP))
             {
-              auto node_data_layout = dynamic_cast<xmlpp::Element*>(item);
-              if(node_data_layout)
-              {
-                const auto layout_name = XmlUtils::get_node_attribute_value(node_data_layout, 
GLOM_ATTRIBUTE_NAME);
-                const auto layout_platform = XmlUtils::get_node_attribute_value(node_data_layout, 
GLOM_ATTRIBUTE_LAYOUT_PLATFORM);
+              const auto node_layout_group = dynamic_cast<const xmlpp::Element*>(item_group);
+              if(!node_layout_group)
+               continue;
 
-                type_list_layout_groups layout_groups;
+              const auto group_name = XmlUtils::get_node_attribute_value(node_layout_group, 
GLOM_ATTRIBUTE_NAME);
+              if(group_name.empty())
+                continue;
 
-                const auto node_group = XmlUtils::get_node_child_named(node_data_layout, 
GLOM_NODE_DATA_LAYOUT_GROUPS);
-                if(node_group)
-                {
-                  //Look at all its children:
-                  for(const auto& item_group : node_group->get_children(GLOM_NODE_DATA_LAYOUT_GROUP))
-                  {
-                    const auto node_layout_group = dynamic_cast<const xmlpp::Element*>(item_group);
-                    if(node_layout_group)
-                    {
-                      const auto group_name = XmlUtils::get_node_attribute_value(node_layout_group, 
GLOM_ATTRIBUTE_NAME);
-                      if(!group_name.empty())
-                      {
-                        auto group = std::make_shared<LayoutGroup>();
-                        load_after_layout_group(node_layout_group, table_name, group);
-
-                        layout_groups.emplace_back(group);
-                      }
-                    }
-                  }
-                }
+              auto group = std::make_shared<LayoutGroup>();
+              load_after_layout_group(node_layout_group, table_name, group);
 
-                LayoutInfo layout_info;
-                layout_info.m_layout_name = layout_name;
-                layout_info.m_layout_platform = layout_platform;
-                layout_info.m_layout_groups = layout_groups;
-                doctableinfo->m_layouts.emplace_back(layout_info);
-              }
+              layout_groups.emplace_back(group);
             }
-          } //if(nodeDataLayouts)
+
+            LayoutInfo layout_info;
+            layout_info.m_layout_name = layout_name;
+            layout_info.m_layout_platform = layout_platform;
+            layout_info.m_layout_groups = layout_groups;
+            doctableinfo->m_layouts.emplace_back(layout_info);
+          }
+        } //if(nodeDataLayouts)
 
 
-          //Reports:
-          const auto nodeReports = XmlUtils::get_node_child_named(nodeTable, GLOM_NODE_REPORTS);
-          if(nodeReports)
+        //Reports:
+        const auto nodeReports = XmlUtils::get_node_child_named(nodeTable, GLOM_NODE_REPORTS);
+        if(nodeReports)
+        {
+          for(const auto& item_report : nodeReports->get_children(GLOM_NODE_REPORT))
           {
-            for(const auto& item_report : nodeReports->get_children(GLOM_NODE_REPORT))
-            {
-              auto node_report = dynamic_cast<xmlpp::Element*>(item_report);
-              if(node_report)
-              {
-                const auto report_name = XmlUtils::get_node_attribute_value(node_report, 
GLOM_ATTRIBUTE_NAME);
-                const auto show_table_title = XmlUtils::get_node_attribute_value_as_bool(node_report, 
GLOM_ATTRIBUTE_REPORT_SHOW_TABLE_TITLE);
+            auto node_report = dynamic_cast<xmlpp::Element*>(item_report);
+            if(!node_report)
+              continue;
 
-                //type_list_layout_groups layout_groups;
+            const auto report_name = XmlUtils::get_node_attribute_value(node_report, GLOM_ATTRIBUTE_NAME);
+            const auto show_table_title = XmlUtils::get_node_attribute_value_as_bool(node_report, 
GLOM_ATTRIBUTE_REPORT_SHOW_TABLE_TITLE);
 
-                auto report = std::make_shared<Report>();
-                report->set_name(report_name);
-                report->set_show_table_title(show_table_title);
+            //type_list_layout_groups layout_groups;
 
-                const auto node_group = XmlUtils::get_node_child_named(node_report, 
GLOM_NODE_DATA_LAYOUT_GROUPS);
-                if(node_group)
-                {
-                  //Look at all its children:
-                  for(const auto& item_group : node_group->get_children(GLOM_NODE_DATA_LAYOUT_GROUP))
-                  {
-                    const auto node_layout_group = dynamic_cast<const xmlpp::Element*>(item_group);
-                    if(node_layout_group)
-                    {
-                      auto group = report->get_layout_group();
-                      group->remove_all_items();
-                      load_after_layout_group(node_layout_group, table_name, group);
-
-                      fill_layout_field_details(table_name, group); //Get full field details from the field 
names.
-                    }
-                  }
-                }
+            auto report = std::make_shared<Report>();
+            report->set_name(report_name);
+            report->set_show_table_title(show_table_title);
 
-                //Translations:
-                load_after_translations(node_report, report);
+            const auto node_group = XmlUtils::get_node_child_named(node_report, 
GLOM_NODE_DATA_LAYOUT_GROUPS);
+            if(!node_group)
+              continue;
 
-                doctableinfo->m_reports[report->get_name()] = report;
-              }
+            //Look at all its children:
+            for(const auto& item_group : node_group->get_children(GLOM_NODE_DATA_LAYOUT_GROUP))
+            {
+              const auto node_layout_group = dynamic_cast<const xmlpp::Element*>(item_group);
+              if(!node_layout_group)
+                continue;
+
+              auto group = report->get_layout_group();
+              group->remove_all_items();
+              load_after_layout_group(node_layout_group, table_name, group);
+
+              fill_layout_field_details(table_name, group); //Get full field details from the field names.
             }
-          } //if(nodeReports)
 
+            //Translations:
+            load_after_translations(node_report, report);
+
+            doctableinfo->m_reports[report->get_name()] = report;
+          }
+        } //if(nodeReports)
 
-          //Print Layouts:
-          const auto nodePrintLayouts = XmlUtils::get_node_child_named(nodeTable, GLOM_NODE_PRINT_LAYOUTS);
-          if(nodePrintLayouts)
+
+        //Print Layouts:
+        const auto nodePrintLayouts = XmlUtils::get_node_child_named(nodeTable, GLOM_NODE_PRINT_LAYOUTS);
+        if(nodePrintLayouts)
+        {
+          for(const auto& item_print_layout : nodePrintLayouts->get_children(GLOM_NODE_PRINT_LAYOUT))
           {
-            for(const auto& item_print_layout : nodePrintLayouts->get_children(GLOM_NODE_PRINT_LAYOUT))
+            auto node_print_layout = dynamic_cast<xmlpp::Element*>(item_print_layout);
+            if(!node_print_layout)
+              continue;
+
+            const auto name = XmlUtils::get_node_attribute_value(node_print_layout, GLOM_ATTRIBUTE_NAME);
+            const auto show_table_title = XmlUtils::get_node_attribute_value_as_bool(node_print_layout, 
GLOM_ATTRIBUTE_REPORT_SHOW_TABLE_TITLE);
+
+            auto print_layout = std::make_shared<PrintLayout>();
+            print_layout->set_name(name);
+            print_layout->set_show_table_title(show_table_title);
+
+            print_layout->set_show_grid(
+              XmlUtils::get_node_attribute_value_as_bool(node_print_layout, 
GLOM_ATTRIBUTE_PRINT_LAYOUT_SHOW_GRID) );
+            print_layout->set_show_rules(
+              XmlUtils::get_node_attribute_value_as_bool(node_print_layout, 
GLOM_ATTRIBUTE_PRINT_LAYOUT_SHOW_RULES) );
+            print_layout->set_show_outlines(
+              XmlUtils::get_node_attribute_value_as_bool(node_print_layout, 
GLOM_ATTRIBUTE_PRINT_LAYOUT_SHOW_OUTLINES) );
+
+            //Get the horizontal and vertical rules:
+            PrintLayout::type_vec_doubles vec_rules_h;
+            for(const auto& item_rule : node_print_layout->get_children(GLOM_NODE_HORIZONTAL_RULE))
             {
-              auto node_print_layout = dynamic_cast<xmlpp::Element*>(item_print_layout);
-              if(node_print_layout)
-              {
-                const auto name = XmlUtils::get_node_attribute_value(node_print_layout, GLOM_ATTRIBUTE_NAME);
-                const auto show_table_title = XmlUtils::get_node_attribute_value_as_bool(node_print_layout, 
GLOM_ATTRIBUTE_REPORT_SHOW_TABLE_TITLE);
-
-                auto print_layout = std::make_shared<PrintLayout>();
-                print_layout->set_name(name);
-                print_layout->set_show_table_title(show_table_title);
-
-                print_layout->set_show_grid(
-                  XmlUtils::get_node_attribute_value_as_bool(node_print_layout, 
GLOM_ATTRIBUTE_PRINT_LAYOUT_SHOW_GRID) );
-                print_layout->set_show_rules(
-                  XmlUtils::get_node_attribute_value_as_bool(node_print_layout, 
GLOM_ATTRIBUTE_PRINT_LAYOUT_SHOW_RULES) );
-                print_layout->set_show_outlines(
-                  XmlUtils::get_node_attribute_value_as_bool(node_print_layout, 
GLOM_ATTRIBUTE_PRINT_LAYOUT_SHOW_OUTLINES) );
-
-                //Get the horizontal and vertical rules:
-                PrintLayout::type_vec_doubles vec_rules_h;
-                for(const auto& item_rule : node_print_layout->get_children(GLOM_NODE_HORIZONTAL_RULE))
-                {
-                  const auto node_rule = dynamic_cast<const xmlpp::Element*>(item_rule);
-                  if(!node_rule)
-                    continue;
+              const auto node_rule = dynamic_cast<const xmlpp::Element*>(item_rule);
+              if(!node_rule)
+                continue;
 
-                  const auto pos = XmlUtils::get_node_attribute_value_as_decimal(node_rule, 
GLOM_ATTRIBUTE_RULE_POSITION);
-                  vec_rules_h.emplace_back(pos);
-                }
-                print_layout->set_horizontal_rules(vec_rules_h);
+              const auto pos = XmlUtils::get_node_attribute_value_as_decimal(node_rule, 
GLOM_ATTRIBUTE_RULE_POSITION);
+              vec_rules_h.emplace_back(pos);
+            }
+            print_layout->set_horizontal_rules(vec_rules_h);
 
-                PrintLayout::type_vec_doubles vec_rules_v;
-                for(const auto& item_rule : node_print_layout->get_children(GLOM_NODE_VERTICAL_RULE))
-                {
-                  const auto node_rule = dynamic_cast<const xmlpp::Element*>(item_rule);
-                  if(!node_rule)
-                    continue;
+            PrintLayout::type_vec_doubles vec_rules_v;
+            for(const auto& item_rule : node_print_layout->get_children(GLOM_NODE_VERTICAL_RULE))
+            {
+              const auto node_rule = dynamic_cast<const xmlpp::Element*>(item_rule);
+              if(!node_rule)
+                continue;
 
-                  const auto pos = XmlUtils::get_node_attribute_value_as_decimal(node_rule, 
GLOM_ATTRIBUTE_RULE_POSITION);
-                  vec_rules_v.emplace_back(pos);
-                }
-                print_layout->set_vertical_rules(vec_rules_v);
+              const auto pos = XmlUtils::get_node_attribute_value_as_decimal(node_rule, 
GLOM_ATTRIBUTE_RULE_POSITION);
+              vec_rules_v.emplace_back(pos);
+            }
+            print_layout->set_vertical_rules(vec_rules_v);
 
 
-                //Page Setup:
-                const auto key_file_text = XmlUtils::get_child_text_node(node_print_layout, 
GLOM_NODE_PAGE_SETUP);
-                print_layout->set_page_setup(key_file_text);
+            //Page Setup:
+            const auto key_file_text = XmlUtils::get_child_text_node(node_print_layout, 
GLOM_NODE_PAGE_SETUP);
+            print_layout->set_page_setup(key_file_text);
 
-                print_layout->set_page_count(
-                  XmlUtils::get_node_attribute_value_as_decimal(node_print_layout, 
GLOM_ATTRIBUTE_PRINT_LAYOUT_PAGE_COUNT, 1));
+            print_layout->set_page_count(
+              XmlUtils::get_node_attribute_value_as_decimal(node_print_layout, 
GLOM_ATTRIBUTE_PRINT_LAYOUT_PAGE_COUNT, 1));
 
 
-                //Layout Groups:
-                const auto nodeGroups = XmlUtils::get_node_child_named(node_print_layout, 
GLOM_NODE_DATA_LAYOUT_GROUPS);
-                if(nodeGroups)
-                {
-                  //Look at all its children:
-                  for(const auto& item_group : nodeGroups->get_children(GLOM_NODE_DATA_LAYOUT_GROUP))
-                  {
-                    const auto node_layout_group = dynamic_cast<const xmlpp::Element*>(item_group);
-                    if(node_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. */);
-
-                      fill_layout_field_details(table_name, group); //Get full field details from the field 
names.
-                    }
-                  }
-                }
+            //Layout Groups:
+            const auto nodeGroups = XmlUtils::get_node_child_named(node_print_layout, 
GLOM_NODE_DATA_LAYOUT_GROUPS);
+            if(nodeGroups)
+            {
+              //Look at all its children:
+              for(const auto& item_group : nodeGroups->get_children(GLOM_NODE_DATA_LAYOUT_GROUP))
+              {
+                const auto node_layout_group = dynamic_cast<const xmlpp::Element*>(item_group);
+                if(!node_layout_group)
+                  continue;
 
-                //Translations:
-                load_after_translations(node_print_layout, print_layout);
+                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. 
*/);
 
-                doctableinfo->m_print_layouts[print_layout->get_name()] = print_layout;
+                fill_layout_field_details(table_name, group); //Get full field details from the field names.
               }
             }
-          } //if(nodePrintLayouts)
 
+            //Translations:
+            load_after_translations(node_print_layout, print_layout);
+
+            doctableinfo->m_print_layouts[print_layout->get_name()] = print_layout;
+          }
+        } //if(nodePrintLayouts)
 
-          //Groups:
-          //These are only used when recreating the database, for instance from an example file.
-          m_groups.clear();
 
-          const auto nodeGroups = XmlUtils::get_node_child_named(nodeRoot, GLOM_NODE_GROUPS);
-          if(nodeGroups)
+        //Groups:
+        //These are only used when recreating the database, for instance from an example file.
+        m_groups.clear();
+
+        const auto nodeGroups = XmlUtils::get_node_child_named(nodeRoot, GLOM_NODE_GROUPS);
+        if(nodeGroups)
+        {
+          for(const auto& item_group : nodeGroups->get_children(GLOM_NODE_GROUP))
           {
-            for(const auto& item_group : nodeGroups->get_children(GLOM_NODE_GROUP))
+            auto node_group = dynamic_cast<xmlpp::Element*>(item_group);
+            if(!node_group)
+              continue;
+
+            GroupInfo group_info;
+
+            group_info.set_name( XmlUtils::get_node_attribute_value(node_group, GLOM_ATTRIBUTE_NAME) );
+            group_info.m_developer = XmlUtils::get_node_attribute_value_as_bool(node_group, 
GLOM_ATTRIBUTE_DEVELOPER);
+
+            for(const auto& item_priv : node_group->get_children(GLOM_NODE_TABLE_PRIVS))
             {
-              auto node_group = dynamic_cast<xmlpp::Element*>(item_group);
-              if(node_group)
-              {
-                GroupInfo group_info;
+              auto node_priv = dynamic_cast<xmlpp::Element*>(item_priv);
+              if(!node_priv)
+                continue;
 
-                group_info.set_name( XmlUtils::get_node_attribute_value(node_group, GLOM_ATTRIBUTE_NAME) );
-                group_info.m_developer = XmlUtils::get_node_attribute_value_as_bool(node_group, 
GLOM_ATTRIBUTE_DEVELOPER);
+              const auto priv_table_name = XmlUtils::get_node_attribute_value(node_priv, 
GLOM_ATTRIBUTE_TABLE_NAME);
 
-                for(const auto& item_priv : node_group->get_children(GLOM_NODE_TABLE_PRIVS))
-                {
-                  auto node_priv = dynamic_cast<xmlpp::Element*>(item_priv);
-                  if(node_priv)
-                  {
-                    const auto priv_table_name = XmlUtils::get_node_attribute_value(node_priv, 
GLOM_ATTRIBUTE_TABLE_NAME);
-
-                    Privileges privs;
-                    privs.m_view = XmlUtils::get_node_attribute_value_as_bool(node_priv, 
GLOM_ATTRIBUTE_PRIV_VIEW);
-                    privs.m_edit = XmlUtils::get_node_attribute_value_as_bool(node_priv, 
GLOM_ATTRIBUTE_PRIV_EDIT);
-                    privs.m_create = XmlUtils::get_node_attribute_value_as_bool(node_priv, 
GLOM_ATTRIBUTE_PRIV_CREATE);
-                    privs.m_delete = XmlUtils::get_node_attribute_value_as_bool(node_priv, 
GLOM_ATTRIBUTE_PRIV_DELETE);
-
-                    group_info.m_map_privileges[priv_table_name] = privs;
-                  }
-                }
+              Privileges privs;
+              privs.m_view = XmlUtils::get_node_attribute_value_as_bool(node_priv, GLOM_ATTRIBUTE_PRIV_VIEW);
+              privs.m_edit = XmlUtils::get_node_attribute_value_as_bool(node_priv, GLOM_ATTRIBUTE_PRIV_EDIT);
+              privs.m_create = XmlUtils::get_node_attribute_value_as_bool(node_priv, 
GLOM_ATTRIBUTE_PRIV_CREATE);
+              privs.m_delete = XmlUtils::get_node_attribute_value_as_bool(node_priv, 
GLOM_ATTRIBUTE_PRIV_DELETE);
 
-                m_groups[group_info.get_name()] = group_info;
-              }
+              group_info.m_map_privileges[priv_table_name] = privs;
             }
+
+            m_groups[group_info.get_name()] = group_info;
           }
+        }
 
 
-          //Library Modules:
-          m_map_library_scripts.clear();
+        //Library Modules:
+        m_map_library_scripts.clear();
 
-          const auto nodeModules = XmlUtils::get_node_child_named(nodeRoot, GLOM_NODE_LIBRARY_MODULES);
-          if(nodeModules)
-          {
-            for(const auto& item : nodeModules->get_children(GLOM_NODE_LIBRARY_MODULE))
-            {
-              auto node_lib_module = dynamic_cast<xmlpp::Element*>(item);
-              if(node_lib_module)
-              {
-                //The name is in an attribute:
-                const auto module_name = XmlUtils::get_node_attribute_value(node_lib_module, 
GLOM_ATTRIBUTE_LIBRARY_MODULE_NAME);
+        const auto nodeModules = XmlUtils::get_node_child_named(nodeRoot, GLOM_NODE_LIBRARY_MODULES);
+        if(nodeModules)
+        {
+          for(const auto& item : nodeModules->get_children(GLOM_NODE_LIBRARY_MODULE)) {
+            auto node_lib_module = dynamic_cast<xmlpp::Element*>(item);
+            if (!node_lib_module)
+              continue;
 
-                //The string is in a child text node:
-                Glib::ustring script;
+            //The name is in an attribute:
+            const auto module_name = XmlUtils::get_node_attribute_value(node_lib_module,
+              GLOM_ATTRIBUTE_LIBRARY_MODULE_NAME);
 
-                const auto text_child = node_lib_module->get_first_child_text();
-                if(text_child)
-                  script = text_child->get_content();
+            //The string is in a child text node:
+            Glib::ustring script;
 
-                //Fall back to the deprecated attribute:
-                if(script.empty())
-                  script = XmlUtils::get_node_attribute_value(node_lib_module, 
GLOM_ATTRIBUTE_LIBRARY_MODULE_SCRIPT);
+            const auto text_child = node_lib_module->get_first_child_text();
+            if (text_child)
+              script = text_child->get_content();
 
-                m_map_library_scripts[module_name] = script;
-              }
-            }
+            //Fall back to the deprecated attribute:
+            if (script.empty())
+              script = XmlUtils::get_node_attribute_value(node_lib_module, 
GLOM_ATTRIBUTE_LIBRARY_MODULE_SCRIPT);
+
+            m_map_library_scripts[module_name] = script;
           }
 
         } //root
diff --git a/glom/mode_data/notebook_data.cc b/glom/mode_data/notebook_data.cc
index bb7ae31..4b81889 100644
--- a/glom/mode_data/notebook_data.cc
+++ b/glom/mode_data/notebook_data.cc
@@ -353,30 +353,29 @@ void Notebook_Data::on_switch_page_handler(Gtk::Widget* pPage)
 
   //Remember that currently-viewed layout, so we can show it again when the user comes back to this table 
from elsewhere:
   auto box = dynamic_cast<Box_Data*>(get_visible_child());
-  if(box)
-  {
-    auto document = get_document();
-    if(document)
-      document->set_layout_current(m_table_name, box->get_layout_name());
+  if(!box)
+    return;
 
-    //And refresh the list view whenever it is shown, to
-    //a) show any new records that were added via the details view, or via a related portal elsewhere.
-    //b) show changed field contents, changed elsewhere.
-    if(box == &m_Box_List)
-    {
-      //std::cout << "debug: switching to list\n";
-      const auto primary_key_selected = m_Box_List.get_primary_key_value_selected();
-      m_Box_List.refresh_data_from_database();
-      m_Box_List.set_primary_key_value_selected(primary_key_selected);
-    }
-    else if(box == &m_Box_Details)
-    {
-      //std::cout << "debug: switching to details\n";
-      const auto primary_key_selected = m_Box_List.get_primary_key_value_selected();
-      m_Box_Details.refresh_data_from_database_with_primary_key(primary_key_selected);
-    }
-  }
+  auto document = get_document();
+  if(document)
+    document->set_layout_current(m_table_name, box->get_layout_name());
 
+  //And refresh the list view whenever it is shown, to
+  //a) show any new records that were added via the details view, or via a related portal elsewhere.
+  //b) show changed field contents, changed elsewhere.
+  if(box == &m_Box_List)
+  {
+    //std::cout << "debug: switching to list\n";
+    const auto primary_key_selected = m_Box_List.get_primary_key_value_selected();
+    m_Box_List.refresh_data_from_database();
+    m_Box_List.set_primary_key_value_selected(primary_key_selected);
+  }
+  else if(box == &m_Box_Details)
+  {
+    //std::cout << "debug: switching to details\n";
+    const auto primary_key_selected = m_Box_List.get_primary_key_value_selected();
+    m_Box_Details.refresh_data_from_database_with_primary_key(primary_key_selected);
+  }
 }
 
 void Notebook_Data::get_record_counts(gulong& total, gulong& found)
diff --git a/glom/mode_design/iso_codes.cc b/glom/mode_design/iso_codes.cc
index 5c2cac0..296a6f0 100644
--- a/glom/mode_design/iso_codes.cc
+++ b/glom/mode_design/iso_codes.cc
@@ -62,27 +62,27 @@ type_list_currencies get_list_of_currency_symbols()
         for(const auto& node : nodeRoot->get_children("iso_4217_entry"))
         {
           auto nodeEntry = dynamic_cast<xmlpp::Element*>(node);
-          if(nodeEntry)
-          {
-            Currency currency;
+          if(!nodeEntry)
+            continue;
 
-            const auto attribute_code = nodeEntry->get_attribute("letter_code");
-            if(attribute_code)
-              currency.m_symbol = attribute_code->get_value();
+          Currency currency;
 
-            const auto attribute_name = nodeEntry->get_attribute("currency_name");
-            if(attribute_name)
-            {
-              Glib::ustring name = _(attribute_name->get_value().c_str());
-              const auto pchTranslatedName = dgettext("iso_4217", name.c_str());
-              if(pchTranslatedName)
-                name = pchTranslatedName;
+          const auto attribute_code = nodeEntry->get_attribute("letter_code");
+          if(attribute_code)
+            currency.m_symbol = attribute_code->get_value();
 
-              currency.m_name = name;
-            }
+          const auto attribute_name = nodeEntry->get_attribute("currency_name");
+          if(attribute_name)
+          {
+            Glib::ustring name = _(attribute_name->get_value().c_str());
+            const auto pchTranslatedName = dgettext("iso_4217", name.c_str());
+            if(pchTranslatedName)
+              name = pchTranslatedName;
 
-            list_currencies.emplace_back(currency);
+            currency.m_name = name;
           }
+
+          list_currencies.emplace_back(currency);
         }
       }
     }
@@ -162,25 +162,25 @@ Glib::ustring get_locale_name(const Glib::ustring& locale_id)
         for(const auto& node : nodeRoot->get_children("iso_639_entry"))
         {
           auto nodeEntry = dynamic_cast<xmlpp::Element*>(node);
-          if(nodeEntry)
+          if(!nodeEntry)
+            continue;
+
+          //TODO: There are 3 codes (not each entry has each code). Is this the correct one to identify a 
language?
+          const auto attribute_code = nodeEntry->get_attribute("iso_639_1_code");
+          if(attribute_code)
           {
-            //TODO: There are 3 codes (not each entry has each code). Is this the correct one to identify a 
language?
-            const auto attribute_code = nodeEntry->get_attribute("iso_639_1_code");
-            if(attribute_code)
+            const auto identifier = attribute_code->get_value();
+            if(!identifier.empty())
             {
-              const auto identifier = attribute_code->get_value();
-              if(!identifier.empty())
+              const auto attribute_name = nodeEntry->get_attribute("name");
+              if(attribute_name)
               {
-                const auto attribute_name = nodeEntry->get_attribute("name");
-                if(attribute_name)
-                {
-                  Glib::ustring name = attribute_name->get_value();
-                  const auto pchTranslatedName = dgettext("iso_639", name.c_str());
-                  if(pchTranslatedName)
-                    name = pchTranslatedName;
-
-                  map_languages[identifier] = name;
-                }
+                Glib::ustring name = attribute_name->get_value();
+                const auto pchTranslatedName = dgettext("iso_639", name.c_str());
+                if(pchTranslatedName)
+                  name = pchTranslatedName;
+
+                map_languages[identifier] = name;
               }
             }
           }
@@ -212,27 +212,27 @@ Glib::ustring get_locale_name(const Glib::ustring& locale_id)
         for(const auto& node : nodeRoot->get_children("iso_3166_entry"))
         {
           auto nodeEntry = dynamic_cast<xmlpp::Element*>(node);
-          if(nodeEntry)
-          {
-            const auto attribute_code = nodeEntry->get_attribute("alpha_2_code");
-            if(attribute_code)
-            {
-              const auto identifier = attribute_code->get_value();
-              if(!identifier.empty())
-              {
-                const auto attribute_name = nodeEntry->get_attribute("name");
-                if(attribute_name)
-                {
-                  Glib::ustring name = attribute_name->get_value();
-                  const auto pchTranslatedName = dgettext("iso_3166", name.c_str());
-                  if(pchTranslatedName)
-                    name = pchTranslatedName;
-
-                  map_country[identifier] = name;
-                }
-              }
-            }
-          }
+          if(!nodeEntry)
+            continue;
+
+          const auto attribute_code = nodeEntry->get_attribute("alpha_2_code");
+          if(!attribute_code)
+           continue;
+
+          const auto identifier = attribute_code->get_value();
+          if(identifier.empty())
+            continue;
+
+          const auto attribute_name = nodeEntry->get_attribute("name");
+          if(!attribute_name)
+            continue;
+
+          Glib::ustring name = attribute_name->get_value();
+          const auto pchTranslatedName = dgettext("iso_3166", name.c_str());
+          if(pchTranslatedName)
+            name = pchTranslatedName;
+
+          map_country[identifier] = name;
         }
       }
     }
diff --git a/glom/mode_design/layout/dialog_layout_details.cc 
b/glom/mode_design/layout/dialog_layout_details.cc
index f99d6fd..00cdc60 100644
--- a/glom/mode_design/layout/dialog_layout_details.cc
+++ b/glom/mode_design/layout/dialog_layout_details.cc
@@ -1096,254 +1096,254 @@ void Dialog_Layout_Details::on_cell_data_name(Gtk::CellRenderer* renderer, const
 
   //Set the view's cell properties depending on the model's data:
   auto renderer_text = dynamic_cast<Gtk::CellRendererText*>(renderer);
-  if(renderer_text)
-  {
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
+  if(!renderer_text)
+    return;
 
-      std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
+  if(!iter)
+    return;
 
-      //Use the markup property instead of the text property, so that we can give the text some style:
-      Glib::ustring markup;
+  Gtk::TreeModel::Row row = *iter;
 
-      bool is_group = false;
+  std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
 
-      auto layout_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
-      if(layout_portal)
+  //Use the markup property instead of the text property, so that we can give the text some style:
+  Glib::ustring markup;
+
+  bool is_group = false;
+
+  auto layout_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
+  if(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
+      markup = Glib::ustring::compose(_("Related List: %1"), layout_portal->get_relationship_name());
+  }
+  else
+  {
+    auto layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
+    if(layout_group)
+    {
+      is_group = true;
+
+      //Make group names bold:
+      markup = UiUtils::bold_message( layout_item->get_name() );
+    }
+    else
+    {
+      auto layout_item_field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
+      if(layout_item_field)
       {
-        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
-          markup = Glib::ustring::compose(_("Related List: %1"), layout_portal->get_relationship_name());
+        markup = Glib::ustring::compose(_("Field: %1"), layout_item_field->get_layout_display_name());
+
+        //Just for debugging:
+        //if(!row[m_model_items->m_columns.m_col_editable])
+        // markup += " *";
       }
       else
       {
-        auto layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
-        if(layout_group)
+        auto layout_item_button = std::dynamic_pointer_cast<LayoutItem_Button>(layout_item);
+        if(layout_item_button)
         {
-          is_group = true;
-
-          //Make group names bold:
-          markup = UiUtils::bold_message( layout_item->get_name() );
+          markup = _("Button"); //Buttons don't have names - just titles. TODO: Would they be useful?
         }
         else
         {
-          auto layout_item_field = std::dynamic_pointer_cast<LayoutItem_Field>(layout_item);
-          if(layout_item_field)
+          auto layout_item_text = std::dynamic_pointer_cast<LayoutItem_Text>(layout_item);
+          if(layout_item_text)
           {
-            markup = Glib::ustring::compose(_("Field: %1"), layout_item_field->get_layout_display_name());
-
-            //Just for debugging:
-            //if(!row[m_model_items->m_columns.m_col_editable])
-            // markup += " *";
+            markup = _("Text"); //Text objects don't have names - just titles. TODO: Would they be useful?
           }
           else
           {
-            auto layout_item_button = std::dynamic_pointer_cast<LayoutItem_Button>(layout_item);
-            if(layout_item_button)
+            auto layout_item_image = std::dynamic_pointer_cast<LayoutItem_Image>(layout_item);
+            if(layout_item_image)
             {
-              markup = _("Button"); //Buttons don't have names - just titles. TODO: Would they be useful?
+              markup = _("Image"); //Image objects don't have names - just titles. TODO: Would they be 
useful?
             }
+            else if(layout_item)
+              markup = layout_item->get_name();
             else
-            {
-              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
-              {
-                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?
-                }
-                else if(layout_item)
-                  markup = layout_item->get_name();
-                else
-                  markup = Glib::ustring();
-              }
-            }
+              markup = Glib::ustring();
           }
         }
       }
-
-      renderer_text->property_markup() = markup;
-
-      if(is_group)
-        renderer_text->property_editable() = true; //Group names can be changed.
-      else
-        renderer_text->property_editable() = false; //Field names can never be edited.
     }
   }
+
+  renderer_text->property_markup() = markup;
+
+  if(is_group)
+    renderer_text->property_editable() = true; //Group names can be changed.
+  else
+    renderer_text->property_editable() = false; //Field names can never be edited.
 }
 
 void Dialog_Layout_Details::on_cell_data_title(Gtk::CellRenderer* renderer, const Gtk::TreeModel::iterator& 
iter)
 {
   //Set the view's cell properties depending on the model's data:
   auto renderer_text = dynamic_cast<Gtk::CellRendererText*>(renderer);
-  if(renderer_text)
-  {
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
-      std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_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)
-        renderer_text->property_text() = item_get_title(layout_item);
-      else
-        renderer_text->property_text() = Glib::ustring();
+  if(!renderer_text)
+    return;
 
-      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;
-    }
-  }
+  if(!iter)
+    return;
+
+  Gtk::TreeModel::Row row = *iter;
+  std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_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)
+    renderer_text->property_text() = item_get_title(layout_item);
+  else
+    renderer_text->property_text() = Glib::ustring();
+
+  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;
 }
 
 void Dialog_Layout_Details::on_cell_data_column_width(Gtk::CellRenderer* renderer, const 
Gtk::TreeModel::iterator& iter)
 {
   //Set the view's cell properties depending on the model's data:
   auto renderer_text = dynamic_cast<Gtk::CellRendererText*>(renderer);
-  if(renderer_text)
-  {
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
-      std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
+  if(!renderer_text)
+    return;
 
-      guint column_width = 0;
-      if(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;
+  if(iter)
+    return;
 
-        column_width = layout_item->get_display_width();
-      }
+  Gtk::TreeModel::Row row = *iter;
+  std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
 
-      Glib::ustring text;
-      if(column_width) //Show nothing if no width has been specified, meaning that it's automatic.
-        text = Utils::string_from_decimal(column_width);
+  guint column_width = 0;
+  if(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;
 
-      renderer_text->property_text() = text;
-    }
+    column_width = layout_item->get_display_width();
   }
+
+  Glib::ustring text;
+  if(column_width) //Show nothing if no width has been specified, meaning that it's automatic.
+    text = Utils::string_from_decimal(column_width);
+
+  renderer_text->property_text() = text;
 }
 
 void Dialog_Layout_Details::on_cell_data_group_columns(Gtk::CellRenderer* renderer, const 
Gtk::TreeModel::iterator& iter)
 {
   //Set the view's cell properties depending on the model's data:
   auto renderer_text = dynamic_cast<Gtk::CellRendererText*>(renderer);
-  if(renderer_text)
-  {
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
-      std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
+  if(!renderer_text)
+   return;
 
-      auto layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
-      auto layout_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
+  if(!iter)
+    return;
 
-      const bool is_group = layout_group && !layout_portal; //Only groups have column_counts.
+  Gtk::TreeModel::Row row = *iter;
+  std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
 
-      //Get a text representation of the number:
-      Glib::ustring text;
-      if(is_group)
-      {
-        text = Utils::string_from_decimal(layout_group->get_columns_count());
-      }
-      else
-      {
-        //Show nothing in the columns_count columns for fields.
-      }
-      renderer_text->property_text() = text;
+  auto layout_group = std::dynamic_pointer_cast<LayoutGroup>(layout_item);
+  auto layout_portal = std::dynamic_pointer_cast<LayoutItem_Portal>(layout_item);
 
-      renderer_text->property_editable() = is_group;
-    }
+  const bool is_group = layout_group && !layout_portal; //Only groups have column_counts.
+
+  //Get a text representation of the number:
+  Glib::ustring text;
+  if(is_group)
+  {
+    text = Utils::string_from_decimal(layout_group->get_columns_count());
+  }
+  else
+  {
+    //Show nothing in the columns_count columns for fields.
   }
+  renderer_text->property_text() = text;
+
+  renderer_text->property_editable() = is_group;
 }
 
 void Dialog_Layout_Details::on_treeview_cell_edited_title(const Glib::ustring& path_string, const 
Glib::ustring& new_text)
 {
-  if(!path_string.empty())
-  {
-    Gtk::TreeModel::Path path(path_string);
+  if(path_string.empty())
+    return;
 
-    //Get the row from the path:
-    auto iter = m_model_items->get_iter(path);
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
-      std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
-      if(layout_item)
-      {
-        //Store the user's new text in the model:
-        layout_item->set_title(new_text, AppWindow::get_current_locale());
+  Gtk::TreeModel::Path path(path_string);
 
-        m_modified = true;
-      }
-    }
-  }
+  //Get the row from the path:
+  auto iter = m_model_items->get_iter(path);
+  if(!iter)
+    return;
+
+  Gtk::TreeModel::Row row = *iter;
+  std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
+  if(!layout_item)
+    return;
+
+  //Store the user's new text in the model:
+  layout_item->set_title(new_text, AppWindow::get_current_locale());
+
+  m_modified = true;
 }
 
 
 void Dialog_Layout_Details::on_treeview_cell_edited_name(const Glib::ustring& path_string, const 
Glib::ustring& new_text)
 {
-  if(!path_string.empty())
-  {
-    Gtk::TreeModel::Path path(path_string);
+  if(path_string.empty())
+    return;
 
-    //Get the row from the path:
-    auto iter = m_model_items->get_iter(path);
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
-      std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
-      if(layout_item)
-      {
-        //Store the user's new text in the model:
-        layout_item->set_name(new_text);
+  Gtk::TreeModel::Path path(path_string);
 
-        m_modified = true;
-      }
-    }
-  }
+  //Get the row from the path:
+  auto iter = m_model_items->get_iter(path);
+  if(!iter)
+    return;
+
+  Gtk::TreeModel::Row row = *iter;
+  std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
+  if(!layout_item)
+    return;
+
+  //Store the user's new text in the model:
+  layout_item->set_name(new_text);
+
+  m_modified = true;
 }
 
 void Dialog_Layout_Details::on_treeview_cell_edited_column_width(const Glib::ustring& path_string, const 
Glib::ustring& new_text)
 {
-  if(!path_string.empty())
-  {
-    Gtk::TreeModel::Path path(path_string);
+  if(path_string.empty())
+    return;
 
-    //Get the row from the path:
-    auto iter = m_model_items->get_iter(path);
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
-      std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
-      if(layout_item)
-      {
-        //Convert the text to a number, using the same logic used by GtkCellRendererText when it stores 
numbers.
-        const auto new_value = static_cast<guint>( std::stod(new_text) );
+  Gtk::TreeModel::Path path(path_string);
 
-        //Store the user's new value in the model:
-        layout_item->set_display_width(new_value);
+  //Get the row from the path:
+  auto iter = m_model_items->get_iter(path);
+  if(!iter)
+    return;
 
-        m_modified = true;
-      }
-    }
-  }
+  Gtk::TreeModel::Row row = *iter;
+  std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_layout_item];
+  if(!layout_item)
+    return;
+
+  //Convert the text to a number, using the same logic used by GtkCellRendererText when it stores numbers.
+  const auto new_value = static_cast<guint>( std::stod(new_text) );
+
+  //Store the user's new value in the model:
+  layout_item->set_display_width(new_value);
+
+  m_modified = true;
 }
 
 void Dialog_Layout_Details::on_treeview_cell_edited_group_columns(const Glib::ustring& path_string, const 
Glib::ustring& new_text)
@@ -1356,30 +1356,30 @@ void Dialog_Layout_Details::on_treeview_cell_edited_group_columns(const Glib::us
 
   //Get the row from the path:
   auto iter = m_model_items->get_iter(path);
-  if(iter)
+  if(!iter)
+    return;
+
+  Gtk::TreeModel::Row row = *iter;
+  std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_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)
   {
-    Gtk::TreeModel::Row row = *iter;
-    std::shared_ptr<LayoutItem> layout_item = row[m_model_items->m_columns.m_col_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.
-      //ColumnType new_value = ColumnType();
-      //new_value << astream; //Get it out of the stream as the numerical type.
+    //std::istringstream astream(new_text); //Put it in a stream.
+    //ColumnType new_value = ColumnType();
+    //new_value << astream; //Get it out of the stream as the numerical type.
 
-      //Convert the text to a number, using the same logic used by GtkCellRendererText when it stores 
numbers.
-      auto new_value = static_cast<guint>( std::stod(new_text) );
+    //Convert the text to a number, using the same logic used by GtkCellRendererText when it stores numbers.
+    auto new_value = static_cast<guint>( std::stod(new_text) );
 
-      //Don't allow a 0 columns_count:
-      if(new_value == 0)
-        new_value = 1;
+    //Don't allow a 0 columns_count:
+    if(new_value == 0)
+      new_value = 1;
 
-      //Store the user's new text in the model:
-      layout_group->set_columns_count(new_value);
+    //Store the user's new text in the model:
+    layout_group->set_columns_count(new_value);
 
-      m_modified = true;
-    }
+    m_modified = true;
   }
 }
 
diff --git a/glom/mode_design/layout/dialog_layout_export.cc b/glom/mode_design/layout/dialog_layout_export.cc
index 7add035..3039c40 100644
--- a/glom/mode_design/layout/dialog_layout_export.cc
+++ b/glom/mode_design/layout/dialog_layout_export.cc
@@ -301,55 +301,55 @@ void Dialog_Layout_Export::on_cell_data_name(Gtk::CellRenderer* renderer, const
 {
   //Set the view's cell properties depending on the model's data:
   auto renderer_text = dynamic_cast<Gtk::CellRendererText*>(renderer);
-  if(renderer_text)
-  {
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
+  if(!renderer_text)
+    return;
 
-      //Indicate that it's a field in another table.
-      std::shared_ptr<LayoutItem_Field> item = row[m_ColumnsFields.m_col_layout_item];
+  if(!iter)
+    return;
 
-      //Names can never be edited.
-      renderer_text->property_markup() = item->get_layout_display_name();
-    }
-  }
+  Gtk::TreeModel::Row row = *iter;
+
+  //Indicate that it's a field in another table.
+  std::shared_ptr<LayoutItem_Field> item = row[m_ColumnsFields.m_col_layout_item];
+
+  //Names can never be edited.
+  renderer_text->property_markup() = item->get_layout_display_name();
 }
 
 
 void Dialog_Layout_Export::on_button_edit_field()
 {
   auto refTreeSelection = m_treeview_fields->get_selection();
-  if(refTreeSelection)
-  {
-    //TODO: Handle multiple-selection:
-    auto iter = refTreeSelection->get_selected();
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
-      std::shared_ptr<LayoutItem_Field> field = row[m_ColumnsFields.m_col_layout_item];
+  if(!refTreeSelection)
+    return;
 
-      //Get the chosen field:
-      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:
+  //TODO: Handle multiple-selection:
+  auto iter = refTreeSelection->get_selected();
+  if(!iter)
+    return;
 
-        row[m_ColumnsFields.m_col_layout_item] = field;
+  Gtk::TreeModel::Row row = *iter;
+  std::shared_ptr<LayoutItem_Field> field = row[m_ColumnsFields.m_col_layout_item];
 
-        //Scroll to, and select, the new row:
-        /*
-        auto refTreeSelection = m_treeview_fields->get_selection();
-        if(refTreeSelection)
-          refTreeSelection->select(iter);
+  //Get the chosen field:
+  auto field_chosen = offer_field_list_select_one_field(field, m_table_name, this);
+  if(!field_chosen)
+   return;
 
-        m_treeview_fields->scroll_to_row( Gtk::TreeModel::Path(iter) );
+  //Set the field details in the layout treeview:
 
-        treeview_fill_sequences(m_model_fields, m_ColumnsFields.m_col_sequence); //The document should have 
checked this already, but it does not hurt to check again.
-        */
-      }
-    }
-  }
+  row[m_ColumnsFields.m_col_layout_item] = field;
+
+  //Scroll to, and select, the new row:
+  /*
+  auto refTreeSelection = m_treeview_fields->get_selection();
+  if(refTreeSelection)
+    refTreeSelection->select(iter);
+
+  m_treeview_fields->scroll_to_row( Gtk::TreeModel::Path(iter) );
+
+  treeview_fill_sequences(m_model_fields, m_ColumnsFields.m_col_sequence); //The document should have 
checked this already, but it does not hurt to check again.
+  */
 }
 
 } //namespace Glom
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 614f545..4e0aaef 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_fieldslist.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_fieldslist.cc
@@ -284,80 +284,80 @@ void Dialog_FieldsList::on_cell_data_name(Gtk::CellRenderer* renderer, const Gtk
 {
   //Set the view's cell properties depending on the model's data:
   auto renderer_text = dynamic_cast<Gtk::CellRendererText*>(renderer);
-  if(renderer_text)
-  {
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
+  if(!renderer_text)
+    return;
 
-      std::shared_ptr<const LayoutItem_Field> item = row[m_ColumnsFields.m_col_layout_item]; 
//TODO_performance: Reduce copying.
-      if(item)
-      {
-        renderer_text->property_markup() = item->get_layout_display_name();
-      }
-      else
-      {
-        //Though this really shouldn't even be in the model:
-        renderer_text->property_markup() = Glib::ustring();
-      }
-
-      renderer_text->property_editable() = false; //Names can never be edited.
-    }
+  if(!iter)
+    return;
+
+  Gtk::TreeModel::Row row = *iter;
+
+  std::shared_ptr<const LayoutItem_Field> item = row[m_ColumnsFields.m_col_layout_item]; //TODO_performance: 
Reduce copying.
+  if(item)
+  {
+    renderer_text->property_markup() = item->get_layout_display_name();
+  }
+  else
+  {
+    //Though this really shouldn't even be in the model:
+    renderer_text->property_markup() = Glib::ustring();
   }
+
+  renderer_text->property_editable() = false; //Names can never be edited.
 }
 
 
 void Dialog_FieldsList::on_button_edit_field()
 {
   auto refTreeSelection = m_treeview_fields->get_selection();
-  if(refTreeSelection)
-  {
-    //TODO: Handle multiple-selection:
-    auto iter = refTreeSelection->get_selected();
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
-      std::shared_ptr<const LayoutItem_Field> field = row[m_ColumnsFields.m_col_layout_item];
+  if(!refTreeSelection)
+    return;
 
-      //Get the chosen field:
-      auto field_chosen =
-        offer_field_list_select_one_field(field, m_table_name, this);
+  //TODO: Handle multiple-selection:
+  auto iter = refTreeSelection->get_selected();
+  if(!iter)
+    return;
 
-      //Set the field details in the layout treeview:
-      if(field_chosen)
-        row[m_ColumnsFields.m_col_layout_item] = field_chosen;
+  Gtk::TreeModel::Row row = *iter;
+  std::shared_ptr<const LayoutItem_Field> field = row[m_ColumnsFields.m_col_layout_item];
 
-      //Scroll to, and select, the new row:
-      /*
-      auto refTreeSelection = m_treeview_fields->get_selection();
-      if(refTreeSelection)
-        refTreeSelection->select(iter);
+  //Get the chosen field:
+  auto field_chosen =
+    offer_field_list_select_one_field(field, m_table_name, this);
 
-      m_treeview_fields->scroll_to_row( Gtk::TreeModel::Path(iter) );
+  //Set the field details in the layout treeview:
+  if(field_chosen)
+    row[m_ColumnsFields.m_col_layout_item] = field_chosen;
 
-      treeview_fill_sequences(m_model_fields, m_ColumnsFields.m_col_sequence); //The document should have 
checked this already, but it does not hurt to check again.
-      */
-    }
-  }
+  //Scroll to, and select, the new row:
+  /*
+  auto refTreeSelection = m_treeview_fields->get_selection();
+  if(refTreeSelection)
+    refTreeSelection->select(iter);
+
+  m_treeview_fields->scroll_to_row( Gtk::TreeModel::Path(iter) );
+
+  treeview_fill_sequences(m_model_fields, m_ColumnsFields.m_col_sequence); //The document should have 
checked this already, but it does not hurt to check again.
+  */
 }
 
 void Dialog_FieldsList::on_button_formatting()
 {
   auto refTreeSelection = m_treeview_fields->get_selection();
-  if(refTreeSelection)
+  if(!refTreeSelection)
+    return;
+
+  //TODO: Handle multiple-selection:
+  auto iter = refTreeSelection->get_selected();
+  if(!iter)
+    return;
+
+  Gtk::TreeModel::Row row = *iter;
+  std::shared_ptr<const LayoutItem_Field> field = row[m_ColumnsFields.m_col_layout_item];
+  if(field)
   {
-    //TODO: Handle multiple-selection:
-    auto iter = refTreeSelection->get_selected();
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
-      std::shared_ptr<const LayoutItem_Field> field = row[m_ColumnsFields.m_col_layout_item];
-      if(field)
-      {
-        field = offer_field_formatting(field, m_table_name, this, false /* no editing options */);
-        row[m_ColumnsFields.m_col_layout_item] = field;
-      }
-    }
+    field = offer_field_formatting(field, m_table_name, this, false /* no editing options */);
+    row[m_ColumnsFields.m_col_layout_item] = field;
   }
 }
 
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 9a525b2..91b67a4 100644
--- a/glom/mode_design/layout/layout_item_dialogs/dialog_sortfields.cc
+++ b/glom/mode_design/layout/layout_item_dialogs/dialog_sortfields.cc
@@ -258,53 +258,54 @@ void Dialog_SortFields::on_cell_data_name(Gtk::CellRenderer* renderer, const Gtk
 {
   //Set the view's cell properties depending on the model's data:
   auto renderer_text = dynamic_cast<Gtk::CellRendererText*>(renderer);
-  if(renderer_text)
-  {
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
+  if(!renderer_text)
+    return;
 
-      std::shared_ptr<const LayoutItem_Field> item = row[m_ColumnsFields.m_col_layout_item]; 
//TODO_performance: Reduce copying.
-      renderer_text->property_markup() = item->get_layout_display_name();
-      renderer_text->property_editable() = false; //Names can never be edited.
-    }
-  }
+  if(!iter)
+    return;
+
+  Gtk::TreeModel::Row row = *iter;
+
+  std::shared_ptr<const LayoutItem_Field> item = row[m_ColumnsFields.m_col_layout_item]; //TODO_performance: 
Reduce copying.
+  renderer_text->property_markup() = item->get_layout_display_name();
+  renderer_text->property_editable() = false; //Names can never be edited.
 }
 
 
 void Dialog_SortFields::on_button_edit_field()
 {
   auto refTreeSelection = m_treeview_fields->get_selection();
-  if(refTreeSelection)
-  {
-    //TODO: Handle multiple-selection:
-    auto iter = refTreeSelection->get_selected();
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
-      std::shared_ptr<const LayoutItem_Field> field = row[m_ColumnsFields.m_col_layout_item];
+  if(!refTreeSelection)
+    return;
 
-      //Get the chosen field:
-      auto field_chosen =
-        offer_field_list_select_one_field(field, m_table_name, this);
-      if(field_chosen)
+  //TODO: Handle multiple-selection:
+  auto iter = refTreeSelection->get_selected();
+  if(!iter)
+    return;
 
-      //Set the field details in the layout treeview:
+  Gtk::TreeModel::Row row = *iter;
+  std::shared_ptr<const LayoutItem_Field> field = row[m_ColumnsFields.m_col_layout_item];
 
-      row[m_ColumnsFields.m_col_layout_item] = field_chosen;
+  //Get the chosen field:
+  auto field_chosen =
+    offer_field_list_select_one_field(field, m_table_name, this);
+  if(!field_chosen)
+    return;
 
-      //Scroll to, and select, the new row:
-      /*
-      auto refTreeSelection = m_treeview_fields->get_selection();
-      if(refTreeSelection)
-        refTreeSelection->select(iter);
+  //Set the field details in the layout treeview:
 
-      m_treeview_fields->scroll_to_row( Gtk::TreeModel::Path(iter) );
+  row[m_ColumnsFields.m_col_layout_item] = field_chosen;
 
-      treeview_fill_sequences(m_model_fields, m_ColumnsFields.m_col_sequence); //The document should have 
checked this already, but it does not hurt to check again.
-      */
-    }
-  }
+  //Scroll to, and select, the new row:
+  /*
+  auto refTreeSelection = m_treeview_fields->get_selection();
+  if(refTreeSelection)
+    refTreeSelection->select(iter);
+
+  m_treeview_fields->scroll_to_row( Gtk::TreeModel::Path(iter) );
+
+  treeview_fill_sequences(m_model_fields, m_ColumnsFields.m_col_sequence); //The document should have 
checked this already, but it does not hurt to check again.
+  */
 }
 
 } //namespace Glom
diff --git a/glom/mode_design/report_layout/dialog_layout_report.cc 
b/glom/mode_design/report_layout/dialog_layout_report.cc
index 002cef3..5d18753 100644
--- a/glom/mode_design/report_layout/dialog_layout_report.cc
+++ b/glom/mode_design/report_layout/dialog_layout_report.cc
@@ -954,19 +954,19 @@ void Dialog_Layout_Report::on_cell_data_part(Gtk::CellRenderer* renderer, const
 
   //Set the view's cell properties depending on the model's data:
   auto renderer_text = dynamic_cast<Gtk::CellRendererText*>(renderer);
-  if(renderer_text)
-  {
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
+  if(!renderer_text)
+    return;
 
-      std::shared_ptr<LayoutItem> pItem = row[model->m_columns.m_col_item];
-      const auto part = pItem->get_part_type_name();
+  if(!iter)
+    return;
 
-      renderer_text->property_text() = part;
-      renderer_text->property_editable() = false; //Part names can never be edited.
-    }
-  }
+  Gtk::TreeModel::Row row = *iter;
+
+  std::shared_ptr<LayoutItem> pItem = row[model->m_columns.m_col_item];
+  const auto part = pItem->get_part_type_name();
+
+  renderer_text->property_text() = part;
+  renderer_text->property_editable() = false; //Part names can never be edited.
 }
 
 void Dialog_Layout_Report::on_cell_data_details(Gtk::CellRenderer* renderer, const Gtk::TreeModel::iterator& 
iter, const Glib::WeakRef<type_model>& model_weak)
@@ -977,18 +977,18 @@ void Dialog_Layout_Report::on_cell_data_details(Gtk::CellRenderer* renderer, con
 
   //Set the view's cell properties depending on the model's data:
   auto renderer_text = dynamic_cast<Gtk::CellRendererText*>(renderer);
-  if(renderer_text)
-  {
-    if(iter)
-    {
-      Glib::ustring text;
+  if(!renderer_text)
+    return;
 
-      Gtk::TreeModel::Row row = *iter;
-      std::shared_ptr<LayoutItem> pItem = row[model->m_columns.m_col_item];
-      renderer_text->property_text() = pItem->get_layout_display_name();
-      renderer_text->property_editable() = false;
-    }
-  }
+  if(!iter)
+    return;
+
+  Glib::ustring text;
+
+  Gtk::TreeModel::Row row = *iter;
+  std::shared_ptr<LayoutItem> pItem = row[model->m_columns.m_col_item];
+  renderer_text->property_text() = pItem->get_layout_display_name();
+  renderer_text->property_editable() = false;
 }
 
 
@@ -998,19 +998,19 @@ void Dialog_Layout_Report::on_cell_data_available_part(Gtk::CellRenderer* render
 
   //Set the view's cell properties depending on the model's data:
   auto renderer_text = dynamic_cast<Gtk::CellRendererText*>(renderer);
-  if(renderer_text)
-  {
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
-      auto model = Glib::RefPtr<type_model>::cast_dynamic(m_treeview_available_parts->get_model());
-      std::shared_ptr<LayoutItem> pItem = row[model->m_columns.m_col_item];
-      Glib::ustring part = pItem->get_part_type_name();
+  if(!renderer_text)
+    return;
 
-      renderer_text->property_text() = part;
-      renderer_text->property_editable() = false; //Part names can never be edited.
-    }
-  }
+  if(!iter)
+    return;
+
+  Gtk::TreeModel::Row row = *iter;
+  auto model = Glib::RefPtr<type_model>::cast_dynamic(m_treeview_available_parts->get_model());
+  std::shared_ptr<LayoutItem> pItem = row[model->m_columns.m_col_item];
+  Glib::ustring part = pItem->get_part_type_name();
+
+  renderer_text->property_text() = part;
+  renderer_text->property_editable() = false; //Part names can never be edited.
 }
 
 Glib::ustring Dialog_Layout_Report::get_original_report_name() const
diff --git a/glom/mode_design/translation/window_translations.cc 
b/glom/mode_design/translation/window_translations.cc
index 45e9f85..7c044fd 100644
--- a/glom/mode_design/translation/window_translations.cc
+++ b/glom/mode_design/translation/window_translations.cc
@@ -177,26 +177,26 @@ void Window_Translations::on_cell_data_original(Gtk::CellRenderer* renderer, con
 {
   //Set the view's cell properties depending on the model's data:
   auto renderer_text = dynamic_cast<Gtk::CellRendererText*>(renderer);
-  if(renderer_text)
-  {
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
+  if(!renderer_text)
+    return;
 
-      Glib::ustring text;
-      std::shared_ptr<TranslatableItem> item = row[m_columns.m_col_item];
-      if(item)
-        text = item->get_title_original();
+    if(!iter)
+      return;
 
-      //Use the name if there is no title:
-      if(text.empty())
-        text = item->get_name();
+  Gtk::TreeModel::Row row = *iter;
 
-      //TODO: Mark non-English originals.
-      renderer_text->property_text() = text;
-      renderer_text->property_editable() = false; //Names can never be edited.
-    }
-  }
+  Glib::ustring text;
+  std::shared_ptr<TranslatableItem> item = row[m_columns.m_col_item];
+  if(item)
+    text = item->get_title_original();
+
+  //Use the name if there is no title:
+  if(text.empty())
+    text = item->get_name();
+
+  //TODO: Mark non-English originals.
+  renderer_text->property_text() = text;
+  renderer_text->property_editable() = false; //Names can never be edited.
 }
 
 void Window_Translations::on_cell_data_item_itemhint(Gtk::CellRenderer* renderer, const 
Gtk::TreeModel::iterator& iter)
@@ -263,11 +263,11 @@ void Window_Translations::save_to_document()
   {
     //We have stored a std::shared_ptr to the original item, so we can just change it directly:
     std::shared_ptr<TranslatableItem> item = row[m_columns.m_col_item];
-    if(item)
-    {
-      const Glib::ustring translation = row[m_columns.m_col_translation];
-      item->set_title(translation, m_translation_locale);
-    }
+    if(!item)
+      continue;
+
+    const Glib::ustring translation = row[m_columns.m_col_translation];
+    item->set_title(translation, m_translation_locale);
   }
 
   m_treeview_modified = false;
diff --git a/glom/mode_design/users/dialog_groups_list.cc b/glom/mode_design/users/dialog_groups_list.cc
index f1d303a..059d679 100644
--- a/glom/mode_design/users/dialog_groups_list.cc
+++ b/glom/mode_design/users/dialog_groups_list.cc
@@ -596,17 +596,17 @@ void Dialog_GroupsList::on_cell_data_group_name(Gtk::CellRenderer* renderer, con
 {
  //Set the view's cell properties depending on the model's data:
   auto renderer_text = dynamic_cast<Gtk::CellRendererText*>(renderer);
-  if(renderer_text)
-  {
-    if(iter)
-    {
-      Gtk::TreeModel::Row row = *iter;
+  if(!renderer_text)
+    return;
 
-      Glib::ustring name = row[m_model_columns_groups.m_col_name];
+  if(!iter)
+    return;
 
-      renderer_text->property_text() = Privs::get_user_visible_group_name(name);
-    }
-  }
+  Gtk::TreeModel::Row row = *iter;
+
+  Glib::ustring name = row[m_model_columns_groups.m_col_name];
+
+  renderer_text->property_text() = Privs::get_user_visible_group_name(name);
 }
 
 } //namespace Glom
diff --git a/glom/notebook_glom.cc b/glom/notebook_glom.cc
index 04737ef..eb367c2 100644
--- a/glom/notebook_glom.cc
+++ b/glom/notebook_glom.cc
@@ -64,28 +64,27 @@ void Notebook_Glom::on_switch_page_handler(Gtk::Widget* /* page */)
 
   //Load the page as we enter it:
   auto pChild = get_visible_child();
-  if(pChild)
+  if(!pChild)
+    return;
+
+  auto pBox = dynamic_cast<Box_WithButtons*>(pChild);
+  if(!pBox)
+    return;
+
+  //pBox->load_from_document();
+
+  //Set the default button, if there is one:
+  auto pAppGlom = dynamic_cast<AppWindow*>(pApp);
+  if(!pAppGlom)
+    return;
+
+  if(auto default_button = pBox->get_default_button())
   {
-    auto pBox = dynamic_cast<Box_WithButtons*>(pChild);
-    if(pBox)
-    {
-      //pBox->load_from_document();
-
-      //Set the default button, if there is one:
-      auto pAppGlom = dynamic_cast<AppWindow*>(pApp);
-      if(pAppGlom)
-      {
-        auto default_button = pBox->get_default_button();
-        if(default_button)
-        {
-          default_button->grab_default();
-          pAppGlom->set_default(*default_button);
-        }
-        else
-          pAppGlom->unset_default();
-      }
-    }
+    default_button->grab_default();
+    pAppGlom->set_default(*default_button);
   }
+  else
+    pAppGlom->unset_default();
 }
 
 /* TODO: What this ever necessary?
@@ -100,10 +99,10 @@ void Notebook_Glom::on_leave_page(guint uiPageNumber)
     for(const auto& pChild : get_page_children())
     {
       auto pBox = dynamic_cast<Base_DB*>(pChild);
-      if(pBox)
-      {
-        pBox->save_to_document();
-      }
+      if(!pBox)
+        continue;
+
+      pBox->save_to_document();
     }
   }
 }
@@ -123,8 +122,10 @@ void Notebook_Glom::show_hint()
   if(pChild)
   {
     auto pBox = dynamic_cast<Box_WithButtons*>(pChild);
-    if(pBox)
-      pBox->show_hint();
+    if(!pBox)
+      continue;
+
+    pBox->show_hint();
   }
 }
 */
diff --git a/glom/utility_widgets/adddel/adddel.cc b/glom/utility_widgets/adddel/adddel.cc
index 2cfebd2..3356c3e 100644
--- a/glom/utility_widgets/adddel/adddel.cc
+++ b/glom/utility_widgets/adddel/adddel.cc
@@ -1304,12 +1304,11 @@ void AddDel::on_treeview_columns_changed()
     for(const auto& item : m_tree_view.get_columns())
     {
       auto pViewColumn = dynamic_cast<TreeViewColumnGlom*>(item);
-      if(pViewColumn)
-      {
-        const auto column_id = pViewColumn->get_column_id();
-        m_column_ids.emplace_back(column_id);
+      if(!pViewColumn)
+        continue;
 
-      }
+      const auto column_id = pViewColumn->get_column_id();
+      m_column_ids.emplace_back(column_id);
     }
 
     //Tell other code that something has changed, so the new column order can be serialized.
diff --git a/glom/variablesmap.cc b/glom/variablesmap.cc
index 957496e..ccf50f2 100644
--- a/glom/variablesmap.cc
+++ b/glom/variablesmap.cc
@@ -66,10 +66,10 @@ void VariablesMap::connect_widget(const Glib::ustring& widget_name, double& vari
   m_builder->get_widget(widget_name, pWidget);
 
   auto pScale = dynamic_cast<Gtk::Scale*>(pWidget);
-  if(pScale)
-  {
-    m_mapWidgetsToVariables[pScale] = (void*)(&variable);
-  }
+  if(!pScale)
+    return;
+
+  m_mapWidgetsToVariables[pScale] = (void*)(&variable);
 }
 
 void VariablesMap::connect_widget(const Glib::ustring& widget_name, Glib::Date& variable)
@@ -78,10 +78,10 @@ void VariablesMap::connect_widget(const Glib::ustring& widget_name, Glib::Date&
   m_builder->get_widget(widget_name, pWidget);
 
   auto pCalendar = dynamic_cast<Gtk::Calendar*>(pWidget);
-  if(pCalendar)
-  {
-    m_mapWidgetsToVariables[pCalendar] = (void*)(&variable);
-  }
+  if(!pCalendar)
+    return;
+
+  m_mapWidgetsToVariables[pCalendar] = (void*)(&variable);
 }
 
 void VariablesMap::transfer_widgets_to_variables()


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