diff options
| author | Liang Qi <liang.qi@theqtcompany.com> | 2015-03-17 16:39:43 +0100 |
|---|---|---|
| committer | Liang Qi <liang.qi@theqtcompany.com> | 2015-03-17 16:39:43 +0100 |
| commit | 7232472c82dcba653ba010fd0d05da13a7fb5dec (patch) | |
| tree | 31af3761fb93417777775a578711ab07b5f81c50 | |
| parent | 8f488d0d540cb7478c5341f1812b5f945c8cf2d4 (diff) | |
| parent | b735ba490fa9f43e1d14e356609a85f39e843259 (diff) | |
Merge remote-tracking branch 'origin/5.5' into dev
Change-Id: I9f4f561a6399b22c5f423dd853b07bffc9deebfc
| -rw-r--r-- | src/qml/jsruntime/qv4dateobject.cpp | 1 | ||||
| -rw-r--r-- | src/qml/jsruntime/qv4global_p.h | 6 | ||||
| -rw-r--r-- | src/quick/items/qquickitem.cpp | 5 | ||||
| -rw-r--r-- | src/quick/items/qquickrepeater.cpp | 92 | ||||
| -rw-r--r-- | src/quick/items/qquickrepeater_p_p.h | 4 | ||||
| -rw-r--r-- | tests/auto/guiapplauncher/demos.txt | 8 | ||||
| -rw-r--r-- | tests/auto/guiapplauncher/examples.txt | 53 | ||||
| -rw-r--r-- | tests/auto/quick/qquickrepeater/data/destroycount.qml | 22 | ||||
| -rw-r--r-- | tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp | 51 | ||||
| -rw-r--r-- | tests/testapplications/text/textedit.qml | 2 |
10 files changed, 186 insertions, 58 deletions
diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 28f0f2e044..451ef2486d 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -55,6 +55,7 @@ # else # include "qplatformdefs.h" # endif +# include <unistd.h> // for _POSIX_THREAD_SAFE_FUNCTIONS #endif using namespace QV4; diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index a79f71ff64..4b08194b60 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -74,9 +74,11 @@ inline double trunc(double d) { return d > 0 ? floor(d) : ceil(d); } // // NOTE: This should match the logic in qv4targetplatform_p.h! -#if defined(Q_PROCESSOR_X86) && (defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_QNX) || defined(Q_OS_FREEBSD)) +#if defined(Q_PROCESSOR_X86) && !defined(__ILP32__) \ + && (defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_QNX) || defined(Q_OS_FREEBSD)) #define V4_ENABLE_JIT -#elif defined(Q_PROCESSOR_X86_64) && (defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_MAC) || defined(Q_OS_FREEBSD)) +#elif defined(Q_PROCESSOR_X86_64) && !defined(__ILP32__) \ + && (defined(Q_OS_WIN) || defined(Q_OS_LINUX) || defined(Q_OS_MAC) || defined(Q_OS_FREEBSD)) #define V4_ENABLE_JIT #elif defined(Q_PROCESSOR_ARM_32) diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index 68ea5f4dbf..776da86b7e 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -2518,13 +2518,12 @@ void QQuickItem::setParentItem(QQuickItem *parentItem) QQuickWindowPrivate::get(d->window)->parentlessItems.remove(this); } - QQuickWindow *oldParentWindow = oldParentItem ? QQuickItemPrivate::get(oldParentItem)->window : 0; QQuickWindow *parentWindow = parentItem ? QQuickItemPrivate::get(parentItem)->window : 0; - if (oldParentWindow == parentWindow) { + if (d->window == parentWindow) { // Avoid freeing and reallocating resources if the window stays the same. d->parentItem = parentItem; } else { - if (oldParentWindow) + if (d->window) d->derefWindow(); d->parentItem = parentItem; if (parentWindow) diff --git a/src/quick/items/qquickrepeater.cpp b/src/quick/items/qquickrepeater.cpp index c5fea34e0b..0168d73c8f 100644 --- a/src/quick/items/qquickrepeater.cpp +++ b/src/quick/items/qquickrepeater.cpp @@ -44,7 +44,11 @@ QT_BEGIN_NAMESPACE QQuickRepeaterPrivate::QQuickRepeaterPrivate() - : model(0), ownModel(false), inRequest(false), dataSourceIsObject(false), delegateValidated(false), itemCount(0), createFrom(-1) + : model(0) + , ownModel(false) + , dataSourceIsObject(false) + , delegateValidated(false) + , itemCount(0) { } @@ -378,57 +382,51 @@ void QQuickRepeater::regenerate() d->itemCount = count(); d->deletables.resize(d->itemCount); - d->createFrom = 0; - d->createItems(); + d->requestItems(); } -void QQuickRepeaterPrivate::createItems() +void QQuickRepeaterPrivate::requestItems() { - Q_Q(QQuickRepeater); - if (createFrom == -1) - return; - inRequest = true; - for (int ii = createFrom; ii < itemCount; ++ii) { - if (!deletables.at(ii)) { - QObject *object = model->object(ii, false); - QQuickItem *item = qmlobject_cast<QQuickItem*>(object); - if (!item) { - if (object) { - model->release(object); - if (!delegateValidated) { - delegateValidated = true; - QObject* delegate = q->delegate(); - qmlInfo(delegate ? delegate : q) << QQuickRepeater::tr("Delegate must be of Item type"); - } + for (int i = 0; i < itemCount; i++) { + QObject *object = model->object(i, false); + if (object) + model->release(object); + } +} + +void QQuickRepeater::createdItem(int index, QObject *) +{ + Q_D(QQuickRepeater); + if (!d->deletables.at(index)) { + QObject *object = d->model->object(index, false); + QQuickItem *item = qmlobject_cast<QQuickItem*>(object); + if (!item) { + if (object) { + d->model->release(object); + if (!d->delegateValidated) { + d->delegateValidated = true; + QObject* delegate = this->delegate(); + qmlInfo(delegate ? delegate : this) << QQuickRepeater::tr("Delegate must be of Item type"); } - createFrom = ii; - break; } - deletables[ii] = item; - item->setParentItem(q->parentItem()); - if (ii > 0 && deletables.at(ii-1)) { - item->stackAfter(deletables.at(ii-1)); - } else { - QQuickItem *after = q; - for (int si = ii+1; si < itemCount; ++si) { - if (deletables.at(si)) { - after = deletables.at(si); - break; - } + return; + } + d->deletables[index] = item; + item->setParentItem(parentItem()); + if (index > 0 && d->deletables.at(index-1)) { + item->stackAfter(d->deletables.at(index-1)); + } else { + QQuickItem *after = this; + for (int si = index+1; si < d->itemCount; ++si) { + if (d->deletables.at(si)) { + after = d->deletables.at(si); + break; } - item->stackBefore(after); } - emit q->itemAdded(ii, item); + item->stackBefore(after); } + emit itemAdded(index, item); } - inRequest = false; -} - -void QQuickRepeater::createdItem(int, QObject *) -{ - Q_D(QQuickRepeater); - if (!d->inRequest) - d->createItems(); } void QQuickRepeater::initItem(int, QObject *object) @@ -476,7 +474,6 @@ void QQuickRepeater::modelUpdated(const QQmlChangeSet &changeSet, bool reset) difference -= remove.count; } - d->createFrom = -1; foreach (const QQmlChangeSet::Change &insert, changeSet.inserts()) { int index = qMin(insert.index, d->deletables.count()); if (insert.isMove()) { @@ -491,14 +488,13 @@ void QQuickRepeater::modelUpdated(const QQmlChangeSet &changeSet, bool reset) int modelIndex = index + i; ++d->itemCount; d->deletables.insert(modelIndex, 0); - if (d->createFrom == -1) - d->createFrom = modelIndex; + QObject *object = d->model->object(modelIndex, false); + if (object) + d->model->release(object); } difference += insert.count; } - d->createItems(); - if (difference != 0) emit countChanged(); } diff --git a/src/quick/items/qquickrepeater_p_p.h b/src/quick/items/qquickrepeater_p_p.h index 026633f156..732ba4d5b8 100644 --- a/src/quick/items/qquickrepeater_p_p.h +++ b/src/quick/items/qquickrepeater_p_p.h @@ -63,17 +63,15 @@ public: ~QQuickRepeaterPrivate(); private: - void createItems(); + void requestItems(); QPointer<QQmlInstanceModel> model; QVariant dataSource; QPointer<QObject> dataSourceAsObject; bool ownModel : 1; - bool inRequest : 1; bool dataSourceIsObject : 1; bool delegateValidated : 1; int itemCount; - int createFrom; QVector<QPointer<QQuickItem> > deletables; }; diff --git a/tests/auto/guiapplauncher/demos.txt b/tests/auto/guiapplauncher/demos.txt new file mode 100644 index 0000000000..1c48b6923d --- /dev/null +++ b/tests/auto/guiapplauncher/demos.txt @@ -0,0 +1,8 @@ +"quick/demos/clocks Example", "examples/quick/demos/clocks", "clocks", 0, -1 +"quick/demos/maroon Example", "examples/quick/demos/maroon", "maroon", 0, -1 +"quick/demos/calqlatr Example", "examples/quick/demos/calqlatr", "calqlatr", 0, -1 +"quick/demos/stocqt Example", "examples/quick/demos/stocqt", "stocqt", 0, -1 +"quick/demos/tweetsearch Example", "examples/quick/demos/tweetsearch", "tweetsearch", 0, -1 +"quick/demos/samegame Example", "examples/quick/demos/samegame", "samegame", 0, -1 +"quick/demos/phoyosurface Example", "examples/quick/demos/photosurface", "photosurface", 10, -1 +"quick/demos/rssnews Example", "examples/quick/demos/rssnews", "rssnews", 0, -1 diff --git a/tests/auto/guiapplauncher/examples.txt b/tests/auto/guiapplauncher/examples.txt new file mode 100644 index 0000000000..396e93dc1b --- /dev/null +++ b/tests/auto/guiapplauncher/examples.txt @@ -0,0 +1,53 @@ +"quick/keyinteraction Example", "examples/quick/keyinteraction", "keyinteraction", 0, -1 +"quick/models/stringlistmodel Example", "examples/quick/models/stringlistmodel", "stringlistmodel", 0, -1 +"quick/models/objectlistmodel Example", "examples/quick/models/objectlistmodel", "objectlistmodel", 0, -1 +"quick/models/abstractitemmodel Example", "examples/quick/models/abstractitemmodel", "abstractitemmodel", 0, -1 +"quick/righttoleft Example", "examples/quick/righttoleft", "righttoleft", 0, -1 +"quick/externaldraganddrop Example", "examples/quick/externaldraganddrop", "externaldraganddrop", 0, -1 +"quick/customitems/maskedmousearea Example", "examples/quick/customitems/maskedmousearea", "maskedmousearea", 0, -1 +"quick/imageelements Example", "examples/quick/imageelements", "imageelements", 0, -1 +"quick/threading Example", "examples/quick/threading", "threading", 0, -1 +"quick/scenegraph/openglunderqml Example", "examples/quick/scenegraph/openglunderqml", "openglunderqml", 0, -1 +"quick/scenegraph/threadedanimation Example", "examples/quick/scenegraph/threadedanimation", "threadedanimation", 0, -1 +"quick/scenegraph/twotextureproviders Example", "examples/quick/scenegraph/twotextureproviders", "twotextureproviders", 0, -1 +"quick/scenegraph/customgeometry Example", "examples/quick/scenegraph/customgeometry", "customgeometry", 0, -1 +"quick/scenegraph/sgengine Example", "examples/quick/scenegraph/sgengine", "sgengine", 10, -1 +"quick/scenegraph/simplematerial Example", "examples/quick/scenegraph/simplematerial", "simplematerial", 0, -1 +"quick/scenegraph/textureinsgnode Example", "examples/quick/scenegraph/textureinsgnode", "textureinsgnode", 0, -1 +"quick/scenegraph/textureinthread Example", "examples/quick/scenegraph/textureinthread", "textureinthread", 0, -1 +"quick/draganddrop Example", "examples/quick/draganddrop", "draganddrop", 0, -1 +"quick/animation Example", "examples/quick/animation", "animation", 0, -1 +"quick/embeddedinwidgets Example", "examples/quick/embeddedinwidgets", "embeddedinwidgets", 0, -1 +"quick/rendercontrol Example", "examples/quick/rendercontrol", "rendercontrol", 0, -1 +"quick/views Example", "examples/quick/views", "views", 0, -1 +"quick/window Example", "examples/quick/window", "window", 10, -1 +"quick/particles/system Example", "examples/quick/particles/system", "system", 0, -1 +"quick/particles/emitters Example", "examples/quick/particles/emitters", "emitters", 0, -1 +"quick/particles/customparticle Example", "examples/quick/particles/customparticle", "customparticle", 0, -1 +"quick/particles/imageparticle Example", "examples/quick/particles/imageparticle", "imageparticle", 0, -1 +"quick/particles/affectors Example", "examples/quick/particles/affectors", "affectors", 0, -1 +"quick/localstorage/localstorage Example", "examples/quick/localstorage/localstorage", "localstorage", 0, -1 +"quick/quick-accessibility Example", "examples/quick/quick-accessibility", "quick-accessibility", 0, -1 +"quick/positioners Example", "examples/quick/positioners", "positioners", 0, -1 +"quick/shadereffects Example", "examples/quick/shadereffects", "shadereffects", 0, -1 +"quick/mousearea Example", "examples/quick/mousearea", "mousearea", 0, -1 +"quick/touchinteraction Example", "examples/quick/touchinteraction", "touchinteraction", 0, -1 +"quick/canvas Example", "examples/quick/canvas", "canvas", 0, -1 +"quick/text Example", "examples/quick/text", "text", 0, -1 +"quick/quickwidgets/qquickviewcomparison Example", "examples/quick/quickwidgets/qquickviewcomparison", "qquickviewcomparison", 0, -1 +"quick/quickwidgets/quickwidget Example", "examples/quick/quickwidgets/quickwidget", "quickwidget", 0, -1 +"qml/shell Example", "examples/qml/shell", "shell", 10, -1 +"qml/referenceexamples/extended Example", "examples/qml/referenceexamples/extended", "extended", 0, -1 +"qml/referenceexamples/binding Example", "examples/qml/referenceexamples/binding", "binding", 10, -1 +"qml/referenceexamples/adding Example", "examples/qml/referenceexamples/adding", "adding", 10, -1 +"qml/referenceexamples/attached Example", "examples/qml/referenceexamples/attached", "attached", 10, -1 +"qml/referenceexamples/default Example", "examples/qml/referenceexamples/default", "default", 10, -1 +"qml/referenceexamples/signal Example", "examples/qml/referenceexamples/signal", "signal", 10, -1 +"qml/referenceexamples/coercion Example", "examples/qml/referenceexamples/coercion", "coercion", 10, -1 +"qml/referenceexamples/grouped Example", "examples/qml/referenceexamples/grouped", "grouped", 10, -1 +"qml/referenceexamples/valuesource Example", "examples/qml/referenceexamples/valuesource", "valuesource", 10, -1 +"qml/referenceexamples/properties Example", "examples/qml/referenceexamples/properties", "properties", 10, -1 +"qml/referenceexamples/methods Example", "examples/qml/referenceexamples/methods", "methods", 10, -1 +"qml/networkaccessmanagerfactory Example", "examples/qml/networkaccessmanagerfactory", "networkaccessmanagerfactory", 10, -1 +"qml/xmlhttprequest Example", "examples/qml/xmlhttprequest", "xmlhttprequest", 0, -1 +"qmltest/qmltest Example", "examples/qmltest/qmltest", "tst_qmltestexample", 10, -1 diff --git a/tests/auto/quick/qquickrepeater/data/destroycount.qml b/tests/auto/quick/qquickrepeater/data/destroycount.qml new file mode 100644 index 0000000000..6aaed8545c --- /dev/null +++ b/tests/auto/quick/qquickrepeater/data/destroycount.qml @@ -0,0 +1,22 @@ +import QtQuick 2.0 + +Item { + width: 360 + height: 480 + + Repeater { + id: repeater + objectName: "repeater" + anchors.fill: parent + property var componentCount: 0 + Component { + Text { + y: index*20 + text: index + Component.onCompleted: repeater.componentCount++; + Component.onDestruction: repeater.componentCount--; + } + } + } + +} diff --git a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp index 81cd87180f..b2039bd323 100644 --- a/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp +++ b/tests/auto/quick/qquickrepeater/tst_qquickrepeater.cpp @@ -75,6 +75,7 @@ private slots: void invalidContextCrash(); void jsArrayChange(); void clearRemovalOrder(); + void destroyCount(); }; class TestObject : public QObject @@ -293,6 +294,18 @@ void tst_QQuickRepeater::dataModel_adding() QCOMPARE(addedSpy.at(0).at(1).value<QQuickItem*>(), container->childItems().at(2)); addedSpy.clear(); + //insert in middle multiple + int childItemsSize = container->childItems().size(); + QList<QPair<QString, QString> > multiData; + multiData << qMakePair(QStringLiteral("five"), QStringLiteral("5")) << qMakePair(QStringLiteral("six"), QStringLiteral("6")) << qMakePair(QStringLiteral("seven"), QStringLiteral("7")); + testModel.insertItems(1, multiData); + QCOMPARE(countSpy.count(), 1); + QCOMPARE(addedSpy.count(), 3); + QCOMPARE(container->childItems().size(), childItemsSize + 3); + QCOMPARE(repeater->itemAt(2), container->childItems().at(2)); + addedSpy.clear(); + countSpy.clear(); + delete testObject; addedSpy.clear(); countSpy.clear(); @@ -676,7 +689,8 @@ void tst_QQuickRepeater::asynchronous() } // items will be created one at a time - for (int i = 0; i < 10; ++i) { + // the order is incubator/model specific + for (int i = 9; i >= 0; --i) { QString name("delegate"); name += QString::number(i); QVERIFY(findItem<QQuickItem>(container, name) == 0); @@ -845,6 +859,41 @@ void tst_QQuickRepeater::clearRemovalOrder() delete rootObject; } +void tst_QQuickRepeater::destroyCount() +{ + QQmlEngine engine; + QQmlComponent component(&engine, testFileUrl("destroycount.qml")); + + QQuickItem *rootObject = qobject_cast<QQuickItem*>(component.create()); + QVERIFY(rootObject); + + QQuickRepeater *repeater = findItem<QQuickRepeater>(rootObject, "repeater"); + QVERIFY(repeater); + + repeater->setProperty("model", qVariantFromValue<int>(3)); + QCOMPARE(repeater->property("componentCount").toInt(), 3); + repeater->setProperty("model", qVariantFromValue<int>(0)); + QCOMPARE(repeater->property("componentCount").toInt(), 0); + repeater->setProperty("model", qVariantFromValue<int>(4)); + QCOMPARE(repeater->property("componentCount").toInt(), 4); + + QStringListModel model; + repeater->setProperty("model", qVariantFromValue<QStringListModel *>(&model)); + QCOMPARE(repeater->property("componentCount").toInt(), 0); + QStringList list; + list << "1" << "2" << "3" << "4"; + model.setStringList(list); + QCOMPARE(repeater->property("componentCount").toInt(), 4); + model.insertRows(2,1); + QModelIndex index = model.index(2); + model.setData(index, qVariantFromValue<QString>(QStringLiteral("foobar"))); + QCOMPARE(repeater->property("componentCount").toInt(), 5); + + model.removeRows(2,1); + QCOMPARE(model.rowCount(), 4); + QCOMPARE(repeater->property("componentCount").toInt(), 4); +} + QTEST_MAIN(tst_QQuickRepeater) #include "tst_qquickrepeater.moc" diff --git a/tests/testapplications/text/textedit.qml b/tests/testapplications/text/textedit.qml index 54989afd47..6b2a89a713 100644 --- a/tests/testapplications/text/textedit.qml +++ b/tests/testapplications/text/textedit.qml @@ -136,7 +136,7 @@ Rectangle { "and a language runtime. "+ "A collection of C++ APIs is used to integrate these high level features with classic Qt applications."}); textmodel.append({ "name": "Links", - "value": "This is a link - <a href=\"http://qt-project.org/doc\">Qt Docs</a>"}); + "value": "This is a link - <a href=\"http://doc.qt.io/\">Qt Docs</a>"}); } } ControlView { |
