When a counter is stepped, reset recursively all slaves

Fixes bug #10063.
This commit is contained in:
Jean-Marc Lasgouttes 2016-04-11 12:00:19 +02:00
parent e408c49b2f
commit 8d76be389d
3 changed files with 21 additions and 12 deletions

View File

@ -265,6 +265,19 @@ int Counters::value(docstring const & ctr) const
} }
void Counters::resetSlaves(docstring const & ctr)
{
CounterList::iterator it = counterList_.begin();
CounterList::iterator const end = counterList_.end();
for (; it != end; ++it) {
if (it->second.master() == ctr) {
it->second.reset();
resetSlaves(it->first);
}
}
}
void Counters::step(docstring const & ctr, UpdateType utype) void Counters::step(docstring const & ctr, UpdateType utype)
{ {
CounterList::iterator it = counterList_.find(ctr); CounterList::iterator it = counterList_.find(ctr);
@ -280,13 +293,8 @@ void Counters::step(docstring const & ctr, UpdateType utype)
counter_stack_.pop_back(); counter_stack_.pop_back();
counter_stack_.push_back(ctr); counter_stack_.push_back(ctr);
} }
it = counterList_.begin();
CounterList::iterator const end = counterList_.end(); resetSlaves(ctr);
for (; it != end; ++it) {
if (it->second.master() == ctr) {
it->second.reset();
}
}
} }

View File

@ -128,10 +128,10 @@ public:
void addto(docstring const & ctr, int val); void addto(docstring const & ctr, int val);
/// ///
int value(docstring const & ctr) const; int value(docstring const & ctr) const;
/// Increment by one counter named by arg, and zeroes slave /// Reset recursively all the counters that are slaves of the one named by \c ctr.
void resetSlaves(docstring const & ctr);
/// Increment by one counter named by \c ctr, and zeroes slave
/// counter(s) for which it is the master. /// counter(s) for which it is the master.
/// Sub-slaves are not zeroed! That happens at slave's first
/// step 0->1. Seems to be sufficient.
/// \param utype determines whether we track the counters. /// \param utype determines whether we track the counters.
void step(docstring const & ctr, UpdateType utype); void step(docstring const & ctr, UpdateType utype);
/// Reset all counters, and all the internal data structures /// Reset all counters, and all the internal data structures

View File

@ -45,7 +45,6 @@ What's new
* DOCUMENTATION AND LOCALIZATION * DOCUMENTATION AND LOCALIZATION
- New German translation of the PDF-comment example file. - New German translation of the PDF-comment example file.
@ -154,7 +153,9 @@ What's new
- Fix a crash when introducing a new shortcut (bug 9869). - Fix a crash when introducing a new shortcut (bug 9869).
- Fix initialization oblem with default Inset Layout. - Fix initialization problem with default Inset Layout.
- When a counter is stepped, reset recursively all subcounters (bug #10063).
* INTERNALS * INTERNALS