aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2018-01-15 12:49:07 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2018-01-15 12:49:07 +0100
commite8106ba7700e1666d1dbb3a9f1a579146dfdb681 (patch)
tree2f22b1429b8b74c59649004db586114f3e12e128
parent589d52b3b64a4b5221738a28df08be2eae4d12b2 (diff)
parentd61567f3cfa100aeab865bd6b436de87970575f5 (diff)
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts: src/quicktemplates2/qquickcontrol.cpp tests/auto/sanity/tst_sanity.cpp Change-Id: I62a79fd7788fec635b9917fc91bacd7338b547fd
-rw-r--r--src/imports/controls/Tumbler.qml10
-rw-r--r--src/imports/controls/material/Tumbler.qml10
-rw-r--r--src/imports/controls/universal/Tumbler.qml9
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp23
-rw-r--r--src/quicktemplates2/qquickcontrol_p_p.h2
-rw-r--r--tests/auto/sanity/BLACKLIST26
-rw-r--r--tests/auto/sanity/tst_sanity.cpp77
7 files changed, 106 insertions, 51 deletions
diff --git a/src/imports/controls/Tumbler.qml b/src/imports/controls/Tumbler.qml
index 918144a0..752d5834 100644
--- a/src/imports/controls/Tumbler.qml
+++ b/src/imports/controls/Tumbler.qml
@@ -45,7 +45,6 @@ T.Tumbler {
implicitHeight: 200
delegate: Text {
- id: label
text: modelData
color: control.visualFocus ? control.palette.highlight : control.palette.text
font: control.font
@@ -55,15 +54,14 @@ T.Tumbler {
}
contentItem: TumblerView {
- id: tumblerView
model: control.model
delegate: control.delegate
path: Path {
- startX: tumblerView.width / 2
- startY: -tumblerView.delegateHeight / 2
+ startX: contentItem.width / 2
+ startY: -contentItem.delegateHeight / 2
PathLine {
- x: tumblerView.width / 2
- y: (control.visibleItemCount + 1) * tumblerView.delegateHeight - tumblerView.delegateHeight / 2
+ x: contentItem.width / 2
+ y: (control.visibleItemCount + 1) * contentItem.delegateHeight - contentItem.delegateHeight / 2
}
}
diff --git a/src/imports/controls/material/Tumbler.qml b/src/imports/controls/material/Tumbler.qml
index b331eae8..8d58257f 100644
--- a/src/imports/controls/material/Tumbler.qml
+++ b/src/imports/controls/material/Tumbler.qml
@@ -46,7 +46,6 @@ T.Tumbler {
implicitHeight: 200
delegate: Text {
- id: label
text: modelData
color: control.Material.foreground
font: control.font
@@ -56,15 +55,14 @@ T.Tumbler {
}
contentItem: TumblerView {
- id: tumblerView
model: control.model
delegate: control.delegate
path: Path {
- startX: tumblerView.width / 2
- startY: -tumblerView.delegateHeight / 2
+ startX: contentItem.width / 2
+ startY: -contentItem.delegateHeight / 2
PathLine {
- x: tumblerView.width / 2
- y: (control.visibleItemCount + 1) * tumblerView.delegateHeight - tumblerView.delegateHeight / 2
+ x: contentItem.width / 2
+ y: (control.visibleItemCount + 1) * contentItem.delegateHeight - contentItem.delegateHeight / 2
}
}
diff --git a/src/imports/controls/universal/Tumbler.qml b/src/imports/controls/universal/Tumbler.qml
index c4fc9ea3..70e80354 100644
--- a/src/imports/controls/universal/Tumbler.qml
+++ b/src/imports/controls/universal/Tumbler.qml
@@ -56,15 +56,14 @@ T.Tumbler {
}
contentItem: TumblerView {
- id: tumblerView
model: control.model
delegate: control.delegate
path: Path {
- startX: tumblerView.width / 2
- startY: -tumblerView.delegateHeight / 2
+ startX: contentItem.width / 2
+ startY: -contentItem.delegateHeight / 2
PathLine {
- x: tumblerView.width / 2
- y: (control.visibleItemCount + 1) * tumblerView.delegateHeight - tumblerView.delegateHeight / 2
+ x: contentItem.width / 2
+ y: (control.visibleItemCount + 1) * contentItem.delegateHeight - contentItem.delegateHeight / 2
}
}
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index f860bcad..080317d8 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -52,7 +52,6 @@
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/qpa/qplatformtheme.h>
-#include <QtQml/private/qqmlincubator_p.h>
#if QT_CONFIG(accessibility)
#include <QtQuick/private/qquickaccessibleattached_p.h>
@@ -690,28 +689,6 @@ void QQuickControlPrivate::executeBackground(bool complete)
quickCompleteDeferred(q, backgroundName(), background);
}
-/*
- Cancels incubation recursively to avoid "Object destroyed during incubation" (QTBUG-50992)
-*/
-static void cancelIncubation(QObject *object, QQmlContext *context)
-{
- const auto children = object->children();
- for (QObject *child : children)
- cancelIncubation(child, context);
- QQmlIncubatorPrivate::cancel(object, context);
-}
-
-void QQuickControlPrivate::destroyDelegate(QObject *delegate, QObject *parent)
-{
- if (!delegate)
- return;
-
- QQmlContext *context = parent ? qmlContext(parent) : nullptr;
- if (context)
- cancelIncubation(delegate, context);
- delete delegate;
-}
-
QQuickControl::QQuickControl(QQuickItem *parent)
: QQuickItem(*(new QQuickControlPrivate), parent)
{
diff --git a/src/quicktemplates2/qquickcontrol_p_p.h b/src/quicktemplates2/qquickcontrol_p_p.h
index 3fe0a65b..7d040ded 100644
--- a/src/quicktemplates2/qquickcontrol_p_p.h
+++ b/src/quicktemplates2/qquickcontrol_p_p.h
@@ -146,8 +146,6 @@ public:
virtual void cancelBackground();
virtual void executeBackground(bool complete = false);
- static void destroyDelegate(QObject *object, QObject *parent);
-
struct ExtraData {
ExtraData();
QFont requestedFont;
diff --git a/tests/auto/sanity/BLACKLIST b/tests/auto/sanity/BLACKLIST
index 965790e7..841819f7 100644
--- a/tests/auto/sanity/BLACKLIST
+++ b/tests/auto/sanity/BLACKLIST
@@ -1,14 +1,26 @@
-[signalHandlers:material/CursorDelegate.qml]
-*
-[attachedObjects:material/ComboBox.qml]
-*
[attachedObjects:material/Switch.qml]
*
[attachedObjects:material/SwitchDelegate.qml]
*
-[attachedObjects:universal/ComboBox.qml]
+[ids:fusion/ComboBox.qml]
+*
+[ids:fusion/Tumbler.qml]
+*
+[ids:imagine/BusyIndicator.qml]
+*
+[ids:imagine/DelayButton.qml]
+*
+[ids:imagine/GroupBox.qml]
+*
+[ids:imagine/ProgressBar.qml]
+*
+[ids:imagine/ProgressBar.qml]
+*
+[ids:imagine/SpinBox.qml]
+*
+[ids:imagine/Switch.qml]
*
-[functions:material/RectangularGlow.qml]
+[ids:imagine/SwitchDelegate.qml]
*
-[anchors:material/RectangularGlow.qml]
+[ids:imagine/Tumbler.qml]
*
diff --git a/tests/auto/sanity/tst_sanity.cpp b/tests/auto/sanity/tst_sanity.cpp
index f6e1c78b..df440ebd 100644
--- a/tests/auto/sanity/tst_sanity.cpp
+++ b/tests/auto/sanity/tst_sanity.cpp
@@ -42,6 +42,7 @@
#include <QtQml/private/qqmljsparser_p.h>
#include <QtQml/private/qqmljsast_p.h>
#include <QtQml/private/qqmljsastvisitor_p.h>
+#include <QtQml/private/qqmlmetatype_p.h>
Q_GLOBAL_STATIC(QObjectList, qt_qobjects)
@@ -73,6 +74,8 @@ private slots:
void anchors_data();
void attachedObjects();
void attachedObjects_data();
+ void ids();
+ void ids_data();
private:
QQmlEngine engine;
@@ -138,12 +141,17 @@ private:
void tst_Sanity::initTestCase()
{
+ QQmlEngine engine;
+ QQmlComponent component(&engine);
+ component.setData(QString("import QtQuick.Templates 2.%1; Control { }").arg(QT_VERSION_MINOR - 7).toUtf8(), QUrl());
+
+ const QStringList qmlTypeNames = QQmlMetaType::qmlTypeNames();
+
QDirIterator it(QQC2_IMPORT_PATH, QStringList() << "*.qml" << "*.js", QDir::Files, QDirIterator::Subdirectories);
- const QStringList excludeDirs = QStringList() << QStringLiteral("snippets") << QStringLiteral("designer") << QStringLiteral("Sketch");
while (it.hasNext()) {
it.next();
QFileInfo info = it.fileInfo();
- if (!excludeDirs.contains(info.dir().dirName()))
+ if (qmlTypeNames.contains(QStringLiteral("QtQuick.Templates/") + info.baseName()))
files.insert(info.dir().dirName() + "/" + info.fileName(), info.filePath());
}
}
@@ -256,6 +264,71 @@ void tst_Sanity::anchors_data()
QTest::newRow(qPrintable(it.key())) << it.key() << it.value();
}
+class IdValidator : public BaseValidator
+{
+public:
+ IdValidator() : m_depth(0) { }
+
+protected:
+ bool visit(QQmlJS::AST::UiObjectBinding *) override
+ {
+ ++m_depth;
+ return true;
+ }
+
+ void endVisit(QQmlJS::AST::UiObjectBinding *) override
+ {
+ --m_depth;
+ }
+
+ bool visit(QQmlJS::AST::UiScriptBinding *node) override
+ {
+ if (m_depth == 0)
+ return true;
+
+ QQmlJS::AST::UiQualifiedId *id = node->qualifiedId;
+ if (id && id->name == QStringLiteral("id"))
+ addError(QString("Internal IDs are not allowed (%1)").arg(extractName(node->statement)), node);
+ return true;
+ }
+
+private:
+ QString extractName(QQmlJS::AST::Statement *statement)
+ {
+ QQmlJS::AST::ExpressionStatement *expressionStatement = static_cast<QQmlJS::AST::ExpressionStatement *>(statement);
+ if (!expressionStatement)
+ return QString();
+
+ QQmlJS::AST::IdentifierExpression *expression = static_cast<QQmlJS::AST::IdentifierExpression *>(expressionStatement->expression);
+ if (!expression)
+ return QString();
+
+ return expression->name.toString();
+ }
+
+ int m_depth;
+};
+
+void tst_Sanity::ids()
+{
+ QFETCH(QString, control);
+ QFETCH(QString, filePath);
+
+ IdValidator validator;
+ if (!validator.validate(filePath))
+ QFAIL(qPrintable(validator.errors()));
+}
+
+void tst_Sanity::ids_data()
+{
+ QTest::addColumn<QString>("control");
+ QTest::addColumn<QString>("filePath");
+
+ QMap<QString, QString>::const_iterator it;
+ for (it = files.constBegin(); it != files.constEnd(); ++it)
+ QTest::newRow(qPrintable(it.key())) << it.key() << it.value();
+}
+
static void addTestRows(QQmlEngine *engine, const QString &sourcePath, const QString &targetPath, const QStringList &skiplist = QStringList())
{
// We cannot use QQmlComponent to load QML files directly from the source tree.