]> git.lyx.org Git - features.git/commitdiff
* src/buffer.C
authorGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 14 Aug 2006 09:33:49 +0000 (09:33 +0000)
committerGeorg Baum <Georg.Baum@post.rwth-aachen.de>
Mon, 14 Aug 2006 09:33:49 +0000 (09:33 +0000)
(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

src/buffer.C
src/buffer.h
src/lyx_main.C

index 367ef539a6d7e2f49abecab5631556642703cd62..fd50d05017a15c08a90aad28b48604d1bcb1ad80 100644 (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
 {
+       static ErrorList const 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 +1714,5 @@ ErrorList const & Buffer::errorList(string const & type) const
 
 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 429d0ac1cc49bf6fe6939850f8295325728abed6..f26e6a6feeba53243bec5ff360882fad8630b41a 100644 (file)
@@ -387,9 +387,6 @@ private:
 
        /// Container for all sort of Buffer dependant errors.
        std::map<std::string, ErrorList> errorLists_;
-
-       /// Empty Error List
-       ErrorList const emptyErrorList_;
 };
 
 #endif
index 9f3dddbb92bd90f8dea0f497ac9fb3b41cc364a6..2cc5eccd161890510b7a2c15b4f523143603b903 100644 (file)
@@ -83,7 +83,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;
@@ -283,15 +282,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);