From 50fc0ea9bb03b654f57015ea013728a949ea7d78 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Wed, 8 Jun 2011 00:44:55 +0000 Subject: [PATCH] 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! git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_2_0_X@38982 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 10 ++++++++-- src/Buffer.h | 3 ++- src/frontends/qt4/GuiView.cpp | 4 ++-- src/insets/InsetInclude.cpp | 2 +- 4 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 47c82ccb7e..2df65c2a24 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -3106,9 +3106,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::iterator it = d->errorLists.find(type); if (it == d->errorLists.end()) return emptyErrorList; @@ -3117,6 +3117,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 { diff --git a/src/Buffer.h b/src/Buffer.h index 3da4d224dd..0c99e1feb8 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -556,7 +556,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 diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index e5f7fc6029..2980301776 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -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(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 diff --git a/src/insets/InsetInclude.cpp b/src/insets/InsetInclude.cpp index 628cb00be3..94a996a81e 100644 --- a/src/insets/InsetInclude.cpp +++ b/src/insets/InsetInclude.cpp @@ -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, -- 2.39.5