From 27e27db14758015c4ae732c997227c101602c98b Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Mon, 18 Mar 2013 19:30:17 -0400 Subject: [PATCH 1/4] Add FIXME concerning bug #8599. --- src/insets/InsetRef.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 180abd18c4..0c8e471d5c 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -226,10 +226,15 @@ docstring InsetRef::xhtml(XHTMLStream & xs, OutputParams const &) const display_string = _("elsewhere"); else if (cmd == "eqref") display_string = '(' + value + ')'; - else if (cmd == "formatted" - // we don't really have the ability to handle these - // properly in XHTML output - || cmd == "nameref") + else if (cmd == "formatted") + display_string = il->prettyCounter(); + else if (cmd == "nameref") + // FIXME We don't really have the ability to handle these + // properly in XHTML output yet (bug #8599). + // It might not be that hard to do. We have the InsetLabel, + // and we can presumably find its paragraph using the TOC. + // We could then output the contents of the paragraph using + // something? display_string = il->prettyCounter(); } else display_string = ref; From 2c75ad0294d4cf3698c77020f910e184a60ce5a8 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Mon, 18 Mar 2013 19:32:30 -0400 Subject: [PATCH 2/4] Allowing direct, read-write access to the references cache just seems like a bad idea. --- src/Buffer.cpp | 13 ++++++++++--- src/Buffer.h | 9 ++++++++- src/insets/InsetLabel.cpp | 6 +++--- src/insets/InsetRef.cpp | 2 +- src/mathed/InsetMathRef.cpp | 2 +- 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index 2455b808fb..c6a8c2202b 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -3269,10 +3269,10 @@ void Buffer::listParentMacros(MacroSet & macros, LaTeXFeatures & features) const } -Buffer::References & Buffer::references(docstring const & label) +Buffer::References & Buffer::getReferenceCache(docstring const & label) { if (d->parent()) - return const_cast(masterBuffer())->references(label); + return const_cast(masterBuffer())->getReferenceCache(label); RefCache::iterator it = d->ref_cache_.find(label); if (it != d->ref_cache_.end()) @@ -3288,7 +3288,14 @@ Buffer::References & Buffer::references(docstring const & label) Buffer::References const & Buffer::references(docstring const & label) const { - return const_cast(this)->references(label); + return const_cast(this)->getReferenceCache(label); +} + + +void Buffer::addReference(docstring const & label, Inset * inset, ParIterator it) +{ + References & refs = getReferenceCache(label); + refs.push_back(make_pair(inset, it)); } diff --git a/src/Buffer.h b/src/Buffer.h index cd0540cb7b..e30a09a9c5 100644 --- a/src/Buffer.h +++ b/src/Buffer.h @@ -660,10 +660,15 @@ public: /// typedef std::vector > References; - References & references(docstring const & label); + /// References const & references(docstring const & label) const; + /// + void addReference(docstring const & label, Inset * inset, ParIterator it); + /// void clearReferenceCache() const; + /// void setInsetLabel(docstring const & label, InsetLabel const * il); + /// InsetLabel const * insetLabel(docstring const & label) const; /// return a list of all used branches (also in children) @@ -713,6 +718,8 @@ private: /// mark the buffer as busy exporting something, or not void setExportStatus(bool e) const; + /// + References & getReferenceCache(docstring const & label); /// Change name of buffer. Updates "read-only" flag. void setFileName(support::FileName const & fname); /// diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index c2ef896b86..4dfbc96448 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -109,9 +109,9 @@ void InsetLabel::updateLabelAndRefs(docstring const & new_label, void InsetLabel::updateReferences(docstring const & old_label, docstring const & new_label) { - Buffer::References & refs = buffer().references(old_label); - Buffer::References::iterator it = refs.begin(); - Buffer::References::iterator end = refs.end(); + Buffer::References const & refs = buffer().references(old_label); + Buffer::References::const_iterator it = refs.begin(); + Buffer::References::const_iterator end = refs.end(); for (; it != end; ++it) { buffer().undo().recordUndo(CursorData(it->second)); if (it->first->lyxCode() == MATH_REF_CODE) { diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 0c8e471d5c..42e7fabe1a 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -270,7 +270,7 @@ void InsetRef::updateBuffer(ParIterator const & it, UpdateType) { docstring const & ref = getParam("reference"); // register this inset into the buffer reference cache. - buffer().references(ref).push_back(make_pair(this, it)); + buffer().addReference(ref, this, it); docstring label; for (int i = 0; !types[i].latex_name.empty(); ++i) { diff --git a/src/mathed/InsetMathRef.cpp b/src/mathed/InsetMathRef.cpp index ae1768351c..ef08cbcd3d 100644 --- a/src/mathed/InsetMathRef.cpp +++ b/src/mathed/InsetMathRef.cpp @@ -184,7 +184,7 @@ void InsetMathRef::updateBuffer(ParIterator const & it, UpdateType /*utype*/) return; } // register this inset into the buffer reference cache. - buffer().references(getTarget()).push_back(make_pair(this, it)); + buffer().addReference(getTarget(), this, it); } From fbe9e96b5eac2d2c3748272d63731437e820e782 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Mon, 18 Mar 2013 19:47:17 -0400 Subject: [PATCH 3/4] Make things a little better with respect to bug #8587. Is it possible to figure out the current language from within an InsetRef? If so, how? --- src/insets/InsetRef.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/insets/InsetRef.cpp b/src/insets/InsetRef.cpp index 42e7fabe1a..9bfb3d488c 100644 --- a/src/insets/InsetRef.cpp +++ b/src/insets/InsetRef.cpp @@ -222,8 +222,10 @@ docstring InsetRef::xhtml(XHTMLStream & xs, OutputParams const &) const // normally, would be "ref on page #", but we have no pages display_string = value; else if (cmd == "pageref" || cmd == "vpageref") - // normally would be "on page #", but we have no pages - display_string = _("elsewhere"); + // normally would be "on page #", but we have no pages. + // FIXME this is wrong, as it should be the current language, + // but it is better than _(), which is what we had before. + display_string = buffer().B_("elsewhere"); else if (cmd == "eqref") display_string = '(' + value + ')'; else if (cmd == "formatted") From 6dac777dbc67d8be9ffff098d40560ab638a8923 Mon Sep 17 00:00:00 2001 From: Richard Heck Date: Fri, 8 Mar 2013 18:09:28 -0500 Subject: [PATCH 4/4] Don't try to show the status message if we are busy. Intended to fix #8523. --- src/frontends/qt4/GuiView.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/frontends/qt4/GuiView.cpp b/src/frontends/qt4/GuiView.cpp index bb8da339d4..5983aa199d 100644 --- a/src/frontends/qt4/GuiView.cpp +++ b/src/frontends/qt4/GuiView.cpp @@ -1064,6 +1064,8 @@ void GuiView::updateStatusBar() void GuiView::showMessage() { + if (busy_) + return; QString msg = toqstr(theGuiApp()->viewStatusMessage()); if (msg.isEmpty()) { BufferView const * bv = currentBufferView();