Skip to content

Commit

Permalink
Get rid of QDeclarativeMetaType::{canCopy,copy}
Browse files Browse the repository at this point in the history
Now that we have QMetaType::construct() that does placement new
construction, we can use that to copy the value.

We need to destruct the (default-constructed) existing value first,
but for primitive types that's a no-op, and for Qt's types it's
cheap since they use lazy initialization or "shared null".

Change-Id: Idadee04b1d5b590be7fec50fb0396fd277bee973
Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
  • Loading branch information
Kent Hansen authored and Qt by Nokia committed Dec 9, 2011
1 parent 3cfee36 commit f641618
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 747 deletions.
21 changes: 7 additions & 14 deletions src/declarative/qml/qdeclarativeboundsignal.cpp
Expand Up @@ -252,15 +252,9 @@ QDeclarativeBoundSignalParameters::QDeclarativeBoundSignalParameters(const QMeta
}
}
}
if (QDeclarativeMetaType::canCopy(t)) {
types[ii] = t;
QMetaPropertyBuilder prop = mob.addProperty(name, propType);
prop.setWritable(false);
} else {
types[ii] = 0x80000000 | t;
QMetaPropertyBuilder prop = mob.addProperty(name, "QVariant");
prop.setWritable(false);
}
types[ii] = t;
QMetaPropertyBuilder prop = mob.addProperty(name, propType);
prop.setWritable(false);
}
}
myMetaObject = mob.toMetaObject();
Expand Down Expand Up @@ -291,11 +285,10 @@ int QDeclarativeBoundSignalParameters::metaCall(QMetaObject::Call c, int id, voi
return -1;

if (c == QMetaObject::ReadProperty && id >= 1) {
if (types[id - 1] & 0x80000000) {
*((QVariant *)a[0]) = QVariant(types[id - 1] & 0x7FFFFFFF, values[id]);
} else {
QDeclarativeMetaType::copy(types[id - 1], a[0], values[id]);
}
int t = types[id - 1];
void *p = a[0];
QMetaType::destruct(t, p);
QMetaType::construct(t, p, values[id]);
return -1;
} else {
return qt_metacall(c, id, a);
Expand Down

0 comments on commit f641618

Please sign in to comment.