aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickcontainer.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-07-06 11:33:08 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-07-06 11:17:36 +0000
commit7fffd12ab19278ce0f91f490c9070905ec4f2c28 (patch)
treeb352e47cfdfd00d1001d4fd95c6da41fe8b10326 /src/quicktemplates2/qquickcontainer.cpp
parent0f7e202bc638f5b84a5c9f1b2a0ed2710ba83eb1 (diff)
QQuickContainer: use get() instead of QQmlListProperty::data for d-ptr
MSVC2015 has very strange issues with QQmlListProperty::data in release builds. The pointer is somehow lost between constructing the object and when it reaches a list-property function. It's probably somehow related to the qSwap() calls in QQmlObjectCreator::setupBindings(), but this is tricky to investigate, because adding qDebug() output anywhere near the qSwap() calls also makes the problem disappear. It's easier to use the standard Private::get() pattern instead. :) Change-Id: Iaa361f07023820bfe38191a100cebf64fadb4d62 Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickcontainer.cpp')
-rw-r--r--src/quicktemplates2/qquickcontainer.cpp28
1 files changed, 13 insertions, 15 deletions
diff --git a/src/quicktemplates2/qquickcontainer.cpp b/src/quicktemplates2/qquickcontainer.cpp
index eaf18714..a62de655 100644
--- a/src/quicktemplates2/qquickcontainer.cpp
+++ b/src/quicktemplates2/qquickcontainer.cpp
@@ -370,8 +370,8 @@ void QQuickContainerPrivate::itemDestroyed(QQuickItem *item)
void QQuickContainerPrivate::contentData_append(QQmlListProperty<QObject> *prop, QObject *obj)
{
- QQuickContainerPrivate *p = static_cast<QQuickContainerPrivate *>(prop->data);
QQuickContainer *q = static_cast<QQuickContainer *>(prop->object);
+ QQuickContainerPrivate *p = QQuickContainerPrivate::get(q);
QQuickItem *item = qobject_cast<QQuickItem *>(obj);
if (item) {
if (QQuickItemPrivate::get(item)->isTransparentForPositioner())
@@ -385,20 +385,20 @@ void QQuickContainerPrivate::contentData_append(QQmlListProperty<QObject> *prop,
int QQuickContainerPrivate::contentData_count(QQmlListProperty<QObject> *prop)
{
- QQuickContainerPrivate *p = static_cast<QQuickContainerPrivate *>(prop->data);
- return p->contentData.count();
+ QQuickContainer *q = static_cast<QQuickContainer *>(prop->object);
+ return QQuickContainerPrivate::get(q)->contentData.count();
}
QObject *QQuickContainerPrivate::contentData_at(QQmlListProperty<QObject> *prop, int index)
{
- QQuickContainerPrivate *p = static_cast<QQuickContainerPrivate *>(prop->data);
- return p->contentData.value(index);
+ QQuickContainer *q = static_cast<QQuickContainer *>(prop->object);
+ return QQuickContainerPrivate::get(q)->contentData.value(index);
}
void QQuickContainerPrivate::contentData_clear(QQmlListProperty<QObject> *prop)
{
- QQuickContainerPrivate *p = static_cast<QQuickContainerPrivate *>(prop->data);
- p->contentData.clear();
+ QQuickContainer *q = static_cast<QQuickContainer *>(prop->object);
+ return QQuickContainerPrivate::get(q)->contentData.clear();
}
void QQuickContainerPrivate::contentChildren_append(QQmlListProperty<QQuickItem> *prop, QQuickItem *item)
@@ -409,8 +409,8 @@ void QQuickContainerPrivate::contentChildren_append(QQmlListProperty<QQuickItem>
int QQuickContainerPrivate::contentChildren_count(QQmlListProperty<QQuickItem> *prop)
{
- QQuickContainerPrivate *p = static_cast<QQuickContainerPrivate *>(prop->data);
- return p->contentModel->count();
+ QQuickContainer *q = static_cast<QQuickContainer *>(prop->object);
+ return QQuickContainerPrivate::get(q)->contentModel->count();
}
QQuickItem *QQuickContainerPrivate::contentChildren_at(QQmlListProperty<QQuickItem> *prop, int index)
@@ -421,8 +421,8 @@ QQuickItem *QQuickContainerPrivate::contentChildren_at(QQmlListProperty<QQuickIt
void QQuickContainerPrivate::contentChildren_clear(QQmlListProperty<QQuickItem> *prop)
{
- QQuickContainerPrivate *p = static_cast<QQuickContainerPrivate *>(prop->data);
- p->contentModel->clear();
+ QQuickContainer *q = static_cast<QQuickContainer *>(prop->object);
+ return QQuickContainerPrivate::get(q)->contentModel->clear();
}
QQuickContainer::QQuickContainer(QQuickItem *parent)
@@ -623,8 +623,7 @@ QVariant QQuickContainer::contentModel() const
*/
QQmlListProperty<QObject> QQuickContainer::contentData()
{
- Q_D(QQuickContainer);
- return QQmlListProperty<QObject>(this, d,
+ return QQmlListProperty<QObject>(this, nullptr,
QQuickContainerPrivate::contentData_append,
QQuickContainerPrivate::contentData_count,
QQuickContainerPrivate::contentData_at,
@@ -647,8 +646,7 @@ QQmlListProperty<QObject> QQuickContainer::contentData()
*/
QQmlListProperty<QQuickItem> QQuickContainer::contentChildren()
{
- Q_D(QQuickContainer);
- return QQmlListProperty<QQuickItem>(this, d,
+ return QQmlListProperty<QQuickItem>(this, nullptr,
QQuickContainerPrivate::contentChildren_append,
QQuickContainerPrivate::contentChildren_count,
QQuickContainerPrivate::contentChildren_at,