diff --git a/ChangeLog b/ChangeLog index cbbd459f6..aa0902acc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -17,6 +17,7 @@ - TW-1704 Use Task::identifier to reference the Task in the output - TW-1720 CmdContext uses a mix of both throw and std::cout to convey errors (thanks to Paul Beckingham). +- TW-1723 task info causes segfault (thanks to Roman Golovin). - Fixed broken build for Cygwin and older GCC (thanks to Richard Boß). - The default configuration is now 256-color only. - The 'columns' report now shows whether a column is modifiable or read only. diff --git a/src/Task.cpp b/src/Task.cpp index 53ea53790..b767531ea 100644 --- a/src/Task.cpp +++ b/src/Task.cpp @@ -501,10 +501,9 @@ bool Task::is_dueyear () const bool Task::is_udaPresent () const { for (auto& col : context.columns) - if (col.first.compare (0, 11, "annotation_", 11) != 0) - if (col.second->is_uda () && - has (col.first)) - return true; + if (col.second->is_uda () && + has (col.first)) + return true; return false; } diff --git a/src/commands/CmdInfo.cpp b/src/commands/CmdInfo.cpp index 2c6268408..d3f96aa2f 100644 --- a/src/commands/CmdInfo.cpp +++ b/src/commands/CmdInfo.cpp @@ -362,28 +362,31 @@ int CmdInfo::execute (std::string& output) std::string type; for (auto& att: all) { - Column* col = context.columns[att]; - if (col && col->is_uda ()) + if (context.columns.find (att) != context.columns.end ()) { - std::string value = task.get (att); - if (value != "") + Column* col = context.columns[att]; + if (col->is_uda ()) { - row = view.addRow (); - view.set (row, 0, col->label ()); - - if (type == "date") - value = ISO8601d (value).toString (dateformat); - else if (type == "duration") + std::string value = task.get (att); + if (value != "") { - ISO8601p iso; - std::string::size_type cursor = 0; - if (iso.parse (value, cursor)) - value = (std::string) Variant ((time_t) iso, Variant::type_duration); - else - value = "PT0S"; - } + row = view.addRow (); + view.set (row, 0, col->label ()); - view.set (row, 1, value); + if (type == "date") + value = ISO8601d (value).toString (dateformat); + else if (type == "duration") + { + ISO8601p iso; + std::string::size_type cursor = 0; + if (iso.parse (value, cursor)) + value = (std::string) Variant ((time_t) iso, Variant::type_duration); + else + value = "PT0S"; + } + + view.set (row, 1, value); + } } } } @@ -393,7 +396,7 @@ int CmdInfo::execute (std::string& output) for (auto& att : all) { if (att.substr (0, 11) != "annotation_" && - ! context.columns[att]) + context.columns.find (att) == context.columns.end ()) { row = view.addRow (); view.set (row, 0, "[" + att); diff --git a/src/feedback.cpp b/src/feedback.cpp index 4a413d54a..5a4a5758d 100644 --- a/src/feedback.cpp +++ b/src/feedback.cpp @@ -262,16 +262,19 @@ std::string taskInfoDifferences ( //////////////////////////////////////////////////////////////////////////////// std::string renderAttribute (const std::string& name, const std::string& value, const std::string& format /* = "" */) { - Column* col = context.columns[name]; - if (col && - col->type () == "date" && - value != "") + if (context.columns.find (name) != context.columns.end ()) { - ISO8601d d ((time_t)strtol (value.c_str (), NULL, 10)); - if (format == "") - return d.toString (context.config.get ("dateformat")); + Column* col = context.columns[name]; + if (col && + col->type () == "date" && + value != "") + { + ISO8601d d ((time_t)strtol (value.c_str (), NULL, 10)); + if (format == "") + return d.toString (context.config.get ("dateformat")); - return d.toString (format); + return d.toString (format); + } } return value;