[Development] HEADS UP: Don't use QList, use Q_DECLARE_TYPEINFO

Curtis Mitch mitch.curtis at theqtcompany.com
Fri Jul 10 12:25:20 CEST 2015


> -----Original Message-----
> From: giuseppe.dangelo at kdab.com [mailto:giuseppe.dangelo at kdab.com]
> Sent: Friday, 10 July 2015 12:22 PM
> To: Curtis Mitch; Smith Martin; development at qt-project.org
> Subject: Re: [Development] HEADS UP: Don't use QList, use
> Q_DECLARE_TYPEINFO
> 
> Il 10/07/2015 12:12, Curtis Mitch ha scritto:
> > How is it binary incompatible?
> 
> Because the code produced by QList<C> (which is inlined) is incompatible
> if C becomes a "good" type (from a "bad" one) or viceversa.
> 
> The code for a "bad" C involves allocating every C object on the heap,
> putting the pointer in the backing array, and dereferencing that pointer
> to get the C back; the code for a "good" C involves putting and
> retrieving C straight into/from the backing array.
> 
> What happens if you have a library which creates a QList<C> assuming C
> to be "bad", and then passes that QList<C> to your app, which assumes C
> to be "good"? This is what happens if you add a typeinfo after you
> forgot.
> 
> Cheers,
> --
> Giuseppe D'Angelo | giuseppe.dangelo at kdab.com | Software Engineer
> KDAB (UK) Ltd., a KDAB Group company | Tel: UK +44-1625-809908
> KDAB - The Qt Experts

Ah, I see. Thank you.


More information about the Development mailing list