From 5eb7add4092708a5a0dbabf303164be624aff72f Mon Sep 17 00:00:00 2001 From: Vincent van Ravesteijn Date: Mon, 29 Nov 2010 19:11:38 +0000 Subject: [PATCH] Fix bug #6315: counters in insets that don't produce output have ghost values. git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36603 a592a061-630c-0410-9148-cb99ea01b6c8 --- src/Buffer.cpp | 10 +++++----- src/Counters.cpp | 6 +++--- src/insets/InsetBibitem.cpp | 5 +++-- src/insets/InsetFoot.cpp | 16 +++++++++------- src/insets/InsetLabel.cpp | 4 ++-- src/insets/InsetText.cpp | 1 + 6 files changed, 23 insertions(+), 19 deletions(-) diff --git a/src/Buffer.cpp b/src/Buffer.cpp index b25aea441e..cf66a7def9 100644 --- a/src/Buffer.cpp +++ b/src/Buffer.cpp @@ -3978,11 +3978,11 @@ void Buffer::Impl::setLabel(ParIterator & it, UpdateType utype) const switch(layout.labeltype) { case LABEL_COUNTER: if (layout.toclevel <= bp.secnumdepth - && (layout.latextype != LATEX_ENVIRONMENT - || it.text()->isFirstInSequence(it.pit()))) { - counters.step(layout.counter, utype); - par.params().labelString( - par.expandLabel(layout, bp)); + && (layout.latextype != LATEX_ENVIRONMENT + || it.text()->isFirstInSequence(it.pit()))) { + if (counters.hasCounter(layout.counter)) + counters.step(layout.counter, utype); + par.params().labelString(par.expandLabel(layout, bp)); } else par.params().labelString(docstring()); break; diff --git a/src/Counters.cpp b/src/Counters.cpp index d6865d107d..d75243e703 100644 --- a/src/Counters.cpp +++ b/src/Counters.cpp @@ -436,7 +436,7 @@ docstring Counters::theCounter(docstring const & counter, { CounterList::const_iterator it = counterList_.find(counter); if (it == counterList_.end()) - return from_ascii("??"); + return from_ascii("#"); Counter const & ctr = it->second; Counter::StringMap & sm = ctr.flatLabelStrings(appendix()); Counter::StringMap::iterator smit = sm.find(lang); @@ -468,7 +468,7 @@ docstring Counters::flattenLabelString(docstring const & counter, CounterList::const_iterator it = counterList_.find(counter); if (it == counterList_.end()) - return from_ascii("??"); + return from_ascii("#"); Counter const & c = it->second; docstring ls = translateIfPossible(c.labelString(in_appendix), lang); @@ -550,7 +550,7 @@ docstring Counters::prettyCounter(docstring const & name, { CounterList::const_iterator it = counterList_.find(name); if (it == counterList_.end()) - return from_ascii("??"); + return from_ascii("#"); Counter const & ctr = it->second; docstring const value = theCounter(name, lang); diff --git a/src/insets/InsetBibitem.cpp b/src/insets/InsetBibitem.cpp index eb8e1c7c77..a685ca0cac 100644 --- a/src/insets/InsetBibitem.cpp +++ b/src/insets/InsetBibitem.cpp @@ -326,8 +326,9 @@ void InsetBibitem::updateBuffer(ParIterator const & it, UpdateType utype) BufferParams const & bp = buffer().masterBuffer()->params(); Counters & counters = bp.documentClass().counters(); docstring const bibitem = from_ascii("bibitem"); - if (counters.hasCounter(bibitem) && getParam("label").empty()) { - counters.step(bibitem, utype); + if (getParam("label").empty()) { + if (counters.hasCounter(bibitem)) + counters.step(bibitem, utype); string const & lang = it.paragraph().getParLanguage(bp)->code(); autolabel_ = counters.theCounter(bibitem, lang); } else { diff --git a/src/insets/InsetFoot.cpp b/src/insets/InsetFoot.cpp index 167102313e..500ec44bcf 100644 --- a/src/insets/InsetFoot.cpp +++ b/src/insets/InsetFoot.cpp @@ -45,13 +45,15 @@ void InsetFoot::updateBuffer(ParIterator const & it, UpdateType utype) cnts.saveLastCounter(); } Paragraph const & outer = it.paragraph(); - InsetLayout const & il = getLayout(); - docstring const & count = il.counter(); - if (!outer.layout().intitle && cnts.hasCounter(count)) { - cnts.step(count, utype); - custom_label_= translateIfPossible(il.labelstring()) - + ' ' + cnts.theCounter(count, outer.getParLanguage(bp)->code()); - setLabel(custom_label_); + if (!outer.layout().intitle) { + InsetLayout const & il = getLayout(); + docstring const & count = il.counter(); + custom_label_ = translateIfPossible(il.labelstring()) + ' '; + if (cnts.hasCounter(count)) + cnts.step(count, utype); + custom_label_ += + cnts.theCounter(count, outer.getParLanguage(bp)->code()); + setLabel(custom_label_); } InsetCollapsable::updateBuffer(it, utype); if (utype == OutputUpdate) diff --git a/src/insets/InsetLabel.cpp b/src/insets/InsetLabel.cpp index 3b1560f673..926297e56f 100644 --- a/src/insets/InsetLabel.cpp +++ b/src/insets/InsetLabel.cpp @@ -135,8 +135,8 @@ void InsetLabel::updateBuffer(ParIterator const & par, UpdateType utype) counter_value_ = cnts.theCounter(active_counter_, lang->code()); pretty_counter_ = cnts.prettyCounter(active_counter_, lang->code()); } else { - counter_value_ = from_ascii("??"); - pretty_counter_ = from_ascii("??"); + counter_value_ = from_ascii("#"); + pretty_counter_ = from_ascii("#"); } } } diff --git a/src/insets/InsetText.cpp b/src/insets/InsetText.cpp index c73d510377..429a1510d6 100644 --- a/src/insets/InsetText.cpp +++ b/src/insets/InsetText.cpp @@ -659,6 +659,7 @@ void InsetText::updateBuffer(ParIterator const & it, UpdateType utype) // tclass.counters().clearLastLayout() // since we are saving and restoring the existing counters, etc. Counters const savecnt = tclass.counters(); + tclass.counters() = Counters(); buffer().updateBuffer(it2, utype); tclass.counters() = savecnt; } -- 2.39.2