summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2010-02-03 05:52:28 (GMT)
committerMartin Jones <martin.jones@nokia.com>2010-02-03 05:52:28 (GMT)
commit4c288190000ea6c9f7148d44e8e12d882256e217 (patch)
treecd6972dcdb9289adb7d653205e9f94b391395e01 /src/declarative/graphicsitems
parentfb6cf75abfae111ab2a1c968ffd0c9b707109b10 (diff)
downloadQt-4c288190000ea6c9f7148d44e8e12d882256e217.zip
Qt-4c288190000ea6c9f7148d44e8e12d882256e217.tar.gz
Qt-4c288190000ea6c9f7148d44e8e12d882256e217.tar.bz2
Avoid crash on shutdown if model is destroyed before view.
Diffstat (limited to 'src/declarative/graphicsitems')
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview.cpp10
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp6
2 files changed, 10 insertions, 6 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
index 890d3ad..7105300 100644
--- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
@@ -151,7 +151,7 @@ class QmlGraphicsGridViewPrivate : public QmlGraphicsFlickablePrivate
public:
QmlGraphicsGridViewPrivate()
- : model(0), currentItem(0), flow(QmlGraphicsGridView::LeftToRight)
+ : currentItem(0), flow(QmlGraphicsGridView::LeftToRight)
, visiblePos(0), visibleIndex(0) , currentIndex(-1)
, cellWidth(100), cellHeight(100), columns(1), requestedIndex(-1)
, highlightComponent(0), highlight(0), trackedItem(0)
@@ -307,7 +307,7 @@ public:
}
}
- QmlGraphicsVisualModel *model;
+ QGuard<QmlGraphicsVisualModel> model;
QVariant modelVariant;
QList<FxGridItem*> visibleItems;
QHash<QmlGraphicsItem*,int> unrequestedItems;
@@ -350,6 +350,7 @@ void QmlGraphicsGridViewPrivate::init()
void QmlGraphicsGridViewPrivate::clear()
{
+ qDebug() << "clearing items" << visibleItems.count();
for (int i = 0; i < visibleItems.count(); ++i)
releaseItem(visibleItems.at(i));
visibleItems.clear();
@@ -384,13 +385,16 @@ FxGridItem *QmlGraphicsGridViewPrivate::createItem(int modelIndex)
void QmlGraphicsGridViewPrivate::releaseItem(FxGridItem *item)
{
Q_Q(QmlGraphicsGridView);
- if (!item)
+ if (!item || !model)
return;
if (trackedItem == item) {
QObject::disconnect(trackedItem->item, SIGNAL(yChanged()), q, SLOT(trackedPositionChanged()));
QObject::disconnect(trackedItem->item, SIGNAL(xChanged()), q, SLOT(trackedPositionChanged()));
trackedItem = 0;
}
+ qDebug() << "release" << item;
+ qDebug() << " item" << item->item;
+ qDebug() << " model" << model;
if (model->release(item->item) == 0) {
// item was not destroyed, and we no longer reference it.
unrequestedItems.insert(item->item, model->indexOf(item->item, q));
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index ad0aa04..8fb7c84 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -210,7 +210,7 @@ class QmlGraphicsListViewPrivate : public QmlGraphicsFlickablePrivate, private Q
public:
QmlGraphicsListViewPrivate()
- : model(0), currentItem(0), orient(QmlGraphicsListView::Vertical)
+ : currentItem(0), orient(QmlGraphicsListView::Vertical)
, visiblePos(0), visibleIndex(0)
, averageSize(100.0), currentIndex(-1), requestedIndex(-1)
, highlightRangeStart(0), highlightRangeEnd(0)
@@ -495,7 +495,7 @@ public:
virtual void flickX(qreal velocity);
virtual void flickY(qreal velocity);
- QmlGraphicsVisualModel *model;
+ QGuard<QmlGraphicsVisualModel> model;
QVariant modelVariant;
QList<FxListItem*> visibleItems;
QHash<QmlGraphicsItem*,int> unrequestedItems;
@@ -615,7 +615,7 @@ FxListItem *QmlGraphicsListViewPrivate::createItem(int modelIndex)
void QmlGraphicsListViewPrivate::releaseItem(FxListItem *item)
{
Q_Q(QmlGraphicsListView);
- if (!item)
+ if (!item || !model)
return;
if (trackedItem == item) {
const char *notifier1 = orient == QmlGraphicsListView::Vertical ? SIGNAL(yChanged()) : SIGNAL(xChanged());