[glom] LayoutItem_Field::is_same_field(): Correct regression.



commit d92ab8f839e29a904c567b0d1ec179a5a02c1bd8
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Nov 5 23:11:27 2015 +0100

    LayoutItem_Field::is_same_field(): Correct regression.
    
    Make sure we call UsesRelationship::operator==() instead of
    the class's own operator==(). This regression was caused by my use
    of auto when the actual type mattered.
    
    Added a test for this: test_compare_same_named_instances_unrelated_difference().

 Makefile_tests.am                                  |    6 ++++++
 .../data_structure/layout/layoutitem_field.cc      |    6 ++++--
 2 files changed, 10 insertions(+), 2 deletions(-)
---
diff --git a/Makefile_tests.am b/Makefile_tests.am
index dd339df..cc29d8d 100644
--- a/Makefile_tests.am
+++ b/Makefile_tests.am
@@ -26,6 +26,7 @@ check_PROGRAMS =                                              \
        tests/test_document_change                      \
        tests/test_document_autosave                    \
        tests/test_field_file_format                    \
+       tests/test_layout_item_field \
        tests/test_parsing_time                 \
        tests/test_signal_reemit                        \
        tests/python/test_load_python_library\
@@ -67,6 +68,7 @@ TESTS =       tests/test_document_load        \
        tests/test_document_autosave    \
        tests/test_field_file_format \
        tests/test_field_file_format_in_locales.sh \
+       tests/test_layout_item_field \
        tests/test_parsing_time \
        tests/test_signal_reemit \
        tests/test_dtd_file_validation.sh \
@@ -180,6 +182,10 @@ tests_test_field_file_format_SOURCES = tests/test_field_file_format.cc \
 tests_test_field_file_format_LDADD = $(tests_ldadd) $(GDKMM_LIBS)
 tests_test_field_file_format_CPPFLAGS = $(tests_cppflags)  $(GDKMM_CFLAGS) $(glom_test_image_defines)
 
+tests_test_layout_item_field_SOURCES = tests/test_layout_item_field.cc
+tests_test_layout_item_field_LDADD = $(tests_ldadd)
+tests_test_layout_item_field_CPPFLAGS = $(tests_cppflags)
+
 tests_test_parsing_time_SOURCES = tests/test_parsing_time.cc
 tests_test_parsing_time_LDADD = $(tests_ldadd)
 tests_test_parsing_time_CPPFLAGS = $(tests_cppflags)
diff --git a/glom/libglom/data_structure/layout/layoutitem_field.cc 
b/glom/libglom/data_structure/layout/layoutitem_field.cc
index 17c5e0f..547d6c1 100644
--- a/glom/libglom/data_structure/layout/layoutitem_field.cc
+++ b/glom/libglom/data_structure/layout/layoutitem_field.cc
@@ -339,8 +339,10 @@ void LayoutItem_Field::set_title_custom(const std::shared_ptr<CustomTitle>& titl
 
 bool LayoutItem_Field::is_same_field(const std::shared_ptr<const LayoutItem_Field>& field) const
 {
-  const auto uses_a = this;
-  const auto uses_b = &(*field);
+  //Don't use auto here because we really want to call
+  //UsesRelationship::operator==(), not LayoutItem_Field::operator==().
+  const UsesRelationship* uses_a = this;
+  const UsesRelationship* uses_b = &(*field);
   if(!uses_a || !uses_b)
     return false; //Shouldn't happen.
     


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