Am Sonntag, 13. August 2006 18:18 schrieb Abdelrazak Younes: > I have comitted the patch.
I noticed two things while resolving merge conflicts (I did not look at the patch because I don't understand enough of the errorlist business): a) The nonconst Buffer::errorList can be shortened a lot, and the empty error list can be made static and can go to the .C file (better because it does not belong to the interface) b) the for_each construct works with boost::bind, we use this at other places. mem_fun_ref calls a member function of the container element, but what we need is a member function of the LyX class. Does this work for you, too? Georg
Index: src/buffer.C =================================================================== --- src/buffer.C (Revision 14657) +++ src/buffer.C (Arbeitskopie) @@ -1698,9 +1868,10 @@ void Buffer::getSourceCode(ostream & os, ErrorList const & Buffer::errorList(string const & type) const { + static const ErrorList emptyErrorList; std::map<std::string, ErrorList>::const_iterator I = errorLists_.find(type); if (I == errorLists_.end()) - return emptyErrorList_; + return emptyErrorList; return I->second; } @@ -1713,11 +1887,5 @@ ErrorList const & Buffer::errorList(stri ErrorList & Buffer::errorList(string const & type) { - std::map<std::string, ErrorList>::iterator I = errorLists_.find(type); - if (I == errorLists_.end()) { - errorLists_[type] = emptyErrorList_; - return errorLists_[type]; - } - - return I->second; + return errorLists_[type]; } Index: src/buffer.h =================================================================== --- src/buffer.h (Revision 14657) +++ src/buffer.h (Arbeitskopie) @@ -387,9 +394,6 @@ private: /// Container for all sort of Buffer dependant errors. std::map<std::string, ErrorList> errorLists_; - - /// Empty Error List - ErrorList const emptyErrorList_; }; #endif Index: src/lyx_main.C =================================================================== --- src/lyx_main.C (Revision 14657) +++ src/lyx_main.C (Arbeitskopie) @@ -83,7 +86,6 @@ namespace fs = boost::filesystem; using std::endl; using std::string; using std::vector; -using std::mem_fun_ref; #ifndef CXX_GLOBAL_CSTD using std::exit; @@ -275,15 +279,9 @@ int LyX::exec2(int & argc, char * argv[] if (loadLyXFile(buf, s)) { last_loaded = buf; ErrorList const & el = buf->errorList("Parse"); - if (!el.empty()) { - // There should be a way to use the following but I (abdel) don't know - // how to make it compile on MSVC2005. - //for_each(el.begin(), el.end(), mem_fun_ref(&LyX::printError)); - for (ErrorList::const_iterator it = el.begin(); - it != el.end(); ++it) { - printError(*it); - } - } + if (!el.empty()) + for_each(el.begin(), el.end(), + boost::bind(&LyX::printError, this, _1)); } else bufferlist.release(buf);