[Development] QProperty and library coding guide

Thiago Macieira thiago.macieira at intel.com
Wed Jul 22 18:26:45 CEST 2020


On Wednesday, 22 July 2020 08:52:17 PDT Simon Hausmann wrote:
> > On Wednesday, 22 July 2020 00:05:34 PDT Simon Hausmann wrote:
> > > That said, this very construct that you're referring to, that is what
> > > has been in user
> > > code since QtDeclarative was been released [1]. Anybody using
> > > qmlRegisterType() will
> > > up with local template code that does this. It's impact wise as if moc
> > > generated it.
> > 
> > Have you hearad of a Schrödinbug? Not a Heisenbug.
> > 
> > It's a bug that was always there but hurt no one. Until someone noticed
> > it.
> > Now it will keep reappearing all the time.
> 
> Hehe. Maybe it’s more like a SchödinUB 

Anyway, I looked at the code in question and though it is UB, it's also 
optional. It only kicks in if the type being registered multiply-derives from 
one of three helper classes. Most user-registered types don't.

There's also a very simple fix for that. Instead of trying to record the 
offset in the QML type registry, record the pointer to a function that takes a 
pointer to QObject and returns the adjusted pointer to those classes. This 
could have been done in 2010.

-- 
Thiago Macieira - thiago.macieira (AT) intel.com
  Software Architect - Intel DPG Cloud Engineering





More information about the Development mailing list