[Development] Should QObject::event() be protected or public?

apoenitz apoenitz at t-online.de
Fri Mar 15 09:11:19 CET 2024


On Fri, Mar 15, 2024 at 07:16:59AM +0000, Marc Mutz via Development wrote:
> Summary as of 2024-3-14 EOD: QObject::event() has to stay public.

Ok.
 
> Please note that this means that any override (and all new QObject 
> classes should contain one, since, in case we ever need it, it might not 
> be possible to add it after the fact) should also be public.

Neither is a necessary consequence, and I don't think this new rule 
would be helpful.

What kind of setups do you expect where an event() override in the
middle of the inheritance chain needs to be called from outside to
warrant this rule requiring class-implementor to regularly write code
that's unlikely (and I claim: Never) needed?

Please note that this thread was started with the assumption that
not even the base QObject::event() needs to be callable from the outside,
[and also that, in principle, for truly hard cases, one can legally
sneak out of the 'protected' jail via litb's trick using
ISO/EIC 14882:2011 14.7.2(12)]

Andre'

> Thanks,
> Marc
> 
> On 13.03.24 08:58, Marc Mutz via Development wrote:
> > Hi,
> > 
> > In API review, we detected some overrides that changed the access
> > specifier vis-a-vis the original virtual function
> > (https://wiki.qt.io/Things_To_Look_Out_For_In_Reviews#Polymorphic_Classes
> > Item 5.3).
> > 
> > One of them was a protected reimplementation of QObject::event() (which
> > itself is public).
> > 
> > The reason why QObject::event() is public seems lost to history, but the
> > feeling in the review comments¹ was that it should have been protected
> > from the get-go (and QObject befriended by whoever delivers events).
> > 
> > If you see any reason for QObject::event() to stay public in Qt 7 and
> > not become protected, please speak up before we fork Qt 7.0 :)
> > 
> > Thanks,
> > Marc
> > 
> > ¹
> > https://codereview.qt-project.org/c/qt/qtdeclarative/+/528290/comment/f51938ca_fd065a18/
> > 
> -- 
> Marc Mutz <marc.mutz at qt.io>
> Principal Software Engineer
> 
> The Qt Company
> Erich-Thilo-Str. 10 12489
> Berlin, Germany
> www.qt.io
> 
> Geschäftsführer: Mika Pälsi, Juha Varelius, Jouni Lintunen
> Sitz der Gesellschaft: Berlin,
> Registergericht: Amtsgericht Charlottenburg,
> HRB 144331 B
> 
> -- 
> Development mailing list
> Development at qt-project.org
> https://lists.qt-project.org/listinfo/development


More information about the Development mailing list