Date: prev next · Thread: first prev next last
2015 Archives by date, by thread · List index


Hi Miklos

On Mon, Mar 23, 2015 at 09:54:45AM +0100, Miklos Vajna wrote:
/home/vmiklos/git/libreoffice/master-clang/sw/source/core/doc/docfmt.cxx:657:26: error: c-style 
cast, type=5, from='const sw::WriterListener *', to='SwClient *', recommendedFix=static_cast 
[loplugin:cstylecast]
    while( 0 != ( pDep = (SwClient*)aCallMod.GetDepends()) )
                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

Additional problem is that SwClient now inherits privately from
::sw::WriterListener, so not even a static_cast + const_cast will make
the compiler happy.

Could do const_cast + reinterpret_cast, but it doesn't sound like the
right fix. What is the correct fix here? ;-)

Doing a:

 SwIterator<SwClient,SwModify> aIter(aCallMod);
 for(SwClient* pClient = aIter.First(); pClient; pClient=aIter.Next())
     aCallMod.Remove(pClient);

should work: SwIterator is required to handle removal of Client gracefully (and
there is a unittest for that now). Also, when doing more than a plain
"Remove()", something like a SwIterator<SwFrm,SwModify> etc. takes care of most
of the casting for you internally.

So for now, SwIterator<> should help getting rid of the cast errors: IMHO
GetDepends() is an implementation detail that shouldnt be public anyway.

Best,

Bjoern

Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.