diff options
author | Andrew den Exter <andrew.den-exter@nokia.com> | 2012-08-23 14:20:47 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-08-24 02:52:30 +0200 |
commit | 19e14d8e2aceb449d3788313165bd371be714a24 (patch) | |
tree | 665d7bbe27645d254cf775c7fb257dfcae0c9313 /src/quick | |
parent | 0853343c33e394f35c31c161b019b2aed17f9256 (diff) |
Fix assert when a VisualDataModels context has been invalidated.
Verify the context is valid before attempting to access its engine. The
context should normally be valid but there is a small window between
a delegate item being released and the DeferredDelete event being
processed when it is not.
Task-number: QTBUG-26949
Change-Id: I79f3affaed8904cbe0974476010b68305666cd29
Reviewed-by: Bea Lam <bea.lam@nokia.com>
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/items/qquickvisualdatamodel.cpp | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/src/quick/items/qquickvisualdatamodel.cpp b/src/quick/items/qquickvisualdatamodel.cpp index e9ac01d712..f98e01e216 100644 --- a/src/quick/items/qquickvisualdatamodel.cpp +++ b/src/quick/items/qquickvisualdatamodel.cpp @@ -847,6 +847,8 @@ QObject *QQuickVisualDataModelPrivate::object(Compositor::Group group, int index if (!m_delegate || index < 0 || index >= m_compositor.count(group)) { qWarning() << "VisualDataModel::item: index out range" << index << m_compositor.count(group); return 0; + } else if (!m_context->isValid()) { + return 0; } Compositor::iterator it = m_compositor.find(group, index); @@ -1376,7 +1378,7 @@ void QQuickVisualDataModelPrivate::emitModelUpdated(const QQuickChangeSet &chang void QQuickVisualDataModelPrivate::emitChanges() { - if (m_transaction || !m_complete) + if (m_transaction || !m_complete || !m_context->isValid()) return; m_transaction = true; @@ -1507,6 +1509,9 @@ QQuickVisualDataModelAttached *QQuickVisualDataModel::qmlAttachedProperties(QObj bool QQuickVisualDataModelPrivate::insert( Compositor::insert_iterator &before, const v8::Local<v8::Object> &object, int groups) { + if (!m_context->isValid()) + return false; + QQuickVisualDataModelItem *cacheItem = m_adaptorModel.createItem(m_cacheMetaType, m_context->engine(), -1); if (!cacheItem) return false; @@ -2275,7 +2280,9 @@ QQmlV8Handle QQuickVisualDataGroup::get(int index) return QQmlV8Handle::fromHandle(v8::Undefined());; QQuickVisualDataModelPrivate *model = QQuickVisualDataModelPrivate::get(d->model); - if (index < 0 || index >= model->m_compositor.count(d->group)) { + if (!model->m_context->isValid()) { + return QQmlV8Handle::fromHandle(v8::Undefined()); + } else if (index < 0 || index >= model->m_compositor.count(d->group)) { qmlInfo(this) << tr("get: index out of range"); return QQmlV8Handle::fromHandle(v8::Undefined()); } |