SwFormat::DerviedFrom()

Markus Mohrhard markus.mohrhard at googlemail.com
Sun Jan 3 01:43:05 PST 2016


Hey

On Sun, Jan 3, 2016 at 9:20 AM, Chris Sherlock <chris.sherlock79 at gmail.com>
wrote:

> Hi all,
>
> I’ve been getting an OSL_ENSURE failure when I run LibreOffice on my
> Ubuntu Linux VM.
>
> The error is:
>
> warn:legacy.osl:25546:1:sw/source/core/attr/format.cxx:227:
> SwFormat::~SwFormat: Def dependents!
>
> This appears to be occuring because the OSL_ENSURE is calling on
> DerivedFrom(), which actually returns the following:
>
> *return* const_cast <http://opengrok.libreoffice.org/s?defs=const_cast&project=core><SwFormat <http://opengrok.libreoffice.org/xref/core/sw/inc/format.hxx#SwFormat>*>(static_cast <http://opengrok.libreoffice.org/s?defs=static_cast&project=core><*const* SwFormat <http://opengrok.libreoffice.org/xref/core/sw/inc/format.hxx#SwFormat>*>(GetRegisteredIn <http://opengrok.libreoffice.org/s?defs=GetRegisteredIn&project=core>()));
>
>
> GetRegisteredIn() is just an event source of type SwModify, the odd thing
> is that it calls on GetRegistedIn() which is NOT a member of SwModify (or
> any child classes).
>
> In fact, I’m surprised that this even compiles, as I was under the
> impression that a static_cast was a compile time check...
>

I can only help you with the C++ part but not explain why it makes sense to
call that code.

The code calls SwFormat::GetRegisteredIn which is actually
SwClient::GetRegisteredIn (through the inheritance hierarchy
SwFormat->SwModify->SwClient). SwClient::GetRegisteredIn returns a pointer
to a SwModify where the code actually assumes that it always returns a
SwFormat.


>
> http://opengrok.libreoffice.org/xref/core/sw/inc/format.hxx#110
>
> Anyway, what *exactly* is this attempting to do? The name looks like it’s
> doing a debugging check to ensure that the SwFormat class was registered in
> a derived class, but I can’t see how this would ever work!
>


It looks a bit like it is using some generic writer code to store the
inheritance of the styles.


>
> In fact, wouldn’t a dynamic_cast be better, as this most specifically down
> or upcasts a pointer, and returns NULL if it fails?
>

That depends on all the code around it. Here the code just assumes that all
returned SwModify objects are actually SwFormat objects.


>
> Any advise on this would be greatly appreciated, got me thoroughly
> tricked...
>
> Chris
>
> _______________________________________________
> LibreOffice mailing list
> LibreOffice at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/libreoffice
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/libreoffice/attachments/20160103/dcfc07bc/attachment.html>


More information about the LibreOffice mailing list