On Sat, Feb 23, 2008 at 12:06:18AM +0100, Bernhard Roider wrote:
> hello,
>
> yesterday i played around with layout files and created the following 
> counter definition (ok, i didn't read the docs carefully enough)
>
> Counter
>       Name                 MajorVersion
>       LabelString          "\theMajorVersion.0"
> End
>
> Using this counter causes lyx to crash because of the recursion in the 
> label string. The attached patch catches the recursion and prints a warning 
> message to the console.
>
> ok to commit?
>
> bernhard

> Index: src/Counters.cpp
> ===================================================================
> --- src/Counters.cpp  (revision 23138)
> +++ src/Counters.cpp  (working copy)
> @@ -338,24 +338,51 @@
>  }
>  
>  
> -docstring Counters::theCounter(docstring const & counter)
> +docstring Counters::theCounter(docstring const & counter,
> +                                                        std::set<docstring> 
> * callers)
>  {
>       if (!hasCounter(counter))
>               return from_ascii("??");
>  
> -     Counter const & c = counterList[counter];
> -     docstring ls = appendix() ? c.labelStringAppendix() : c.labelString();
> +     bool owner = false;
> +     if (!callers) {
> +             callers = new std::set<docstring>;
> +             owner = true;
> +     }

Hm... what about

docstring Counters::theCounter(docstring const & counter)
{
         std::set<docstrin> callers;
         return theCounter(counter, callers);
}

docstring Counters::theCounter(docstring const & counter,
        std::set<docstring> & callers)
{
        [...]
}

etc instead of the owner/new/delete logic?

Andre'

Reply via email to