]> git.lyx.org Git - features.git/commitdiff
Fix problem with static error list.
authorRichard Heck <rgheck@comcast.net>
Wed, 8 Jun 2011 00:12:52 +0000 (00:12 +0000)
committerRichard Heck <rgheck@comcast.net>
Wed, 8 Jun 2011 00:12:52 +0000 (00:12 +0000)
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!

git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@38980 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/Buffer.h
src/frontends/qt4/GuiView.cpp
src/insets/InsetInclude.cpp

index 117cfe0ca7e5ba5ec100d56e2670635a16f1fe11..f7b91a682de8e40e5d38e2d84da3bf4514f20e2c 100644 (file)
@@ -3154,9 +3154,9 @@ void Buffer::getSourceCode(odocstream & os, string const format,
 }
 
 
-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;
@@ -3165,6 +3165,12 @@ ErrorList & Buffer::errorList(string const & type) const
 }
 
 
+ErrorList & Buffer::errorList(string const & type)
+{
+       return d->errorLists[type];
+}
+
+
 void Buffer::updateTocItem(std::string const & type,
        DocIterator const & dit) const
 {
index 9701f319132aed6e1ed65f9d854ff1a0f1248ed1..1aeb66fe066b4a73cfdba7a27fc91e85313c8563 100644 (file)
@@ -562,7 +562,8 @@ public:
        /// 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
index 15e05fd04c042bcfbe62ef2f7527f58a9bda5c95..90ed2fbe36f59f4593fac24bd08eb5724e2cbc43 100644 (file)
@@ -1451,13 +1451,13 @@ void GuiView::errors(string const & error_type, bool from_master)
 #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
index 628cb00be31b421837ef16d98d0b2dcf6a2f4ca1..94a996a81edf5c16dd607776bc6be1fd8c15c3bb 100644 (file)
@@ -627,7 +627,7 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                                        "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,