]> git.lyx.org Git - features.git/commitdiff
Fix bug #6315: counters in insets that don't produce output have ghost values.
authorVincent van Ravesteijn <vfr@lyx.org>
Mon, 29 Nov 2010 19:11:38 +0000 (19:11 +0000)
committerVincent van Ravesteijn <vfr@lyx.org>
Mon, 29 Nov 2010 19:11:38 +0000 (19:11 +0000)
git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/trunk@36603 a592a061-630c-0410-9148-cb99ea01b6c8

src/Buffer.cpp
src/Counters.cpp
src/insets/InsetBibitem.cpp
src/insets/InsetFoot.cpp
src/insets/InsetLabel.cpp
src/insets/InsetText.cpp

index b25aea441e6ba354f63fa946a5876a33cc4476f1..cf66a7def965a5c8bfd0ffdac57791ed94cff550 100644 (file)
@@ -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;
index d6865d107d99dd6954b1e4a3d697c7449a2f8acd..d75243e703773e2cfb7b69a01f24e75e9ea3eaf2 100644 (file)
@@ -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);
index eb8e1c7c7751c881ebd8f9dfb213a76f87b68d4c..a685ca0cac1ee36f5ecf34c627cf776bf2ea4325 100644 (file)
@@ -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 {
index 167102313e592b642cb097335451646a1df0540f..500ec44bcf41d9f3ce00b9e6c0ab7b22bec28fce 100644 (file)
@@ -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)
index 3b1560f673f5d5aff6f8bbeb40e618fa7c6d3d74..926297e56fc1a2078502a6e521597b82b5a02c60 100644 (file)
@@ -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("#");
                }
        }
 }
index c73d5103779aa41f28ad357ff60924a856db8a33..429a1510d6a912a9b75f914b0f98cb209cadd615 100644 (file)
@@ -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;
        }