* src/buffer.C

(Buffer::errorList): simplify

	* src/buffer.h
	emptyErrorList_ move to buffer.C and make it static const

	* src/lyx_main.C
	(LyX::exec2): Use for_each instead of for loop


git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@14667 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
Georg Baum 2006-08-14 09:33:49 +00:00
parent 63b5b965df
commit 28ef49f2d9
3 changed files with 6 additions and 21 deletions

View File

@ -1703,9 +1703,10 @@ void Buffer::getSourceCode(ostream & os, lyx::pit_type par_begin, lyx::pit_type
ErrorList const & Buffer::errorList(string const & type) const ErrorList const & Buffer::errorList(string const & type) const
{ {
static ErrorList const emptyErrorList;
std::map<std::string, ErrorList>::const_iterator I = errorLists_.find(type); std::map<std::string, ErrorList>::const_iterator I = errorLists_.find(type);
if (I == errorLists_.end()) if (I == errorLists_.end())
return emptyErrorList_; return emptyErrorList;
return I->second; return I->second;
} }
@ -1713,11 +1714,5 @@ ErrorList const & Buffer::errorList(string const & type) const
ErrorList & Buffer::errorList(string const & type) 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 errorLists_[type];
}
return I->second;
} }

View File

@ -387,9 +387,6 @@ private:
/// Container for all sort of Buffer dependant errors. /// Container for all sort of Buffer dependant errors.
std::map<std::string, ErrorList> errorLists_; std::map<std::string, ErrorList> errorLists_;
/// Empty Error List
ErrorList const emptyErrorList_;
}; };
#endif #endif

View File

@ -83,7 +83,6 @@ namespace fs = boost::filesystem;
using std::endl; using std::endl;
using std::string; using std::string;
using std::vector; using std::vector;
using std::mem_fun_ref;
#ifndef CXX_GLOBAL_CSTD #ifndef CXX_GLOBAL_CSTD
using std::exit; using std::exit;
@ -283,15 +282,9 @@ int LyX::exec2(int & argc, char * argv[])
if (loadLyXFile(buf, s)) { if (loadLyXFile(buf, s)) {
last_loaded = buf; last_loaded = buf;
ErrorList const & el = buf->errorList("Parse"); ErrorList const & el = buf->errorList("Parse");
if (!el.empty()) { if (!el.empty())
// There should be a way to use the following but I (abdel) don't know for_each(el.begin(), el.end(),
// how to make it compile on MSVC2005. boost::bind(&LyX::printError, this, _1));
//for_each(el.begin(), el.end(), mem_fun_ref(&LyX::printError));
for (ErrorList::const_iterator it = el.begin();
it != el.end(); ++it) {
printError(*it);
}
}
} }
else else
bufferlist.release(buf); bufferlist.release(buf);