Accidentally exported private classes

Volker Krause vkrause at kde.org
Mon Aug 10 11:23:05 UTC 2015


On Monday 10 August 2015 13:06:29 David Faure wrote:
> On Monday 10 August 2015 11:47:43 Volker Krause wrote:
> > Hi,
> > 
> > it turns out KF5 (and PIM, which is where I started looking into this)
> > have
> > quite some unintentionally exported private symbols (2000+ for PIM and the
> > KF5 subset used by it, I'd not entirely trust the tool yet though ;) ).
> > 
> > This is mainly caused by using nested private classes, those inherit the
> > visibility from their outer class:
> > 
> > class FOO_EXPORT Foo {
> > 
> >   class Private;
> > 
> > };
> > 
> > Foo::Private is also exported by default in this case.
> > 
> > This is easy to fix by explicitly hiding the private class (by adding
> > Q_DECL_HIDDEN to its declaration).
> 
> Good catch. I assume this doesn't happen in Qt because it always says "class
> FooPrivate" rather than "class Foo::Private"?

Right, then you have just another top-level class, and the default visibility 
is hidden as one would expect.

> Maybe we should move towards that too, for consistency with Qt, and to
> reduce risks (someone might copy "class Private;" from an existing header
> and forget to copy the Q_DECL_HIDDEN).

Yep, and there are more reasons for not using nested classes for this and 
following the Qt scheme instead, such as the Q_D/Q_Q macros for example.

For existing code it is however a quite substantial (although not particularly 
hard) change, I'm not sure if this is worth the effort, compared to the 
Q_DECL_HIDDEN approach.

> > I've started doing this in PIM code that
> > isn't covered by BC guarantees yet. Do we also want this to be done in
> > already released frameworks, although it is technically BIC?
> 
> Classes called "*Private" are not part of our BIC promises.

Ok, then I'll fix this in KF5 as well. Do you want individual review requests 
for these changes or can I just push those directly?

regards,
Volker
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 173 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-frameworks-devel/attachments/20150810/13b4f3ff/attachment.sig>


More information about the Kde-frameworks-devel mailing list