diff options
author | Qt Continuous Integration System <qt-info@nokia.com> | 2010-10-21 11:51:06 (GMT) |
---|---|---|
committer | Qt Continuous Integration System <qt-info@nokia.com> | 2010-10-21 11:51:06 (GMT) |
commit | 9624d70e5588bb1f6b0c894288c8ec3d4b3246c6 (patch) | |
tree | 73fd295570fc93c32b97c49c9e6849b6801dad53 | |
parent | 0a1118c3b8c491dadeff0b3f521fccbdb1c2e92c (diff) | |
parent | 8749766b23518277af81561e81c0a644375548f2 (diff) | |
download | Qt-9624d70e5588bb1f6b0c894288c8ec3d4b3246c6.zip Qt-9624d70e5588bb1f6b0c894288c8ec3d4b3246c6.tar.gz Qt-9624d70e5588bb1f6b0c894288c8ec3d4b3246c6.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2 into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/oslo-staging-2:
In meego, support Format_RGB32 too for eglShared images.
Make sure d->ranges does not have invalid ranges before processing it.
-rw-r--r-- | src/gui/itemviews/qitemselectionmodel.cpp | 13 | ||||
-rw-r--r-- | src/plugins/graphicssystems/meego/qmeegographicssystem.cpp | 5 | ||||
-rw-r--r-- | tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp | 66 |
3 files changed, 82 insertions, 2 deletions
diff --git a/src/gui/itemviews/qitemselectionmodel.cpp b/src/gui/itemviews/qitemselectionmodel.cpp index f848321..e69cd65 100644 --- a/src/gui/itemviews/qitemselectionmodel.cpp +++ b/src/gui/itemviews/qitemselectionmodel.cpp @@ -1059,6 +1059,19 @@ void QItemSelectionModel::select(const QItemSelection &selection, QItemSelection // store old selection QItemSelection sel = selection; + // If d->ranges is non-empty when the source model is reset the persistent indexes + // it contains will be invalid. We can't clear them in a modelReset slot because that might already + // be too late if another model observer is connected to the same modelReset slot and is invoked first + // it might call select() on this selection model before any such QItemSelectionModelPrivate::_q_modelReset() slot + // is invoked, so it would not be cleared yet. We clear it invalid ranges in it here. + QItemSelection::iterator it = d->ranges.begin(); + while (it != d->ranges.end()) { + if (!it->isValid()) + it = d->ranges.erase(it); + else + ++it; + } + QItemSelection old = d->ranges; old.merge(d->currentSelection, d->currentCommand); diff --git a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp index 27e728a..772db44 100644 --- a/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp +++ b/src/plugins/graphicssystems/meego/qmeegographicssystem.cpp @@ -150,8 +150,9 @@ void QMeeGoGraphicsSystem::setTranslucent(bool translucent) QPixmapData *QMeeGoGraphicsSystem::pixmapDataFromEGLSharedImage(Qt::HANDLE handle, const QImage &softImage) { if (softImage.format() != QImage::Format_ARGB32_Premultiplied && - softImage.format() != QImage::Format_ARGB32) { - qFatal("For egl shared images, the soft image has to be ARGB32 or ARGB32_Premultiplied"); + softImage.format() != QImage::Format_ARGB32 && + softImage.format() != QImage::Format_RGB32) { + qFatal("For egl shared images, the soft image has to be ARGB32, ARGB32_Premultiplied or RGB32"); return NULL; } diff --git a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp index 3b2a716..8058294 100644 --- a/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp +++ b/tests/auto/qitemselectionmodel/tst_qitemselectionmodel.cpp @@ -95,6 +95,8 @@ private slots: void QTBUG5671_layoutChangedWithAllSelected(); void QTBUG2804_layoutChangedTreeSelection(); + void testValidRangesInSelectionsAfterReset(); + private: QAbstractItemModel *model; QItemSelectionModel *selection; @@ -2353,6 +2355,70 @@ void tst_QItemSelectionModel::QTBUG2804_layoutChangedTreeSelection() QCOMPARE(selModel.selectedIndexes().count(), 4); } +class SelectionObserver : public QObject +{ + Q_OBJECT +public: + SelectionObserver(QAbstractItemModel *model, QObject *parent = 0) + : QObject(parent), m_model(model), m_selectionModel(0) + { + connect(model, SIGNAL(modelReset()), SLOT(modelReset())); + } + + void setSelectionModel(QItemSelectionModel *selectionModel) + { + m_selectionModel = selectionModel; + connect(m_selectionModel, SIGNAL(selectionChanged(QItemSelection,QItemSelection)), SLOT(selectionChanged(QItemSelection,QItemSelection))); + } + + private slots: + void modelReset() + { + const QModelIndex idx = m_model->index(2, 0); + QVERIFY(idx.isValid()); + m_selectionModel->select(QItemSelection(idx, idx), QItemSelectionModel::Clear); + } + + void selectionChanged(const QItemSelection &selected, const QItemSelection &deselected) + { + foreach(const QItemSelectionRange &range, selected) + QVERIFY(range.isValid()); + foreach(const QItemSelectionRange &range, deselected) + QVERIFY(range.isValid()); + } + +private: + QAbstractItemModel *m_model; + QItemSelectionModel *m_selectionModel; +}; + +void tst_QItemSelectionModel::testValidRangesInSelectionsAfterReset() +{ + QStringListModel model; + + QStringList strings; + strings << "one" + << "two" + << "three" + << "four" + << "five"; + + model.setStringList(strings); + + SelectionObserver observer(&model); + + QItemSelectionModel selectionModel(&model); + + selectionModel.select(QItemSelection(model.index(1, 0), model.index(3, 0)), QItemSelectionModel::Select); + + // Cause d->ranges to contain something. + model.insertRows(2, 1); + + observer.setSelectionModel(&selectionModel); + + model.setStringList(strings); + +} QTEST_MAIN(tst_QItemSelectionModel) #include "tst_qitemselectionmodel.moc" |