]> git.lyx.org Git - lyx.git/blobdiff - src/mathed/MacroTable.cpp
installer: further preparation
[lyx.git] / src / mathed / MacroTable.cpp
index 20a713a513e15e1d3af377282e4cfe63d359cfe5..fbcd7e69e578549d1130d99cf67e133c76f3ab4d 100644 (file)
@@ -24,6 +24,7 @@
 #include "Text.h"
 
 #include "support/debug.h"
+#include "support/gettext.h"
 #include "support/lassert.h"
 
 #include <sstream>
@@ -109,7 +110,7 @@ vector<docstring> const &  MacroData::defaults() const
 void MacroData::unlock() const
 {
        --lockCount_;
-       LASSERT(lockCount_ >= 0, /**/);
+       LASSERT(lockCount_ >= 0, lockCount_ = 0);
 }
 
 
@@ -135,7 +136,7 @@ void MacroData::updateData() const
        if (queried_)
                return;
 
-       LASSERT(buffer_ != 0, /**/);
+       LBUFERR(buffer_);
        
        // Try to fix position DocIterator. Should not do anything in theory.
        pos_.fixIfBroken();
@@ -191,20 +192,28 @@ MacroData const * MacroTable::get(docstring const & name) const
 }
 
 
-void MacroTable::insert(docstring const & name, MacroData const & data)
+MacroTable::iterator
+MacroTable::insert(docstring const & name, MacroData const & data)
 {
        //lyxerr << "MacroTable::insert: " << to_utf8(name) << endl;
-       operator[](name) = data;
+       iterator it = find(name);
+       if (it == end())
+               it = map<docstring, MacroData>::insert(
+                               make_pair(name, data)).first;
+       else
+               it->second = data;
+       return it;
 }
 
 
-void MacroTable::insert(Buffer * buf, docstring const & def, string const & requires)
+MacroTable::iterator
+MacroTable::insert(Buffer * buf, docstring const & def, string const & requires)
 {
        //lyxerr << "MacroTable::insert, def: " << to_utf8(def) << endl;
        MathMacroTemplate mac(buf, def);
        MacroData data(buf, mac);
        data.requires() = requires;
-       insert(mac.name(), data);
+       return insert(mac.name(), data);
 }