[Libreoffice] [PATCH] ScGlobal::GetAutoFormat not always required to create fresh instance

Stephan Bergmann sbergman at redhat.com
Mon Jan 9 00:29:13 PST 2012


On 01/07/2012 02:07 AM, Kohei Yoshida wrote:
> Anyway, it's my understanding that the main problem is that the global
> ScAutoFormat instance unintentionally get instantiated in the destructor
> of ScAutoFormatObj during the termination of the cppunit?  In that case,
> what I would do is to add ScGlobal::HasAutoFormat() which simply checks
> whether the instance already exists, and if yes go on ahead and save if
> the flag is set.  When no such instance exists there is no need to save
> stuff anyway (since there is no data to save).
>
> Another advantage of this is that we wouldn't have to modify all the
> code that currently uses GetAutoFormat() expecting it to return a live
> instance at all times, and we could only modify the code in
> ~ScAutoFormatObj().

A new HasAutoFormat (only) called from ~ScAutoFormatObj would of course 
solve the immediate problem, too.

However, whether it actually would be an advantage to not have to 
address the other calls to GetAutoFormat, I am not sure.  After all, 
those calls that afterwards check for null-ness *are* dubious.

Stephan


More information about the LibreOffice mailing list