The branch, cleanup/updateMacros3, has been updated. - Log -----------------------------------------------------------------
commit d51aa94b67bdda9ddaaf43020598b78e39815906 Author: Richard Kimberly Heck <[email protected]> Date: Wed Nov 11 22:47:57 2020 -0500 Redo the getMacroDefinitions routine. diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 1901264..859f9ce 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -215,14 +215,15 @@ public: typedef map<DocIterator, MacroDefinition> MacroDefList; typedef map<docstring, MacroDefList> MacroMap; - pair<bool, MacroDefList const &> getMacroDefinitions(docstring const & name) const + bool haveMacro(docstring const & name) const + { return macro_map_.count(name) != 0; } + + // Will assert if there is no such macro, so call haveMacro first! + MacroDefList const & getMacroDefinitions(docstring const & name) const { MacroMap::const_iterator it = macro_map_.find(name); - if (it == macro_map_.end()) { - static MacroDefList dummy; - return {false, dummy}; - } - return {true, it->second}; + LBUFERR(it != macro_map_.end()); + return it->second; } set<docstring> getMacroNames() const @@ -3634,10 +3635,9 @@ MacroData const * Buffer::Impl::getBufferMacro(docstring const & name, MacroData const * bestData = nullptr; // find macro definitions for name - pair<bool, MacroTable::MacroDefList const &> mdl_pair = - macro_table.getMacroDefinitions(name); - if (mdl_pair.first) { - MacroTable::MacroDefList const & mdl = mdl_pair.second; + if (macro_table.haveMacro(name)) { + MacroTable::MacroDefList const & mdl = + macro_table.getMacroDefinitions(name); // find last definition in front of pos MacroTable::MacroDefList::const_iterator it = greatest_below(mdl, pos); @@ -3748,8 +3748,10 @@ MacroData const * Buffer::getMacro(docstring const & name, { // look where the child buffer is included first Impl::BufferPositionMap::iterator it = d->children_positions.find(&child); - if (it == d->children_positions.end()) + if (it == d->children_positions.end()) { + LYXERR0("Querying parent for macro when we are not a child!"); return nullptr; + } // check for macros at the inclusion position return getMacro(name, it->second, global); ----------------------------------------------------------------------- Summary of changes: src/Buffer.cpp | 24 +++++++++++++----------- 1 files changed, 13 insertions(+), 11 deletions(-) hooks/post-receive -- Repository for new features -- lyx-cvs mailing list [email protected] http://lists.lyx.org/mailman/listinfo/lyx-cvs
