diff options
author | A-Team <ateam@pad.test.qt.nokia.com> | 2010-10-21 22:00:10 (GMT) |
---|---|---|
committer | A-Team <ateam@pad.test.qt.nokia.com> | 2010-10-21 22:00:10 (GMT) |
commit | 215f46d0a61a2f48d1ccbbc52c3b161fa36c84ec (patch) | |
tree | 77e8cfce5c765702e5f60daf123d2740c1879d1c | |
parent | dd97db856bc19d648d7faa3aac4e27576dcb2512 (diff) | |
parent | be6a0b58680213da42d956ed9d1c77103be24c93 (diff) | |
download | Qt-215f46d0a61a2f48d1ccbbc52c3b161fa36c84ec.zip Qt-215f46d0a61a2f48d1ccbbc52c3b161fa36c84ec.tar.gz Qt-215f46d0a61a2f48d1ccbbc52c3b161fa36c84ec.tar.bz2 |
Merge branch '4.7-upstream' into 4.7-doc
7 files changed, 138 insertions, 16 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 2e5a43d..b737785 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -483,9 +483,9 @@ qreal QDeclarativeFlickable::contentX() const void QDeclarativeFlickable::setContentX(qreal pos) { Q_D(QDeclarativeFlickable); - pos = qRound(pos); d->timeline.reset(d->hData.move); d->vTime = d->timeline.time(); + movementXEnding(); if (-pos != d->hData.move.value()) { d->hData.move.setValue(-pos); viewportMoved(); @@ -501,9 +501,9 @@ qreal QDeclarativeFlickable::contentY() const void QDeclarativeFlickable::setContentY(qreal pos) { Q_D(QDeclarativeFlickable); - pos = qRound(pos); d->timeline.reset(d->vData.move); d->vTime = d->timeline.time(); + movementYEnding(); if (-pos != d->vData.move.value()) { d->vData.move.setValue(-pos); viewportMoved(); @@ -1516,6 +1516,15 @@ void QDeclarativeFlickable::movementStarting() void QDeclarativeFlickable::movementEnding() { Q_D(QDeclarativeFlickable); + movementXEnding(); + movementYEnding(); + d->hData.smoothVelocity.setValue(0); + d->vData.smoothVelocity.setValue(0); +} + +void QDeclarativeFlickable::movementXEnding() +{ + Q_D(QDeclarativeFlickable); if (d->flickingHorizontally) { d->flickingHorizontally = false; emit flickingChanged(); @@ -1523,13 +1532,6 @@ void QDeclarativeFlickable::movementEnding() if (!d->flickingVertically) emit flickEnded(); } - if (d->flickingVertically) { - d->flickingVertically = false; - emit flickingChanged(); - emit flickingVerticallyChanged(); - if (!d->flickingHorizontally) - emit flickEnded(); - } if (!d->pressed && !d->stealMouse) { if (d->movingHorizontally) { d->movingHorizontally = false; @@ -1539,6 +1541,20 @@ void QDeclarativeFlickable::movementEnding() if (!d->movingVertically) emit movementEnded(); } + } +} + +void QDeclarativeFlickable::movementYEnding() +{ + Q_D(QDeclarativeFlickable); + if (d->flickingVertically) { + d->flickingVertically = false; + emit flickingChanged(); + emit flickingVerticallyChanged(); + if (!d->flickingHorizontally) + emit flickEnded(); + } + if (!d->pressed && !d->stealMouse) { if (d->movingVertically) { d->movingVertically = false; d->vMoved = false; @@ -1548,8 +1564,6 @@ void QDeclarativeFlickable::movementEnding() emit movementEnded(); } } - d->hData.smoothVelocity.setValue(0); - d->vData.smoothVelocity.setValue(0); } void QDeclarativeFlickablePrivate::updateVelocity() diff --git a/src/declarative/graphicsitems/qdeclarativeflickable_p.h b/src/declarative/graphicsitems/qdeclarativeflickable_p.h index 4fb9c25..6e4d8ed 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable_p.h +++ b/src/declarative/graphicsitems/qdeclarativeflickable_p.h @@ -190,6 +190,8 @@ protected Q_SLOTS: void movementEnding(); protected: + void movementXEnding(); + void movementYEnding(); virtual qreal minXExtent() const; virtual qreal minYExtent() const; virtual qreal maxXExtent() const; diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index 4fc52f5..a07b1bb 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -93,6 +93,7 @@ public: QDeclarativePixmapData *data; QDeclarativePixmapReader *reader; + QSize requestSize; bool loading; int redirectCount; @@ -366,7 +367,7 @@ void QDeclarativePixmapReader::networkRequestDone(QNetworkReply *reply) QByteArray all = reply->readAll(); QBuffer buff(&all); buff.open(QIODevice::ReadOnly); - if (!readImage(reply->url(), &buff, &image, &errorString, &readSize, job->data->requestSize)) { + if (!readImage(reply->url(), &buff, &image, &errorString, &readSize, job->requestSize)) { error = QDeclarativePixmapReply::Decoding; } } @@ -683,7 +684,7 @@ void QDeclarativePixmapStore::timerEvent(QTimerEvent *) } QDeclarativePixmapReply::QDeclarativePixmapReply(QDeclarativePixmapData *d) -: data(d), reader(0), loading(false), redirectCount(0) +: data(d), reader(0), loading(false), redirectCount(0), requestSize(d->requestSize) { if (finishedIndex == -1) { finishedIndex = QDeclarativePixmapReply::staticMetaObject.indexOfSignal("finished()"); 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/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp index b20d8ec..50d0731 100644 --- a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp +++ b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp @@ -74,7 +74,7 @@ private slots: void massive(); void cancelcrash(); void shrinkcache(); - + void networkCrash(); private: QDeclarativeEngine engine; QUrl thisfile; @@ -335,6 +335,7 @@ public: : QDeclarativeImageProvider(Pixmap) {} virtual QPixmap requestPixmap(const QString &d, QSize *, const QSize &) { + Q_UNUSED(d) QPixmap pix(800, 600); pix.fill(Qt::red); return pix; @@ -353,6 +354,30 @@ void tst_qdeclarativepixmapcache::shrinkcache() } } +void createNetworkServer() +{ + QEventLoop eventLoop; + TestHTTPServer server(14453); + server.serveDirectory(SRCDIR "/data/http"); + QTimer::singleShot(100, &eventLoop, SLOT(quit())); + eventLoop.exec(); +} + +// QT-3957 +void tst_qdeclarativepixmapcache::networkCrash() +{ + QFuture<void> future = QtConcurrent::run(createNetworkServer); + QDeclarativeEngine engine; + for (int ii = 0; ii < 100 ; ++ii) { + QDeclarativePixmap* pixmap = new QDeclarativePixmap; + pixmap->load(&engine, QUrl(QString("http://127.0.0.1:14453/exists.png"))); + QTest::qSleep(1); + pixmap->clear(); + delete pixmap; + } + future.cancel(); +} + QTEST_MAIN(tst_qdeclarativepixmapcache) #include "tst_qdeclarativepixmapcache.moc" 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" |