lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] (no subject)


From: Greg Chicares
Subject: [lmi-commits] (no subject)
Date: Sun, 29 May 2016 23:16:41 +0000 (UTC)

branch: master
commit 4e47fc27c876a62bc7e78622f072cfaf3271e962
Author: Vadim Zeitlin <address@hidden>
Date:   Sun May 1 23:56:17 2016 +0200

    Improve calculation summary columns checks [449]
    
    Instead of explicitly excluding "UseBuiltinCalculationSummary" column
    or, worse, rely on member indices to avoid changing this column in
    Load(), just explicitly check that for calculation summary column member
    name before using it as such.
---
 preferences_model.cpp |   22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/preferences_model.cpp b/preferences_model.cpp
index df8f46e..ca8448a 100644
--- a/preferences_model.cpp
+++ b/preferences_model.cpp
@@ -52,6 +52,16 @@ namespace
 // whole issue would vanish.
 
 std::string magic_null_column_name("[none]");
+
+// Check if the given PreferencesModel class member name is one of the
+// calculation summary columns.
+bool is_calculation_summary_column_member(std::string const& member)
+{
+    static char const* summary_column_prefix = "CalculationSummaryColumn";
+    static std::size_t summary_column_prefix_len = 
strlen(summary_column_prefix);
+
+    return member.compare(0, summary_column_prefix_len, summary_column_prefix) 
== 0;
+}
 }
 
 PreferencesModel::PreferencesModel()
@@ -214,11 +224,14 @@ void PreferencesModel::Load()
     bool b = z.use_builtin_calculation_summary();
     UseBuiltinCalculationSummary = b ? "Yes" : "No";
 
-    // TODO ?? CALCULATION_SUMMARY '-1 +' is a poor way of ignoring
-    // 'UseBuiltinCalculationSummary'.
-    for(std::size_t i = 0; i < -1 + member_names().size(); ++i)
+    for(std::size_t i = 0; i < member_names().size(); ++i)
         {
         std::string const& name = member_names()[i];
+
+        if(!is_calculation_summary_column_member(name))
+            {
+            continue;
+            }
         if(columns.size() <= i)
             {
             operator[](name) = magic_null_column_name;
@@ -236,8 +249,7 @@ std::string PreferencesModel::string_of_column_names() const
     std::vector<std::string>::const_iterator i;
     for(i = member_names().begin(); i != member_names().end(); ++i)
         {
-        // TODO ?? CALCULATION_SUMMARY This is poor.
-        if("UseBuiltinCalculationSummary" == *i)
+        if(!is_calculation_summary_column_member(*i))
             {
             continue;
             }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]