Author: rgheck
Date: Wed Jun  8 02:44:55 2011
New Revision: 38982
URL: http://www.lyx.org/trac/changeset/38982

Log:
Fix problem with static error list.

It's amazing we haven't seen problems with this before. The basic problem is 
that buf.errorList("whatever") would always return the same global, static 
error list, if it did not already exist. So, to a significant extent, there was 
only one global error list!

Modified:
   lyx-devel/branches/BRANCH_2_0_X/src/Buffer.cpp
   lyx-devel/branches/BRANCH_2_0_X/src/Buffer.h
   lyx-devel/branches/BRANCH_2_0_X/src/frontends/qt4/GuiView.cpp
   lyx-devel/branches/BRANCH_2_0_X/src/insets/InsetInclude.cpp

Modified: lyx-devel/branches/BRANCH_2_0_X/src/Buffer.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/src/Buffer.cpp      Wed Jun  8 02:12:57 
2011        (r38981)
+++ lyx-devel/branches/BRANCH_2_0_X/src/Buffer.cpp      Wed Jun  8 02:44:55 
2011        (r38982)
@@ -3106,9 +3106,9 @@
 }
 
 
-ErrorList & Buffer::errorList(string const & type) const
+ErrorList const & Buffer::errorList(string const & type) const
 {
-       static ErrorList emptyErrorList;
+       static const ErrorList emptyErrorList;
        map<string, ErrorList>::iterator it = d->errorLists.find(type);
        if (it == d->errorLists.end())
                return emptyErrorList;
@@ -3117,6 +3117,12 @@
 }
 
 
+ErrorList & Buffer::errorList(string const & type)
+{
+       return d->errorLists[type];
+}
+
+
 void Buffer::updateTocItem(std::string const & type,
        DocIterator const & dit) const
 {

Modified: lyx-devel/branches/BRANCH_2_0_X/src/Buffer.h
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/src/Buffer.h        Wed Jun  8 02:12:57 
2011        (r38981)
+++ lyx-devel/branches/BRANCH_2_0_X/src/Buffer.h        Wed Jun  8 02:44:55 
2011        (r38982)
@@ -556,7 +556,8 @@
        /// errors (like parsing or LateX compilation). This method is const
        /// because modifying the returned ErrorList does not touch the document
        /// contents.
-       ErrorList & errorList(std::string const & type) const;
+       ErrorList & errorList(std::string const & type);
+       ErrorList const & errorList(std::string const & type) const;
 
        /// The Toc backend.
        /// This is useful only for screen visualisation of the Buffer. This

Modified: lyx-devel/branches/BRANCH_2_0_X/src/frontends/qt4/GuiView.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/src/frontends/qt4/GuiView.cpp       Wed Jun 
 8 02:12:57 2011        (r38981)
+++ lyx-devel/branches/BRANCH_2_0_X/src/frontends/qt4/GuiView.cpp       Wed Jun 
 8 02:44:55 2011        (r38982)
@@ -1451,13 +1451,13 @@
 #if EXPORT_in_THREAD && (QT_VERSION >= 0x040400)
        // We are called with from_master == false by default, so we
        // have to figure out whether that is the case or not.
-       ErrorList & el = bv->buffer().errorList(error_type);
+       ErrorList & el = const_cast<ErrorList 
&>(bv->buffer().errorList(error_type));
        if (el.empty()) {
            el = bv->buffer().masterBuffer()->errorList(error_type);
            from_master = true;
        }
 #else
-       ErrorList & el = from_master ?
+       ErrorList const & el = from_master ?
                bv->buffer().masterBuffer()->errorList(error_type) :
                bv->buffer().errorList(error_type);
 #endif

Modified: lyx-devel/branches/BRANCH_2_0_X/src/insets/InsetInclude.cpp
==============================================================================
--- lyx-devel/branches/BRANCH_2_0_X/src/insets/InsetInclude.cpp Wed Jun  8 
02:12:57 2011        (r38981)
+++ lyx-devel/branches/BRANCH_2_0_X/src/insets/InsetInclude.cpp Wed Jun  8 
02:44:55 2011        (r38982)
@@ -627,7 +627,7 @@
                                        "was not exported correctly.\nWarning: "
                                        "LaTeX export is probably incomplete."),
                                        included_file.displayName());
-                       ErrorList & el = tmp->errorList("Export");
+                       ErrorList const & el = tmp->errorList("Export");
                        if (!el.empty())
                                msg = 
bformat(from_ascii("%1$s\n\n%2$s\n\n%3$s"),
                                                msg, el.begin()->error,

Reply via email to