[patch] KConfig: Efficient iterators

Matthias Kretz kretz at kde.org
Wed Apr 23 14:15:27 BST 2008


On Tuesday 22 April 2008, Thiago Macieira wrote:
> Declaring a type to be movable *could* be binary incompatible. It depends
> on whether the type is also large (> sizeof(void*)) or not. The breakage
> happens in QList because a movable type that fits inside a void* gets
> allocated inside the QList internal array itself, doing away with an
> extra allocation per item in the list.
>
> We caught this issue in QSharedDataPointer and
> QExplicitlySharedDataPointer. We tried to do the right thing and make it
> movable, but that broke KDE code that was using those classes in a way
> that wasn't intended.

AFAIR all that is needed to break BC is to have

An app, compiled against old version without Q_MOVABLE_TYPE either create a 
QList/QVector and hand it to libx or get a QList/QVector created by libx, 
where libx is a library compiled against the new version with Q_MOVABLE_TYPE 
set.

example:

lib:
struct Foo
{
  int x;
};

//in new version add: Q_DECLARE_TYPEINFO(Foo, Q_MOVABLE_TYPE)

QList<Foo> bar();



app:
main()
{
  int a = 0;
  foreach(const Foo &f, bar()) {
    a += f.x;
  }
}


I recommend to use Q_DECLARE_TYPEINFO(Foo, Q_MOVABLE_TYPE) only for new types 
(first release) or for internal types. Everything else is dangerous.

-- 
________________________________________________________
Matthias Kretz (Germany)                            <><
http://Vir.homelinux.org/
MatthiasKretz at gmx.net, kretz at kde.org,
Matthias.Kretz at urz.uni-heidelberg.de
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20080423/3eaefbac/attachment.sig>


More information about the kde-core-devel mailing list