diff options
author | Dan Goodliffe <randomdan@akira.random.lan> | 2014-12-01 16:35:01 +0000 |
---|---|---|
committer | Dan Goodliffe <randomdan@akira.random.lan> | 2014-12-01 16:35:01 +0000 |
commit | 076fcee8fe0af97f82db93aa180a2d69d7691047 (patch) | |
tree | 14f8ea8ab8e4db2fc736ca6e17f64812a21695a5 | |
parent | Use char * for logging as it can represent null (diff) | |
download | project2-076fcee8fe0af97f82db93aa180a2d69d7691047.tar.bz2 project2-076fcee8fe0af97f82db93aa180a2d69d7691047.tar.xz project2-076fcee8fe0af97f82db93aa180a2d69d7691047.zip |
Don't cache a pointer to the row state instance, it might move!
-rw-r--r-- | project2/common/variables.cpp | 25 |
1 files changed, 9 insertions, 16 deletions
diff --git a/project2/common/variables.cpp b/project2/common/variables.cpp index 591a03e..d3e7254 100644 --- a/project2/common/variables.cpp +++ b/project2/common/variables.cpp @@ -46,13 +46,16 @@ class VariableParent : public VariableImplDyn { VariableType value(ExecContext * ec) const { try { - if (!getValue) { - if (depth > RowState::Stack().size()) { - throw RowSet::ParentOutOfRange(depth); - } - bind(ec, RowState::Stack()[RowState::Stack().size() - depth]); + if (depth > RowState::Stack().size()) { + throw RowSet::ParentOutOfRange(depth); + } + const auto & row = RowState::Stack()[RowState::Stack().size() - depth]; + if (attr) { + return row->resolveAttr(name)(); + } + else { + return row->getCurrentValue(ec, name); } - return getValue(); } catch (RowSet::ParentOutOfRange) { if (!defaultValue) { @@ -68,19 +71,9 @@ class VariableParent : public VariableImplDyn { } } protected: - void bind(ExecContext * ec, const RowState * row) const - { - if (attr) { - getValue = boost::bind(row->resolveAttr(name)); - } - else { - getValue = boost::bind(&RowState::getCurrentValue, row, ec, name); - } - } const size_t depth; const bool attr; const Glib::ustring name; - mutable boost::function0<VariableType> getValue; }; DECLARE_COMPONENT_LOADER("parent", VariableParent, VariableLoader); |