On 12/02/2010 11:29 AM, Vincent van Ravesteijn wrote:
No, this should never be empty. We specifically push a null pointer onto the
stack at the beginning, as a kind
of dummy entry that makes sure we never pop more than we push. If it is
empty, then we have popped more
than we have pushed.
I don't understand why we do that. We only push&pop in
InsetText::updateBuffer and in Counters::setActiveLayout, but we do it
always one time each.
Right now we do, yes, but I was finding it annoyingly easy to
end up with an empty stack when writing this code. If we do, then
we are going to crash.
And if we should never have an empty layout_stack_, why does the
constructor return an "invalid" object as it doesn't initialize the
layout_stack_ properly.
This constructor should really never be called except when a new
TextClass object is created. Still, I agree that the initialization
should be done in the constructor, too, both for the layout_stack_
and for the counter_stack_.
And why does resetting Counters mean we are only pushing an extra 0
onto the layout_stack_ :S.. ? So we accumulate layouts on the stack if
we reset often. Shouldn't we clear the stack first ?
Yes. As with the counter_stack_. Forgot that one, I guess.
I'll sort some of this out.
Richard