aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShawn Rutledge <shawn.rutledge@qt.io>2016-08-23 16:39:29 +0200
committerShawn Rutledge <shawn.rutledge@qt.io>2016-08-23 16:43:58 +0200
commite2736212a7762d8c6d474d64bec1df87799cf33b (patch)
tree9d5c88e10d32fd872c3ab6b8d312fc9f350c26d4
parent3eed20c22ee046c42fec81b0d9d6e47a27bdbe03 (diff)
parent8eeede619f417904cbd33fd44143f857dfce0996 (diff)
Merge branch remote-tracking branch '5.8' into wip/pointerhandler
-rw-r--r--.gitignore5
-rw-r--r--examples/quick/quick.pro2
-rw-r--r--examples/quick/scenegraph/graph/linenode.cpp2
-rw-r--r--examples/quick/scenegraph/graph/noisynode.cpp2
-rw-r--r--examples/quick/scenegraph/rendernode/softwarerenderer.h3
-rw-r--r--examples/quick/scenegraph/scenegraph.pro2
-rw-r--r--src/3rdparty/masm/yarr/YarrJIT.cpp22
-rw-r--r--src/imports/folderlistmodel/fileinfothread.cpp5
-rw-r--r--src/imports/imports.pro6
-rw-r--r--src/imports/localstorage/plugin.cpp5
-rw-r--r--src/imports/qtquick2/plugin.cpp6
-rw-r--r--src/imports/settings/qqmlsettings.cpp2
-rw-r--r--src/imports/testlib/TestCase.qml9
-rw-r--r--src/particles/qquickimageparticle.cpp10
-rw-r--r--src/particles/qquickparticlepainter.cpp3
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp4
-rw-r--r--src/qml/compiler/qqmltypecompiler.cpp2
-rw-r--r--src/qml/compiler/qv4codegen.cpp7
-rw-r--r--src/qml/compiler/qv4isel_moth.cpp163
-rw-r--r--src/qml/compiler/qv4ssa_p.h163
-rw-r--r--src/qml/doc/src/cppintegration/exposecppattributes.qdoc2
-rw-r--r--src/qml/doc/src/cppintegration/extending-tutorial.qdoc2
-rw-r--r--src/qml/doc/src/javascript/hostenvironment.qdoc5
-rw-r--r--src/qml/jsruntime/qv4engine.cpp13
-rw-r--r--src/qml/jsruntime/qv4object_p.h4
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp6
-rw-r--r--src/qml/memory/qv4mm.cpp13
-rw-r--r--src/qml/qml/ftw/ftw.pri3
-rw-r--r--src/qml/qml/qml.pri6
-rw-r--r--src/qml/qml/qqmlbinding.cpp11
-rw-r--r--src/qml/qml/qqmlbinding_p.h2
-rw-r--r--src/qml/qml/qqmlengine.cpp5
-rw-r--r--src/qml/qml/qqmlexpression_p.h1
-rw-r--r--src/qml/qml/qqmlimport.cpp2
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp4
-rw-r--r--src/qml/qml/qqmlloggingcategory.cpp128
-rw-r--r--src/qml/qml/qqmlloggingcategory_p.h (renamed from src/qml/qml/ftw/qdeletewatcher_p.h)74
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp10
-rw-r--r--src/qml/qml/qqmlproperty.cpp25
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp1
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h103
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp25
-rw-r--r--src/qmltest/quicktestevent.cpp13
-rw-r--r--src/qmltest/quicktestevent_p.h2
-rw-r--r--src/quick/accessible/qaccessiblequickitem.cpp4
-rw-r--r--src/quick/designer/qquickdesignercustomobjectdata.cpp4
-rw-r--r--src/quick/designer/qquickdesignersupport.cpp7
-rw-r--r--src/quick/designer/qquickdesignersupportitems.cpp14
-rw-r--r--src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc4
-rw-r--r--src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc2
-rw-r--r--src/quick/items/items.pri2
-rw-r--r--src/quick/items/qquickclipnode.cpp2
-rw-r--r--src/quick/items/qquickdroparea.cpp2
-rw-r--r--src/quick/items/qquickevents.cpp2
-rw-r--r--src/quick/items/qquickflickable.cpp45
-rw-r--r--src/quick/items/qquickframebufferobject.cpp11
-rw-r--r--src/quick/items/qquickgridview.cpp4
-rw-r--r--src/quick/items/qquickitem.cpp6
-rw-r--r--src/quick/items/qquickitemview.cpp21
-rw-r--r--src/quick/items/qquicklistview.cpp4
-rw-r--r--src/quick/items/qquickmultipointtoucharea.cpp20
-rw-r--r--src/quick/items/qquickpathview.cpp123
-rw-r--r--src/quick/items/qquickpincharea.cpp2
-rw-r--r--src/quick/items/qquickrepeater.cpp4
-rw-r--r--src/quick/items/qquickspriteengine.cpp19
-rw-r--r--src/quick/items/qquickspriteengine_p.h2
-rw-r--r--src/quick/items/qquicktext.cpp12
-rw-r--r--src/quick/items/qquicktextdocument.cpp2
-rw-r--r--src/quick/items/qquicktextedit.cpp4
-rw-r--r--src/quick/items/qquicktextinput.cpp4
-rw-r--r--src/quick/items/qquickview.cpp12
-rw-r--r--src/quick/items/qquickwindow.cpp14
-rw-r--r--src/quick/qtquick2.cpp2
-rw-r--r--src/quick/quick.pro2
-rw-r--r--src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp4
-rw-r--r--src/quick/scenegraph/coreapi/qsgmaterial.cpp4
-rw-r--r--src/quick/scenegraph/qsgcontext_p.h3
-rw-r--r--src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp3
-rw-r--r--src/quick/scenegraph/qsgdefaultrendercontext.cpp6
-rw-r--r--src/quick/scenegraph/scenegraph.pri10
-rw-r--r--src/quick/util/qquickanimation.cpp2
-rw-r--r--src/quick/util/qquickanimatorcontroller.cpp20
-rw-r--r--src/quick/util/qquickpath.cpp14
-rw-r--r--src/quick/util/qquickpixmapcache.cpp2
-rw-r--r--src/quick/util/qquickpropertychanges.cpp2
-rw-r--r--src/quick/util/qquickshortcut.cpp2
-rw-r--r--src/quick/util/qquickstate.cpp4
-rw-r--r--src/quick/util/qquicktransitionmanager.cpp10
-rw-r--r--src/quickwidgets/qquickwidget.cpp3
-rw-r--r--src/src.pro3
-rw-r--r--tests/auto/auto.pro5
-rw-r--r--tests/auto/particles/particles.pro3
-rw-r--r--tests/auto/particles/qquickage/tst_qquickage.cpp8
-rw-r--r--tests/auto/particles/qquickangleddirection/tst_qquickangleddirection.cpp2
-rw-r--r--tests/auto/particles/qquickcumulativedirection/tst_qquickcumulativedirection.cpp2
-rw-r--r--tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp4
-rw-r--r--tests/auto/particles/qquickcustomparticle/tst_qquickcustomparticle.cpp2
-rw-r--r--tests/auto/particles/qquickellipseextruder/tst_qquickellipseextruder.cpp4
-rw-r--r--tests/auto/particles/qquickfriction/tst_qquickfriction.cpp6
-rw-r--r--tests/auto/particles/qquickgravity/tst_qquickgravity.cpp2
-rw-r--r--tests/auto/particles/qquickgroupgoal/tst_qquickgroupgoal.cpp2
-rw-r--r--tests/auto/particles/qquickimageparticle/tst_qquickimageparticle.cpp12
-rw-r--r--tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp2
-rw-r--r--tests/auto/particles/qquicklineextruder/tst_qquicklineextruder.cpp4
-rw-r--r--tests/auto/particles/qquickmaskextruder/tst_qquickmaskextruder.cpp2
-rw-r--r--tests/auto/particles/qquickparticlegroup/tst_qquickparticlegroup.cpp2
-rw-r--r--tests/auto/particles/qquickparticlesystem/tst_qquickparticlesystem.cpp2
-rw-r--r--tests/auto/particles/qquickpointattractor/tst_qquickpointattractor.cpp2
-rw-r--r--tests/auto/particles/qquickpointdirection/tst_qquickpointdirection.cpp2
-rw-r--r--tests/auto/particles/qquickrectangleextruder/tst_qquickrectangleextruder.cpp4
-rw-r--r--tests/auto/particles/qquickspritegoal/tst_qquickspritegoal.cpp2
-rw-r--r--tests/auto/particles/qquicktargetdirection/tst_qquicktargetdirection.cpp2
-rw-r--r--tests/auto/particles/qquicktrailemitter/tst_qquicktrailemitter.cpp4
-rw-r--r--tests/auto/particles/qquickturbulence/tst_qquickturbulence.cpp2
-rw-r--r--tests/auto/particles/qquickwander/tst_qquickwander.cpp2
-rw-r--r--tests/auto/qml/debugger/debugger.pro4
-rw-r--r--tests/auto/qml/qml.pro8
-rw-r--r--tests/auto/qml/qqmlconsole/data/categorized_logging.qml65
-rw-r--r--tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp36
-rw-r--r--tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp29
-rw-r--r--tests/auto/qml/qqmlecmascript/data/DestructionHelper.qml3
-rw-r--r--tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp102
-rw-r--r--tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp42
-rw-r--r--tests/auto/qmldevtools/compile/compile.pro2
-rw-r--r--tests/auto/qmldevtools/qmldevtools.pro6
-rw-r--r--tests/auto/qmltest/listview/tst_listview.qml4
-rw-r--r--tests/auto/quick/qquickflickable/data/contentXY.qml6
-rw-r--r--tests/auto/quick/qquickflickable/tst_qquickflickable.cpp21
-rw-r--r--tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp31
-rw-r--r--tests/auto/quick/qquickpathview/data/qtbug37815.qml77
-rw-r--r--tests/auto/quick/qquickpathview/data/qtbug53464.qml77
-rw-r--r--tests/auto/quick/qquickpathview/tst_qquickpathview.cpp50
-rw-r--r--tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp35
-rw-r--r--tests/auto/quick/quick.pro6
-rw-r--r--tests/auto/shared/util.cpp11
-rw-r--r--tests/auto/shared/util.h5
-rw-r--r--tests/benchmarks/benchmarks.pro4
-rw-r--r--tests/benchmarks/particles/affectors/tst_affectors.cpp4
-rw-r--r--tests/benchmarks/particles/emission/tst_emission.cpp2
-rw-r--r--tests/benchmarks/qml/animation/tst_animation.cpp4
-rw-r--r--tests/benchmarks/qml/creation/creation.pro2
-rw-r--r--tests/benchmarks/qml/creation/tst_creation.cpp57
-rw-r--r--tests/benchmarks/qml/librarymetrics_performance/tst_librarymetrics_performance.cpp147
-rw-r--r--tests/benchmarks/qml/qml.pro5
-rw-r--r--tests/benchmarks/qml/qqmlimage/image.pngbin611 -> 0 bytes
-rw-r--r--tests/benchmarks/qml/qqmlimage/qqmlimage.pro11
-rw-r--r--tests/benchmarks/qml/qqmlimage/tst_qqmlimage.cpp95
-rw-r--r--tests/manual/qmlplugindump/tst_qmlplugindump.cpp11
-rw-r--r--tests/manual/scenegraph_lancelot/scenegrabber/main.cpp4
-rw-r--r--tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp6
-rw-r--r--tools/qml/main.cpp8
-rw-r--r--tools/qmleasing/splineeditor.cpp2
-rw-r--r--tools/qmlimportscanner/main.cpp92
-rw-r--r--tools/qmljs/qmljs.cpp4
-rw-r--r--tools/qmlmin/main.cpp2
-rw-r--r--tools/qmlplugindump/main.cpp48
-rw-r--r--tools/qmlplugindump/qmlstreamwriter.cpp2
-rw-r--r--tools/qmlplugindump/qmltypereader.cpp2
-rw-r--r--tools/qmlprofiler/qmlprofilerapplication.cpp4
-rw-r--r--tools/qmlprofiler/qmlprofilerdata.cpp2
-rw-r--r--tools/qmlscene/main.cpp16
-rw-r--r--tools/tools.pro2
162 files changed, 1504 insertions, 1067 deletions
diff --git a/.gitignore b/.gitignore
index e0af30c299..da9552c8e6 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,12 +4,17 @@
config.tests/*/*/*
!config.tests/*/*/*[.]*
config.tests/*/*/*[.]app
+config.log
callgrind.out.*
pcviewer.cfg
*~
*.a
*.la
+*_wrapper.sh
+*_wrapper.bat
+wrapper.sh
+wrapper.bat
*.core
*.moc
*.o
diff --git a/examples/quick/quick.pro b/examples/quick/quick.pro
index b164bf4f5b..445dfb0fab 100644
--- a/examples/quick/quick.pro
+++ b/examples/quick/quick.pro
@@ -27,7 +27,7 @@ SUBDIRS = quick-accessibility \
demos
#OpenGL Support Required
-contains(QT_CONFIG, opengl(es1|es2)?) {
+qtConfig(opengl(es1|es2)?) {
SUBDIRS += \
textureprovider \
rendercontrol
diff --git a/examples/quick/scenegraph/graph/linenode.cpp b/examples/quick/scenegraph/graph/linenode.cpp
index 473be7da17..992e2d44c9 100644
--- a/examples/quick/scenegraph/graph/linenode.cpp
+++ b/examples/quick/scenegraph/graph/linenode.cpp
@@ -56,7 +56,7 @@ class LineShader : public QSGSimpleMaterialShader<LineMaterial>
QSG_DECLARE_SIMPLE_SHADER(LineShader, LineMaterial)
public:
- LineShader() {
+ LineShader() : id_color(-1), id_spread(-1), id_size(-1) {
setShaderSourceFile(QOpenGLShader::Vertex, ":/scenegraph/graph/shaders/line.vsh");
setShaderSourceFile(QOpenGLShader::Fragment, ":/scenegraph/graph/shaders/line.fsh");
}
diff --git a/examples/quick/scenegraph/graph/noisynode.cpp b/examples/quick/scenegraph/graph/noisynode.cpp
index bc273cf632..834151599b 100644
--- a/examples/quick/scenegraph/graph/noisynode.cpp
+++ b/examples/quick/scenegraph/graph/noisynode.cpp
@@ -61,7 +61,7 @@ class NoisyShader : public QSGSimpleMaterialShader<NoisyMaterial>
QSG_DECLARE_SIMPLE_SHADER(NoisyShader, NoisyMaterial)
public:
- NoisyShader() {
+ NoisyShader() : id_color(-1), id_texture(-1), id_textureSize(-1) {
setShaderSourceFile(QOpenGLShader::Vertex, ":/scenegraph/graph/shaders/noisy.vsh");
setShaderSourceFile(QOpenGLShader::Fragment, ":/scenegraph/graph/shaders/noisy.fsh");
}
diff --git a/examples/quick/scenegraph/rendernode/softwarerenderer.h b/examples/quick/scenegraph/rendernode/softwarerenderer.h
index 5b2a475ed8..e91ca92d88 100644
--- a/examples/quick/scenegraph/rendernode/softwarerenderer.h
+++ b/examples/quick/scenegraph/rendernode/softwarerenderer.h
@@ -42,8 +42,7 @@
#define SOFTWARERENDERER_H
#include <qsgrendernode.h>
-
-class QQuickItem;
+#include <QQuickItem>
class SoftwareRenderNode : public QSGRenderNode
{
diff --git a/examples/quick/scenegraph/scenegraph.pro b/examples/quick/scenegraph/scenegraph.pro
index 1015d7be3d..e13e8198b0 100644
--- a/examples/quick/scenegraph/scenegraph.pro
+++ b/examples/quick/scenegraph/scenegraph.pro
@@ -1,6 +1,6 @@
TEMPLATE = subdirs
-contains(QT_CONFIG, opengl(es1|es2)?) {
+qtConfig(opengl(es1|es2)?) {
SUBDIRS += \
graph \
simplematerial \
diff --git a/src/3rdparty/masm/yarr/YarrJIT.cpp b/src/3rdparty/masm/yarr/YarrJIT.cpp
index 5664c585b9..d8211ec4b2 100644
--- a/src/3rdparty/masm/yarr/YarrJIT.cpp
+++ b/src/3rdparty/masm/yarr/YarrJIT.cpp
@@ -338,17 +338,31 @@ class YarrGenerator : private MacroAssembler {
jump(Address(stackPointerRegister, frameLocation * sizeof(void*)));
}
+ unsigned alignCallFrameSizeInBytes(unsigned callFrameSize)
+ {
+ callFrameSize *= sizeof(void*);
+ if (callFrameSize / sizeof(void*) != m_pattern.m_body->m_callFrameSize)
+ CRASH();
+ // Originally, the code was:
+// callFrameSize = (callFrameSize + 0x3f) & ~0x3f;
+ // However, 64 bytes is a bit surprising. The biggest "alignment" requirement is on Aarch64, where:
+ // "SP mod 16 = 0. The stack must be quad-word aligned." (IHI0055B_aapcs64.pdf)
+ callFrameSize = (callFrameSize + 0xf) & ~0xf;
+ if (!callFrameSize)
+ CRASH();
+ return callFrameSize;
+ }
void initCallFrame()
{
unsigned callFrameSize = m_pattern.m_body->m_callFrameSize;
if (callFrameSize)
- subPtr(Imm32(callFrameSize * sizeof(void*)), stackPointerRegister);
+ subPtr(Imm32(alignCallFrameSizeInBytes(callFrameSize)), stackPointerRegister);
}
void removeCallFrame()
{
unsigned callFrameSize = m_pattern.m_body->m_callFrameSize;
if (callFrameSize)
- addPtr(Imm32(callFrameSize * sizeof(void*)), stackPointerRegister);
+ addPtr(Imm32(alignCallFrameSizeInBytes(callFrameSize)), stackPointerRegister);
}
// Used to record subpatters, should only be called if compileMode is IncludeSubpatterns.
@@ -2565,6 +2579,10 @@ class YarrGenerator : private MacroAssembler {
if (compileMode == IncludeSubpatterns)
loadPtr(Address(X86Registers::ebp, 2 * sizeof(void*)), output);
#endif
+#elif CPU(ARM64)
+ // The ABI doesn't guarantee the upper bits are zero on unsigned arguments, so clear them ourselves.
+ zeroExtend32ToPtr(index, index);
+ zeroExtend32ToPtr(length, length);
#elif CPU(ARM)
push(ARMRegisters::r4);
push(ARMRegisters::r5);
diff --git a/src/imports/folderlistmodel/fileinfothread.cpp b/src/imports/folderlistmodel/fileinfothread.cpp
index 5d911eec1e..0b62935f87 100644
--- a/src/imports/folderlistmodel/fileinfothread.cpp
+++ b/src/imports/folderlistmodel/fileinfothread.cpp
@@ -260,14 +260,13 @@ void FileInfoThread::getFileInfos(const QString &path)
sortFlags = sortFlags | QDir::DirsFirst;
QDir currentDir(path, QString(), sortFlags);
- QFileInfoList fileInfoList;
QList<FileProperty> filePropertyList;
- fileInfoList = currentDir.entryInfoList(nameFilters, filter, sortFlags);
+ const QFileInfoList fileInfoList = currentDir.entryInfoList(nameFilters, filter, sortFlags);
if (!fileInfoList.isEmpty()) {
filePropertyList.reserve(fileInfoList.count());
- foreach (const QFileInfo &info, fileInfoList) {
+ for (const QFileInfo &info : fileInfoList) {
//qDebug() << "Adding file : " << info.fileName() << "to list ";
filePropertyList << FileProperty(info);
}
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
index ade744ec19..28345d049a 100644
--- a/src/imports/imports.pro
+++ b/src/imports/imports.pro
@@ -17,10 +17,8 @@ qtHaveModule(quick) {
window \
testlib
- contains(QT_CONFIG, opengl(es1|es2)?) {
- SUBDIRS += \
- particles
- }
+ qtConfig(opengl(es1|es2)?): \
+ SUBDIRS += particles
}
qtHaveModule(xmlpatterns) : SUBDIRS += xmllistmodel
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index f59ccc551e..7d96f11768 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -149,12 +149,7 @@ public:
using namespace QV4;
-QT_WARNING_PUSH
-#if (Q_CC_GNU >= 600)
-QT_WARNING_DISABLE_GCC("-Wtautological-compare")
-#endif
DEFINE_OBJECT_VTABLE(QV4::QQmlSqlDatabaseWrapper);
-QT_WARNING_POP
diff --git a/src/imports/qtquick2/plugin.cpp b/src/imports/qtquick2/plugin.cpp
index e56027c1bb..d16467a5bb 100644
--- a/src/imports/qtquick2/plugin.cpp
+++ b/src/imports/qtquick2/plugin.cpp
@@ -61,13 +61,17 @@ public:
{
Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick"));
Q_UNUSED(uri);
+ moduleDefined = true;
QQmlQtQuick2Module::defineModule();
}
~QtQuick2Plugin()
{
- QQmlQtQuick2Module::undefineModule();
+ if (moduleDefined)
+ QQmlQtQuick2Module::undefineModule();
}
+
+ bool moduleDefined = false;
};
//![class decl]
diff --git a/src/imports/settings/qqmlsettings.cpp b/src/imports/settings/qqmlsettings.cpp
index bc097e4575..cd6fcbc718 100644
--- a/src/imports/settings/qqmlsettings.cpp
+++ b/src/imports/settings/qqmlsettings.cpp
@@ -214,7 +214,7 @@ QT_BEGIN_NAMESPACE
instance, even if they are referring to the same setting in the same category.
The information is stored in the system registry on Windows, and in XML
- preferences files on OS X. On other Unix systems, in the absence of a
+ preferences files on \macos. On other Unix systems, in the absence of a
standard, INI text files are used. See \l QSettings documentation for
more details.
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml
index bc6786f9f8..683200a259 100644
--- a/src/imports/testlib/TestCase.qml
+++ b/src/imports/testlib/TestCase.qml
@@ -1125,6 +1125,7 @@ Item {
modifiers = Qt.NoModifier
if (delay == undefined)
delay = -1
+ var moveDelay = Math.max(1, delay === -1 ? qtest_events.defaultMouseDelay : delay)
// Divide dx and dy to have intermediate mouseMove while dragging
// Fractions of dx/dy need be superior to the dragThreshold
@@ -1138,12 +1139,12 @@ Item {
mousePress(item, x, y, button, modifiers, delay)
//trigger dragging
- mouseMove(item, x + util.dragThreshold + 1, y + util.dragThreshold + 1, delay, button)
+ mouseMove(item, x + util.dragThreshold + 1, y + util.dragThreshold + 1, moveDelay, button)
if (ddx > 0 || ddy > 0) {
- mouseMove(item, x + ddx, y + ddy, delay, button)
- mouseMove(item, x + 2*ddx, y + 2*ddy, delay, button)
+ mouseMove(item, x + ddx, y + ddy, moveDelay, button)
+ mouseMove(item, x + 2*ddx, y + 2*ddy, moveDelay, button)
}
- mouseMove(item, x + dx, y + dy, delay, button)
+ mouseMove(item, x + dx, y + dy, moveDelay, button)
mouseRelease(item, x + dx, y + dy, button, modifiers, delay)
}
diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp
index 07cbee1383..c68153aca8 100644
--- a/src/particles/qquickimageparticle.cpp
+++ b/src/particles/qquickimageparticle.cpp
@@ -49,6 +49,7 @@
#include <private/qquicksprite_p.h>
#include <private/qquickspriteengine_p.h>
#include <QOpenGLFunctions>
+#include <QSGRendererInterface>
#include <QtQuick/private/qsgshadersourcebuilder_p.h>
#include <QtQuick/private/qsgtexture_p.h>
#include <private/qqmlglobal_p.h>
@@ -1469,8 +1470,17 @@ void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node)
update();
}
+static inline bool isOpenGL(QSGRenderContext *rc)
+{
+ QSGRendererInterface *rif = rc->sceneGraphContext()->rendererInterface(rc);
+ return !rif || rif->graphicsApi() == QSGRendererInterface::OpenGL;
+}
+
QSGNode *QQuickImageParticle::updatePaintNode(QSGNode *node, UpdatePaintNodeData *)
{
+ if (!node && !isOpenGL(QQuickItemPrivate::get(this)->sceneGraphRenderContext()))
+ return 0;
+
if (m_pleaseReset){
if (node)
delete node;
diff --git a/src/particles/qquickparticlepainter.cpp b/src/particles/qquickparticlepainter.cpp
index d6303eb219..0c2521cd9e 100644
--- a/src/particles/qquickparticlepainter.cpp
+++ b/src/particles/qquickparticlepainter.cpp
@@ -103,7 +103,8 @@ void QQuickParticlePainter::recalculateGroupIds() const
m_groupIdsNeedRecalculation = false;
m_groupIds.clear();
- for (const QString &str : groups()) {
+ const auto groupList = groups();
+ for (const QString &str : groupList) {
QQuickParticleGroupData::ID groupId = m_system->groupIds.value(str, QQuickParticleGroupData::InvalidID);
if (groupId == QQuickParticleGroupData::InvalidID) {
// invalid data, not finished setting up, or whatever. Fallback: do not cache.
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp
index 900dfe7ef7..2644c693ce 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp
@@ -737,9 +737,13 @@ void QSGD3D12EnginePrivate::initialize(WId w, const QSize &size, float dpr, int
const bool debugLayer = qEnvironmentVariableIntValue("QT_D3D_DEBUG") != 0;
if (debugLayer) {
qCDebug(QSG_LOG_INFO_GENERAL, "Enabling debug layer");
+#if !defined(Q_OS_WINRT) || !defined(NDEBUG)
ComPtr<ID3D12Debug> debugController;
if (SUCCEEDED(D3D12GetDebugInterface(IID_PPV_ARGS(&debugController))))
debugController->EnableDebugLayer();
+#else
+ qCDebug(QSG_LOG_INFO_GENERAL, "Using DebugInterface will not allow certification to pass");
+#endif
}
QSGD3D12DeviceManager *dev = deviceManager();
diff --git a/src/qml/compiler/qqmltypecompiler.cpp b/src/qml/compiler/qqmltypecompiler.cpp
index 4b33363d09..2308e66609 100644
--- a/src/qml/compiler/qqmltypecompiler.cpp
+++ b/src/qml/compiler/qqmltypecompiler.cpp
@@ -816,7 +816,7 @@ void QQmlComponentAndAliasResolver::findAndRegisterImplicitComponents(const QmlI
continue;
QQmlPropertyCache *pc = enginePrivate->rawPropertyCacheForType(pd->propType());
- const QMetaObject *mo = pc->firstCppMetaObject();
+ const QMetaObject *mo = pc ? pc->firstCppMetaObject() : 0;
while (mo) {
if (mo == &QQmlComponent::staticMetaObject)
break;
diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp
index 4130ad08d7..e0def1021b 100644
--- a/src/qml/compiler/qv4codegen.cpp
+++ b/src/qml/compiler/qv4codegen.cpp
@@ -2513,6 +2513,13 @@ bool Codegen::visit(ReturnStatement *ast)
Result expr = expression(ast->expression);
move(_block->TEMP(_returnAddress), *expr);
}
+
+ // Since we're leaving, don't let any finally statements we emit as part of the unwinding
+ // jump to exception handlers at run-time if they throw.
+ IR::BasicBlock *unwindBlock = _function->newBasicBlock(/*no exception handler*/Q_NULLPTR);
+ _block->JUMP(unwindBlock);
+ _block = unwindBlock;
+
unwindException(0);
_block->JUMP(_exitBlock);
diff --git a/src/qml/compiler/qv4isel_moth.cpp b/src/qml/compiler/qv4isel_moth.cpp
index c9143b6857..fda5b4cdd0 100644
--- a/src/qml/compiler/qv4isel_moth.cpp
+++ b/src/qml/compiler/qv4isel_moth.cpp
@@ -150,167 +150,6 @@ inline bool isBoolType(IR::Expr *e)
return (e->type == IR::BoolType);
}
-/*
- * stack slot allocation:
- *
- * foreach bb do
- * foreach stmt do
- * if the current statement is not a phi-node:
- * purge ranges that end before the current statement
- * check for life ranges to activate, and if they don't have a stackslot associated then allocate one
- * renumber temps to stack
- * for phi nodes: check if all temps (src+dst) are assigned stack slots and marked as allocated
- * if it's a jump:
- * foreach phi node in the successor:
- * allocate slots for each temp (both sources and targets) if they don't have one allocated already
- * insert moves before the jump
- */
-class AllocateStackSlots: protected ConvertTemps
-{
- IR::LifeTimeIntervals::Ptr _intervals;
- QVector<IR::LifeTimeInterval *> _unhandled;
- QVector<IR::LifeTimeInterval *> _live;
- QBitArray _slotIsInUse;
- IR::Function *_function;
-
- int defPosition(IR::Stmt *s) const
- {
- return usePosition(s) + 1;
- }
-
- int usePosition(IR::Stmt *s) const
- {
- return _intervals->positionForStatement(s);
- }
-
-public:
- AllocateStackSlots(const IR::LifeTimeIntervals::Ptr &intervals)
- : _intervals(intervals)
- , _slotIsInUse(intervals->size(), false)
- , _function(0)
- {
- _live.reserve(8);
- _unhandled = _intervals->intervals();
- }
-
- void forFunction(IR::Function *function)
- {
- IR::Optimizer::showMeTheCode(function, "Before stack slot allocation");
- _function = function;
- toStackSlots(function);
- }
-
-protected:
- virtual int allocateFreeSlot()
- {
- for (int i = 0, ei = _slotIsInUse.size(); i != ei; ++i) {
- if (!_slotIsInUse[i]) {
- if (_nextUnusedStackSlot <= i) {
- Q_ASSERT(_nextUnusedStackSlot == i);
- _nextUnusedStackSlot = i + 1;
- }
- _slotIsInUse[i] = true;
- return i;
- }
- }
-
- Q_UNREACHABLE();
- return -1;
- }
-
- virtual void process(IR::Stmt *s)
- {
-// qDebug("L%d statement %d:", _currentBasicBlock->index, s->id);
-
- if (IR::Phi *phi = s->asPhi()) {
- visitPhi(phi);
- } else {
- // purge ranges no longer alive:
- for (int i = 0; i < _live.size(); ) {
- const IR::LifeTimeInterval *lti = _live.at(i);
- if (lti->end() < usePosition(s)) {
-// qDebug() << "\t - moving temp" << lti->temp().index << "to handled, freeing slot" << _stackSlotForTemp[lti->temp().index];
- _live.remove(i);
- Q_ASSERT(_slotIsInUse[_stackSlotForTemp[lti->temp().index]]);
- _slotIsInUse[_stackSlotForTemp[lti->temp().index]] = false;
- continue;
- } else {
- ++i;
- }
- }
-
- // active new ranges:
- while (!_unhandled.isEmpty()) {
- IR::LifeTimeInterval *lti = _unhandled.last();
- if (lti->start() > defPosition(s))
- break; // we're done
- Q_ASSERT(!_stackSlotForTemp.contains(lti->temp().index));
- _stackSlotForTemp[lti->temp().index] = allocateFreeSlot();
-// qDebug() << "\t - activating temp" << lti->temp().index << "on slot" << _stackSlotForTemp[lti->temp().index];
- _live.append(lti);
- _unhandled.removeLast();
- }
-
- visit(s);
- }
-
- if (IR::Jump *jump = s->asJump()) {
- IR::MoveMapping moves;
- for (IR::Stmt *succStmt : jump->target->statements()) {
- if (IR::Phi *phi = succStmt->asPhi()) {
- forceActivation(*phi->targetTemp);
- for (int i = 0, ei = phi->incoming.size(); i != ei; ++i) {
- IR::Expr *e = phi->incoming[i];
- if (IR::Temp *t = e->asTemp()) {
- forceActivation(*t);
- }
- if (jump->target->in[i] == _currentBasicBlock)
- moves.add(phi->incoming[i], phi->targetTemp);
- }
- } else {
- break;
- }
- }
- moves.order();
- QList<IR::Move *> newMoves = moves.insertMoves(_currentBasicBlock, _function, true);
- foreach (IR::Move *move, newMoves)
- visit(move);
- }
- }
-
- void forceActivation(const IR::Temp &t)
- {
- if (_stackSlotForTemp.contains(t.index))
- return;
-
- int i = _unhandled.size() - 1;
- for (; i >= 0; --i) {
- IR::LifeTimeInterval *lti = _unhandled[i];
- if (lti->temp() == t) {
- _live.append(lti);
- _unhandled.remove(i);
- break;
- }
- }
- Q_ASSERT(i >= 0); // check that we always found the entry
-
- _stackSlotForTemp[t.index] = allocateFreeSlot();
-// qDebug() << "\t - force activating temp" << t.index << "on slot" << _stackSlotForTemp[t.index];
- }
-
- virtual void visitPhi(IR::Phi *phi)
- {
- Q_UNUSED(phi);
-#if !defined(QT_NO_DEBUG)
- Q_ASSERT(_stackSlotForTemp.contains(phi->targetTemp->index));
- Q_ASSERT(_slotIsInUse[_stackSlotForTemp[phi->targetTemp->index]]);
- foreach (IR::Expr *e, phi->incoming) {
- if (IR::Temp *t = e->asTemp())
- Q_ASSERT(_stackSlotForTemp.contains(t->index));
- }
-#endif // defined(QT_NO_DEBUG)
- }
-};
} // anonymous namespace
InstructionSelection::InstructionSelection(QQmlEnginePrivate *qmlEngine, QV4::ExecutableAllocator *execAllocator, IR::Module *module, QV4::Compiler::JSUnitGenerator *jsGenerator, EvalISelFactory *iselFactory)
@@ -360,7 +199,7 @@ void InstructionSelection::run(int functionIndex)
qEnvironmentVariableIsEmpty("QV4_NO_INTERPRETER_STACK_SLOT_ALLOCATION");
if (doStackSlotAllocation) {
- AllocateStackSlots(opt.lifeTimeIntervals()).forFunction(_function);
+ IR::AllocateStackSlots(opt.lifeTimeIntervals()).forFunction(_function);
} else {
opt.convertOutOfSSA();
ConvertTemps().toStackSlots(_function);
diff --git a/src/qml/compiler/qv4ssa_p.h b/src/qml/compiler/qv4ssa_p.h
index e608c08591..386990a9f5 100644
--- a/src/qml/compiler/qv4ssa_p.h
+++ b/src/qml/compiler/qv4ssa_p.h
@@ -52,6 +52,7 @@
//
#include "qv4jsir_p.h"
+#include "qv4isel_util_p.h"
#include <QtCore/QSharedPointer>
QT_BEGIN_NAMESPACE
@@ -277,6 +278,168 @@ private:
QList<Move> &swaps) const;
};
+/*
+ * stack slot allocation:
+ *
+ * foreach bb do
+ * foreach stmt do
+ * if the current statement is not a phi-node:
+ * purge ranges that end before the current statement
+ * check for life ranges to activate, and if they don't have a stackslot associated then allocate one
+ * renumber temps to stack
+ * for phi nodes: check if all temps (src+dst) are assigned stack slots and marked as allocated
+ * if it's a jump:
+ * foreach phi node in the successor:
+ * allocate slots for each temp (both sources and targets) if they don't have one allocated already
+ * insert moves before the jump
+ */
+class AllocateStackSlots: protected ConvertTemps
+{
+ IR::LifeTimeIntervals::Ptr _intervals;
+ QVector<IR::LifeTimeInterval *> _unhandled;
+ QVector<IR::LifeTimeInterval *> _live;
+ QBitArray _slotIsInUse;
+ IR::Function *_function;
+
+ int defPosition(IR::Stmt *s) const
+ {
+ return usePosition(s) + 1;
+ }
+
+ int usePosition(IR::Stmt *s) const
+ {
+ return _intervals->positionForStatement(s);
+ }
+
+public:
+ AllocateStackSlots(const IR::LifeTimeIntervals::Ptr &intervals)
+ : _intervals(intervals)
+ , _slotIsInUse(intervals->size(), false)
+ , _function(0)
+ {
+ _live.reserve(8);
+ _unhandled = _intervals->intervals();
+ }
+
+ void forFunction(IR::Function *function)
+ {
+ IR::Optimizer::showMeTheCode(function, "Before stack slot allocation");
+ _function = function;
+ toStackSlots(function);
+ }
+
+protected:
+ virtual int allocateFreeSlot()
+ {
+ for (int i = 0, ei = _slotIsInUse.size(); i != ei; ++i) {
+ if (!_slotIsInUse[i]) {
+ if (_nextUnusedStackSlot <= i) {
+ Q_ASSERT(_nextUnusedStackSlot == i);
+ _nextUnusedStackSlot = i + 1;
+ }
+ _slotIsInUse[i] = true;
+ return i;
+ }
+ }
+
+ Q_UNREACHABLE();
+ return -1;
+ }
+
+ virtual void process(IR::Stmt *s)
+ {
+// qDebug("L%d statement %d:", _currentBasicBlock->index, s->id);
+
+ if (IR::Phi *phi = s->asPhi()) {
+ visitPhi(phi);
+ } else {
+ // purge ranges no longer alive:
+ for (int i = 0; i < _live.size(); ) {
+ const IR::LifeTimeInterval *lti = _live.at(i);
+ if (lti->end() < usePosition(s)) {
+// qDebug() << "\t - moving temp" << lti->temp().index << "to handled, freeing slot" << _stackSlotForTemp[lti->temp().index];
+ _live.remove(i);
+ Q_ASSERT(_slotIsInUse[_stackSlotForTemp[lti->temp().index]]);
+ _slotIsInUse[_stackSlotForTemp[lti->temp().index]] = false;
+ continue;
+ } else {
+ ++i;
+ }
+ }
+
+ // active new ranges:
+ while (!_unhandled.isEmpty()) {
+ IR::LifeTimeInterval *lti = _unhandled.last();
+ if (lti->start() > defPosition(s))
+ break; // we're done
+ Q_ASSERT(!_stackSlotForTemp.contains(lti->temp().index));
+ _stackSlotForTemp[lti->temp().index] = allocateFreeSlot();
+// qDebug() << "\t - activating temp" << lti->temp().index << "on slot" << _stackSlotForTemp[lti->temp().index];
+ _live.append(lti);
+ _unhandled.removeLast();
+ }
+
+ visit(s);
+ }
+
+ if (IR::Jump *jump = s->asJump()) {
+ IR::MoveMapping moves;
+ for (IR::Stmt *succStmt : jump->target->statements()) {
+ if (IR::Phi *phi = succStmt->asPhi()) {
+ forceActivation(*phi->targetTemp);
+ for (int i = 0, ei = phi->incoming.size(); i != ei; ++i) {
+ IR::Expr *e = phi->incoming[i];
+ if (IR::Temp *t = e->asTemp()) {
+ forceActivation(*t);
+ }
+ if (jump->target->in[i] == _currentBasicBlock)
+ moves.add(phi->incoming[i], phi->targetTemp);
+ }
+ } else {
+ break;
+ }
+ }
+ moves.order();
+ QList<IR::Move *> newMoves = moves.insertMoves(_currentBasicBlock, _function, true);
+ foreach (IR::Move *move, newMoves)
+ visit(move);
+ }
+ }
+
+ void forceActivation(const IR::Temp &t)
+ {
+ if (_stackSlotForTemp.contains(t.index))
+ return;
+
+ int i = _unhandled.size() - 1;
+ for (; i >= 0; --i) {
+ IR::LifeTimeInterval *lti = _unhandled[i];
+ if (lti->temp() == t) {
+ _live.append(lti);
+ _unhandled.remove(i);
+ break;
+ }
+ }
+ Q_ASSERT(i >= 0); // check that we always found the entry
+
+ _stackSlotForTemp[t.index] = allocateFreeSlot();
+// qDebug() << "\t - force activating temp" << t.index << "on slot" << _stackSlotForTemp[t.index];
+ }
+
+ virtual void visitPhi(IR::Phi *phi)
+ {
+ Q_UNUSED(phi);
+#if !defined(QT_NO_DEBUG)
+ Q_ASSERT(_stackSlotForTemp.contains(phi->targetTemp->index));
+ Q_ASSERT(_slotIsInUse[_stackSlotForTemp[phi->targetTemp->index]]);
+ foreach (IR::Expr *e, phi->incoming) {
+ if (IR::Temp *t = e->asTemp())
+ Q_ASSERT(_stackSlotForTemp.contains(t->index));
+ }
+#endif // defined(QT_NO_DEBUG)
+ }
+};
+
} // IR namespace
} // QV4 namespace
diff --git a/src/qml/doc/src/cppintegration/exposecppattributes.qdoc b/src/qml/doc/src/cppintegration/exposecppattributes.qdoc
index c7e4930bfb..f5aea0b01a 100644
--- a/src/qml/doc/src/cppintegration/exposecppattributes.qdoc
+++ b/src/qml/doc/src/cppintegration/exposecppattributes.qdoc
@@ -73,7 +73,7 @@ convert them as appropriately when used from QML. Additionally, C++ classes
that are \l{Registering C++ types with the QML type system}{registered} with
the QML type system can be can be used as data types, as can their enums if
appropriately registered. See \l{qtqml-cppintegration-data.html}{Data Type
-Conversion Between QML and C++} for details for further information.
+Conversion Between QML and C++} for further information.
Additionally, data ownership rules are taken into consideration when data is
transferred from C++ to QML. See \l {Data Ownership} for more details.
diff --git a/src/qml/doc/src/cppintegration/extending-tutorial.qdoc b/src/qml/doc/src/cppintegration/extending-tutorial.qdoc
index c0cfc3e1aa..58cc650e01 100644
--- a/src/qml/doc/src/cppintegration/extending-tutorial.qdoc
+++ b/src/qml/doc/src/cppintegration/extending-tutorial.qdoc
@@ -389,7 +389,7 @@ directory.
When building this example on Windows or Linux, the \c Charts directory will be
located at the same level as the application that uses our new import module.
This way, the QML engine will find our module as the default search path for QML
-imports includes the directory of the application executable. On OS X, the
+imports includes the directory of the application executable. On \macos, the
plugin binary is copied to \c Contents/PlugIns in the the application bundle;
this path is set in \l {tutorials/extending-qml/chapter6-plugins/app.pro}
{chapter6-plugins/app.pro}:
diff --git a/src/qml/doc/src/javascript/hostenvironment.qdoc b/src/qml/doc/src/javascript/hostenvironment.qdoc
index de8b967d72..1e33f2f641 100644
--- a/src/qml/doc/src/javascript/hostenvironment.qdoc
+++ b/src/qml/doc/src/javascript/hostenvironment.qdoc
@@ -80,7 +80,10 @@ Note that QML makes the following modifications to native objects:
QML implements the following restrictions for JavaScript code:
\list
-\li JavaScript code cannot modify the global object.
+\li JavaScript code written in a \c .qml file cannot modify the global object.
+ JavaScript code in a .js file can modify the global object,
+ and those modifications will be visible to the .qml file when
+ \l {Importing a JavaScript Resource from a QML Document}{imported}.
In QML, the global object is constant - existing properties cannot be modified
or deleted, and no new properties may be created.
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 27397fe3d8..f8110d29f6 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -1144,8 +1144,13 @@ static QVariant toVariant(QV4::ExecutionEngine *e, const QV4::Value &value, int
return value.integerValue();
if (value.isNumber())
return value.asDouble();
- if (value.isString())
- return value.stringValue()->toQString();
+ if (value.isString()) {
+ const QString &str = value.toQString();
+ // QChars are stored as a strings
+ if (typeHint == QVariant::Char && str.size() == 1)
+ return str.at(0);
+ return str;
+ }
if (const QV4::QQmlLocaleData *ld = value.as<QV4::QQmlLocaleData>())
return ld->d()->locale;
if (const QV4::DateObject *d = value.as<DateObject>())
@@ -1288,9 +1293,9 @@ QV4::ReturnedValue QV4::ExecutionEngine::fromVariant(const QVariant &variant)
case QMetaType::UShort:
return QV4::Encode((int)*reinterpret_cast<const unsigned short*>(ptr));
case QMetaType::Char:
- return newString(QChar::fromLatin1(*reinterpret_cast<const char *>(ptr)))->asReturnedValue();
+ return QV4::Encode((int)*reinterpret_cast<const char*>(ptr));
case QMetaType::UChar:
- return newString(QChar::fromLatin1(*reinterpret_cast<const unsigned char *>(ptr)))->asReturnedValue();
+ return QV4::Encode((int)*reinterpret_cast<const unsigned char*>(ptr));
case QMetaType::QChar:
return newString(*reinterpret_cast<const QChar *>(ptr))->asReturnedValue();
case QMetaType::QDateTime:
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index b68dbc27b7..eda7774f90 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -58,6 +58,8 @@
#include "qv4value_p.h"
#include "qv4internalclass_p.h"
+#include <QtCore/qtypetraits.h>
+
QT_BEGIN_NAMESPACE
@@ -132,7 +134,7 @@ struct ObjectVTable
#define DEFINE_OBJECT_VTABLE(classname) \
const QV4::ObjectVTable classname::static_vtbl = \
{ \
- DEFINE_MANAGED_VTABLE_INT(classname, &classname::SuperClass::static_vtbl == &Object::static_vtbl ? 0 : &classname::SuperClass::static_vtbl.vTable), \
+ DEFINE_MANAGED_VTABLE_INT(classname, (QT_PREPEND_NAMESPACE(QtPrivate)::is_same<classname::SuperClass, Object>::value) ? Q_NULLPTR : &classname::SuperClass::static_vtbl.vTable), \
call, \
construct, \
get, \
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index c95e767bb0..9032503fdf 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -1262,19 +1262,19 @@ ReturnedValue Runtime::method_unwindException(ExecutionEngine *engine)
void Runtime::method_pushWithScope(const Value &o, ExecutionEngine *engine)
{
engine->pushContext(engine->currentContext->newWithContext(o.toObject(engine)));
- Q_ASSERT(engine->jsStackTop = engine->currentContext + 2);
+ Q_ASSERT(engine->jsStackTop == engine->currentContext + 2);
}
void Runtime::method_pushCatchScope(NoThrowEngine *engine, int exceptionVarNameIndex)
{
ExecutionContext *c = engine->currentContext;
engine->pushContext(c->newCatchContext(c->d()->compilationUnit->runtimeStrings[exceptionVarNameIndex], engine->catchException(0)));
- Q_ASSERT(engine->jsStackTop = engine->currentContext + 2);
+ Q_ASSERT(engine->jsStackTop == engine->currentContext + 2);
}
void Runtime::method_popScope(ExecutionEngine *engine)
{
- Q_ASSERT(engine->jsStackTop = engine->currentContext + 2);
+ Q_ASSERT(engine->jsStackTop == engine->currentContext + 2);
engine->popContext();
engine->jsStackTop -= 2;
}
diff --git a/src/qml/memory/qv4mm.cpp b/src/qml/memory/qv4mm.cpp
index 53b9ebfe2a..3d25bd1639 100644
--- a/src/qml/memory/qv4mm.cpp
+++ b/src/qml/memory/qv4mm.cpp
@@ -456,7 +456,7 @@ void MemoryManager::sweep(bool lastSweep)
Managed *m = (*it).managed();
if (m->markBit())
continue;
- // we need to call detroyObject on qobjectwrappers now, so that they can emit the destroyed
+ // we need to call destroyObject on qobjectwrappers now, so that they can emit the destroyed
// signal before we start sweeping the heap
if (QObjectWrapper *qobjectWrapper = (*it).as<QObjectWrapper>())
qobjectWrapper->destroyObject(lastSweep);
@@ -464,6 +464,17 @@ void MemoryManager::sweep(bool lastSweep)
(*it) = Primitive::undefinedValue();
}
+ // onDestruction handlers may have accessed other QObject wrappers and reset their value, so ensure
+ // that they are all set to undefined.
+ for (PersistentValueStorage::Iterator it = m_weakValues->begin(); it != m_weakValues->end(); ++it) {
+ if (!(*it).isManaged())
+ continue;
+ Managed *m = (*it).as<Managed>();
+ if (m->markBit())
+ continue;
+ (*it) = Primitive::undefinedValue();
+ }
+
// Now it is time to free QV4::QObjectWrapper Value, we must check the Value's tag to make sure its object has been destroyed
const int pendingCount = m_pendingFreedObjectWrapperValue.count();
if (pendingCount) {
diff --git a/src/qml/qml/ftw/ftw.pri b/src/qml/qml/ftw/ftw.pri
index 2d4a82e2f4..87d80d04bc 100644
--- a/src/qml/qml/ftw/ftw.pri
+++ b/src/qml/qml/ftw/ftw.pri
@@ -8,7 +8,6 @@ HEADERS += \
$$PWD/qqmlthread_p.h \
$$PWD/qfinitestack_p.h \
$$PWD/qrecursionwatcher_p.h \
- $$PWD/qdeletewatcher_p.h \
$$PWD/qrecyclepool_p.h \
$$PWD/qflagpointer_p.h \
$$PWD/qlazilyallocated_p.h \
@@ -22,4 +21,4 @@ SOURCES += \
# mirrors logic in $$QT_SOURCE_TREE/config.tests/unix/clock-gettime/clock-gettime.pri
# clock_gettime() is implemented in librt on these systems
-contains(QT_CONFIG, clock-gettime):linux-*|hpux-*|solaris-*:LIBS_PRIVATE *= -lrt
+qtConfig(clock-gettime):linux-*|hpux-*|solaris-*:LIBS_PRIVATE *= -lrt
diff --git a/src/qml/qml/qml.pri b/src/qml/qml/qml.pri
index 87be140cbb..4244b16210 100644
--- a/src/qml/qml/qml.pri
+++ b/src/qml/qml/qml.pri
@@ -49,7 +49,8 @@ SOURCES += \
$$PWD/qqmlfileselector.cpp \
$$PWD/qqmlobjectcreator.cpp \
$$PWD/qqmldirparser.cpp \
- $$PWD/qqmldelayedcallqueue.cpp
+ $$PWD/qqmldelayedcallqueue.cpp \
+ $$PWD/qqmlloggingcategory.cpp
HEADERS += \
$$PWD/qqmlglobal_p.h \
@@ -121,7 +122,8 @@ HEADERS += \
$$PWD/qqmlfileselector.h \
$$PWD/qqmlobjectcreator_p.h \
$$PWD/qqmldirparser_p.h \
- $$PWD/qqmldelayedcallqueue_p.h
+ $$PWD/qqmldelayedcallqueue_p.h \
+ $$PWD/qqmlloggingcategory_p.h
include(ftw/ftw.pri)
include(v8/v8.pri)
diff --git a/src/qml/qml/qqmlbinding.cpp b/src/qml/qml/qqmlbinding.cpp
index 8ed7641610..d944857fc1 100644
--- a/src/qml/qml/qqmlbinding.cpp
+++ b/src/qml/qml/qqmlbinding.cpp
@@ -191,7 +191,7 @@ void QQmlBinding::update(QQmlPropertyData::WriteFlags flags)
flags.setFlag(QQmlPropertyData::BypassInterceptor);
QQmlBindingProfiler prof(ep->profiler, this, f);
- doUpdate(this, watcher, flags, scope, f);
+ doUpdate(watcher, flags, scope, f);
if (!watcher.wasDeleted())
setUpdatingFlag(false);
@@ -205,14 +205,15 @@ void QQmlBinding::update(QQmlPropertyData::WriteFlags flags)
class QQmlBindingBinding: public QQmlBinding
{
protected:
- void doUpdate(QQmlBinding *binding, const DeleteWatcher &,
+ void doUpdate(const DeleteWatcher &,
QQmlPropertyData::WriteFlags flags, QV4::Scope &,
const QV4::ScopedFunctionObject &) Q_DECL_OVERRIDE Q_DECL_FINAL
{
Q_ASSERT(!m_targetIndex.hasValueTypeIndex());
QQmlPropertyData *pd = nullptr;
getPropertyData(&pd, nullptr);
- pd->writeProperty(*m_target, &binding, flags);
+ QQmlBinding *thisPtr = this;
+ pd->writeProperty(*m_target, &thisPtr, flags);
}
};
@@ -221,7 +222,7 @@ protected:
class QQmlNonbindingBinding: public QQmlBinding
{
protected:
- void doUpdate(QQmlBinding *binding, const DeleteWatcher &watcher,
+ void doUpdate(const DeleteWatcher &watcher,
QQmlPropertyData::WriteFlags flags, QV4::Scope &scope,
const QV4::ScopedFunctionObject &f) Q_DECL_OVERRIDE Q_DECL_FINAL
{
@@ -231,7 +232,7 @@ protected:
bool isUndefined = false;
QV4::ScopedCallData callData(scope);
- binding->QQmlJavaScriptExpression::evaluate(callData, &isUndefined, scope);
+ QQmlJavaScriptExpression::evaluate(callData, &isUndefined, scope);
bool error = false;
if (!watcher.wasDeleted() && isAddedToObject() && !hasError())
diff --git a/src/qml/qml/qqmlbinding_p.h b/src/qml/qml/qqmlbinding_p.h
index 1801c3040c..6d42a8ea8a 100644
--- a/src/qml/qml/qqmlbinding_p.h
+++ b/src/qml/qml/qqmlbinding_p.h
@@ -102,7 +102,7 @@ public:
void expressionChanged() Q_DECL_OVERRIDE;
protected:
- virtual void doUpdate(QQmlBinding *binding, const DeleteWatcher &watcher,
+ virtual void doUpdate(const DeleteWatcher &watcher,
QQmlPropertyData::WriteFlags flags, QV4::Scope &scope,
const QV4::ScopedFunctionObject &f) = 0;
diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp
index cdaa9e83e9..7e4fe73ba1 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -89,6 +89,7 @@
#include <private/qqmlobjectmodel_p.h>
#include <private/qquickworkerscript_p.h>
#include <private/qqmlinstantiator_p.h>
+#include <private/qqmlloggingcategory_p.h>
#ifdef Q_OS_WIN // for %APPDATA%
# include <qt_windows.h>
@@ -187,6 +188,7 @@ void QQmlEnginePrivate::registerBaseTypes(const char *uri, int versionMajor, int
qmlRegisterType<QQmlInstantiator>(uri, versionMajor, (versionMinor < 1 ? 1 : versionMinor), "Instantiator"); //Only available in >=2.1
qmlRegisterCustomType<QQmlConnections>(uri, versionMajor, versionMinor,"Connections", new QQmlConnectionsParser);
qmlRegisterType<QQmlInstanceModel>();
+ qmlRegisterType<QQmlLoggingCategory>(uri, versionMajor, (versionMinor < 8 ? 8 : versionMinor), "LoggingCategory"); //Only available in >=2.8
}
@@ -405,10 +407,9 @@ The following functions are also on the Qt object.
\li \c "ios" - iOS
\li \c "tvos" - tvOS
\li \c "linux" - Linux
- \li \c "osx" - OS X
+ \li \c "osx" - \macos
\li \c "unix" - Other Unix-based OS
\li \c "windows" - Windows
- \li \c "wince" - Windows CE
\li \c "winrt" - Windows Runtime
\li \c "winphone" - Windows Phone
\endlist
diff --git a/src/qml/qml/qqmlexpression_p.h b/src/qml/qml/qqmlexpression_p.h
index 741c25e206..809a57b169 100644
--- a/src/qml/qml/qqmlexpression_p.h
+++ b/src/qml/qml/qqmlexpression_p.h
@@ -56,7 +56,6 @@
#include <private/qqmlengine_p.h>
#include <private/qfieldlist_p.h>
#include <private/qflagpointer_p.h>
-#include <private/qdeletewatcher_p.h>
#include <private/qqmljavascriptexpression_p.h>
QT_BEGIN_NAMESPACE
diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp
index 63e8da3aa8..ee4d3efa6f 100644
--- a/src/qml/qml/qqmlimport.cpp
+++ b/src/qml/qml/qqmlimport.cpp
@@ -1717,7 +1717,7 @@ QString QQmlImportDatabase::resolvePlugin(QQmlTypeLoader *typeLoader,
\header \li Platform \li Valid suffixes
\row \li Windows \li \c .dll
\row \li Unix/Linux \li \c .so
- \row \li OS X \li \c .dylib, \c .bundle, \c .so
+ \row \li \macos \li \c .dylib, \c .bundle, \c .so
\endtable
Version number on unix are ignored.
diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp
index 5d96240e5b..ebc4d49c36 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -235,7 +235,7 @@ void QQmlPropertyCapture::captureProperty(QQmlNotifier *n, Duration duration)
g->connect(n);
}
- if (duration == OnlyOnce)
+ if (duration == Permanently)
expression->permanentGuards.prepend(g);
else
expression->activeGuards.prepend(g);
@@ -301,7 +301,7 @@ void QQmlPropertyCapture::registerQmlDependencies(const QV4::CompiledData::Funct
if (!ep)
return;
QQmlPropertyCapture *capture = ep->propertyCapture;
- if (!capture)
+ if (!capture || capture->watcher->wasDeleted())
return;
if (capture->expression->m_permanentDependenciesRegistered)
diff --git a/src/qml/qml/qqmlloggingcategory.cpp b/src/qml/qml/qqmlloggingcategory.cpp
new file mode 100644
index 0000000000..88cf14cba0
--- /dev/null
+++ b/src/qml/qml/qqmlloggingcategory.cpp
@@ -0,0 +1,128 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qqmlloggingcategory_p.h"
+
+#include <QtQml/qqmlinfo.h>
+
+/*!
+ \qmltype LoggingCategory
+ \ingroup qml-utility-elements
+ \inqmlmodule QtQml
+ \brief Defines a logging category in QML
+ \since 5.8
+
+ A logging category can be passed to console.log() and friends as the first argument.
+ If supplied to to the logger the LoggingCategory's name will be used as Logging Category
+ otherwise the default logging category will be used.
+
+ \qml
+ import QtQuick 2.8
+
+ Item {
+ LoggingCategory {
+ id: category
+ name: "com.qt.category"
+ }
+
+ Component.onCompleted: {
+ console.log(category, "message");
+ }
+ }
+ \endqml
+
+ \note As the creation of objects is expensive, it is encouraged to put the needed
+ LoggingCategory definitions into a singleton and import this where needed.
+
+ \sa QLoggingCategory
+*/
+
+/*!
+ \qmlproperty string QtQml::LoggingCategory::name
+
+ Holds the name of the logging category.
+
+ \note This property needs to be set when declaring the LoggingCategory
+ and cannot be changed later.
+
+ \sa QLoggingCategory::name()
+*/
+
+QQmlLoggingCategory::QQmlLoggingCategory(QObject *parent)
+ : QObject(parent)
+ , m_initialized(false)
+{
+}
+
+QQmlLoggingCategory::~QQmlLoggingCategory()
+{
+}
+
+QString QQmlLoggingCategory::name() const
+{
+ return QString::fromUtf8(m_name);
+}
+
+QLoggingCategory *QQmlLoggingCategory::category() const
+{
+ return m_category.data();
+}
+
+void QQmlLoggingCategory::classBegin()
+{
+}
+
+void QQmlLoggingCategory::componentComplete()
+{
+ m_initialized = true;
+ if (m_name.isNull())
+ qmlInfo(this) << QString(QLatin1String("Declaring the name of the LoggingCategory is mandatory and cannot be changed later !"));
+}
+
+void QQmlLoggingCategory::setName(const QString &name)
+{
+ if (m_initialized) {
+ qmlInfo(this) << QString(QLatin1String("The name of a LoggingCategory cannot be changed after the Item is created"));
+ return;
+ }
+
+ m_name = name.toUtf8();
+ QScopedPointer<QLoggingCategory> category(new QLoggingCategory(m_name.constData()));
+ m_category.swap(category);
+}
diff --git a/src/qml/qml/ftw/qdeletewatcher_p.h b/src/qml/qml/qqmlloggingcategory_p.h
index d4c0c6dfb2..2b7f2f5b53 100644
--- a/src/qml/qml/ftw/qdeletewatcher_p.h
+++ b/src/qml/qml/qqmlloggingcategory_p.h
@@ -1,6 +1,6 @@
/****************************************************************************
**
-** Copyright (C) 2016 The Qt Company Ltd.
+** Copyright (C) 2016 Pelagicore AG
** Contact: https://www.qt.io/licensing/
**
** This file is part of the QtQml module of the Qt Toolkit.
@@ -37,8 +37,8 @@
**
****************************************************************************/
-#ifndef QDELETEWATCHER_P_H
-#define QDELETEWATCHER_P_H
+#ifndef QQMLLOGGINGCATEGORY_P_H
+#define QQMLLOGGINGCATEGORY_P_H
//
// W A R N I N G
@@ -51,61 +51,39 @@
// We mean it.
//
-#include <QtCore/qglobal.h>
+#include <QtCore/qobject.h>
+#include <QtCore/qstring.h>
+#include <QtCore/qloggingcategory.h>
+
+#include <QtQml/qqmlparserstatus.h>
QT_BEGIN_NAMESPACE
-class QDeleteWatchable
+class QQmlLoggingCategory : public QObject, public QQmlParserStatus
{
-public:
- inline QDeleteWatchable();
- inline ~QDeleteWatchable();
-private:
- friend class QDeleteWatcher;
- bool *_w;
-};
+ Q_OBJECT
+ Q_INTERFACES(QQmlParserStatus)
-class QDeleteWatcher {
-public:
- inline QDeleteWatcher(QDeleteWatchable *data);
- inline ~QDeleteWatcher();
- inline bool wasDeleted() const;
-private:
- void *operator new(size_t);
- bool *_w;
- bool _s;
- QDeleteWatchable *m_d;
-};
+ Q_PROPERTY(QString name READ name WRITE setName)
-QDeleteWatchable::QDeleteWatchable()
-: _w(0)
-{
-}
+public:
+ QQmlLoggingCategory(QObject *parent = 0);
+ virtual ~QQmlLoggingCategory();
-QDeleteWatchable::~QDeleteWatchable()
-{
- if (_w) *_w = true;
-}
+ QString name() const;
+ void setName(const QString &name);
-QDeleteWatcher::QDeleteWatcher(QDeleteWatchable *data)
-: _s(false), m_d(data)
-{
- if (!m_d->_w)
- m_d->_w = &_s;
- _w = m_d->_w;
-}
+ QLoggingCategory *category() const;
-QDeleteWatcher::~QDeleteWatcher()
-{
- if (false == *_w && &_s == m_d->_w)
- m_d->_w = 0;
-}
+ void classBegin() override;
+ void componentComplete() override;
-bool QDeleteWatcher::wasDeleted() const
-{
- return *_w;
-}
+private:
+ QByteArray m_name;
+ QScopedPointer<QLoggingCategory> m_category;
+ bool m_initialized;
+};
QT_END_NAMESPACE
-#endif // QDELETEWATCHER_P_H
+#endif // QQMLLOGGINGCATEGORY_H
diff --git a/src/qml/qml/qqmlobjectcreator.cpp b/src/qml/qml/qqmlobjectcreator.cpp
index f9794ec26a..e02d362815 100644
--- a/src/qml/qml/qqmlobjectcreator.cpp
+++ b/src/qml/qml/qqmlobjectcreator.cpp
@@ -75,12 +75,12 @@ QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QV4::Compil
, compilationUnit(compilationUnit)
, resolvedTypes(compilationUnit->resolvedTypes)
, propertyCaches(&compilationUnit->propertyCaches)
+ , sharedState(new QQmlObjectCreatorSharedState)
+ , topLevelCreator(true)
, activeVMEDataForRootContext(activeVMEDataForRootContext)
{
init(parentContext);
- sharedState = new QQmlObjectCreatorSharedState;
- topLevelCreator = true;
sharedState->componentAttached = 0;
sharedState->allCreatedBindings.allocate(compilationUnit->totalBindingsCount);
sharedState->allParserStatusCallbacks.allocate(compilationUnit->totalParserStatusCount);
@@ -102,12 +102,11 @@ QQmlObjectCreator::QQmlObjectCreator(QQmlContextData *parentContext, QV4::Compil
, compilationUnit(compilationUnit)
, resolvedTypes(compilationUnit->resolvedTypes)
, propertyCaches(&compilationUnit->propertyCaches)
+ , sharedState(inheritedSharedState)
+ , topLevelCreator(false)
, activeVMEDataForRootContext(0)
{
init(parentContext);
-
- sharedState = inheritedSharedState;
- topLevelCreator = false;
}
void QQmlObjectCreator::init(QQmlContextData *providedParentContext)
@@ -123,6 +122,7 @@ void QQmlObjectCreator::init(QQmlContextData *providedParentContext)
context = 0;
_qobject = 0;
_scopeObject = 0;
+ _bindingTarget = 0;
_valueTypeProperty = 0;
_compiledObject = 0;
_compiledObjectIndex = -1;
diff --git a/src/qml/qml/qqmlproperty.cpp b/src/qml/qml/qqmlproperty.cpp
index 7b1e2ec4f6..c62fef7c3d 100644
--- a/src/qml/qml/qqmlproperty.cpp
+++ b/src/qml/qml/qqmlproperty.cpp
@@ -1321,29 +1321,8 @@ bool QQmlPropertyPrivate::write(QObject *object,
bool ok = false;
QVariant v;
- if (variantType == QVariant::String) {
- const QString &str = value.toString();
- const bool targetIsChar = (propertyType == qMetaTypeId<QChar>()
- || propertyType == qMetaTypeId<char>()
- || propertyType == qMetaTypeId<unsigned char>());
- // If the string contains only one character and the target is a char, try converting it.
- if (targetIsChar) {
- if (str.size() != 1)
- return false; // We can only convert if the string contains exactly one character.
-
- const QChar &qChar = str.at(0);
- if (propertyType == qMetaTypeId<QChar>()) {
- v = qChar;
- ok = true;
- } else if (propertyType == qMetaTypeId<char>() || propertyType == qMetaTypeId<unsigned char>()) {
- const char c = qChar.toLatin1();
- v = c;
- ok = (qChar == c);
- }
- } else {
- v = QQmlStringConverters::variantFromString(str, propertyType, &ok);
- }
- }
+ if (variantType == QVariant::String)
+ v = QQmlStringConverters::variantFromString(value.toString(), propertyType, &ok);
if (!ok) {
v = value;
diff --git a/src/qml/qml/qqmlpropertycache.cpp b/src/qml/qml/qqmlpropertycache.cpp
index 7cb1425725..5c53e342f3 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -678,7 +678,6 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject,
Q_ASSERT(accessorProperty == 0 || (old == 0 && data->revision() == 0));
if (accessorProperty) {
- data->_flags.hasAccessors = true;
data->setAccessors(accessorProperty->accessors);
} else if (old) {
data->markAsOverrideOf(old);
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index 8a1f3810aa..63a9c63d90 100644
--- a/src/qml/qml/qqmlpropertycache_p.h
+++ b/src/qml/qml/qqmlpropertycache_p.h
@@ -108,7 +108,6 @@ public:
unsigned isFinal : 1; // Has FINAL flag
unsigned isOverridden : 1; // Is overridden by a extension property
unsigned isDirect : 1; // Exists on a C++ QMetaObject
- unsigned hasAccessors : 1; // Has property accessors
unsigned type : 4; // stores an entry of Types
@@ -127,7 +126,7 @@ public:
unsigned notFullyResolved : 1; // True if the type data is to be lazily resolved
unsigned overrideIndexIsProperty: 1;
- unsigned _padding : 9; // align to 32 bits
+ unsigned _padding : 10; // align to 32 bits
inline Flags();
inline bool operator==(const Flags &other) const;
@@ -147,7 +146,7 @@ public:
bool isFinal() const { return _flags.isFinal; }
bool isOverridden() const { return _flags.isOverridden; }
bool isDirect() const { return _flags.isDirect; }
- bool hasAccessors() const { return _flags.hasAccessors; }
+ bool hasAccessors() const { return accessors() != nullptr; }
bool isFunction() const { return _flags.type == Flags::FunctionType; }
bool isQObject() const { return _flags.type == Flags::QObjectDerivedType; }
bool isEnum() const { return _flags.type == Flags::EnumType; }
@@ -168,20 +167,45 @@ public:
bool isCloned() const { return _flags.isCloned; }
bool isConstructor() const { return _flags.isConstructor; }
- bool hasOverride() const { return !(_flags.hasAccessors) &&
- overrideIndex() >= 0; }
- bool hasRevision() const { return !(_flags.hasAccessors) && revision() != 0; }
+ bool hasOverride() const { return overrideIndex() >= 0; }
+ bool hasRevision() const { return revision() != 0; }
bool isFullyResolved() const { return !_flags.notFullyResolved; }
int propType() const { Q_ASSERT(isFullyResolved()); return _propType; }
- void setPropType(int pt) { _propType = pt; }
+ void setPropType(int pt)
+ {
+ Q_ASSERT(pt >= 0);
+ Q_ASSERT(pt <= std::numeric_limits<qint16>::max());
+ _propType = quint16(pt);
+ }
int notifyIndex() const { return _notifyIndex; }
- void setNotifyIndex(int idx) { _notifyIndex = idx; }
+ void setNotifyIndex(int idx)
+ {
+ Q_ASSERT(idx >= std::numeric_limits<qint16>::min());
+ Q_ASSERT(idx <= std::numeric_limits<qint16>::max());
+ _notifyIndex = qint16(idx);
+ }
- QQmlPropertyCacheMethodArguments *arguments() const { return _arguments; }
- void setArguments(QQmlPropertyCacheMethodArguments *args) { _arguments = args; }
+ bool overrideIndexIsProperty() const { return _flags.overrideIndexIsProperty; }
+ void setOverrideIndexIsProperty(bool onoff) { _flags.overrideIndexIsProperty = onoff; }
+
+ int overrideIndex() const { return _overrideIndex; }
+ void setOverrideIndex(int idx)
+ {
+ Q_ASSERT(idx >= std::numeric_limits<qint16>::min());
+ Q_ASSERT(idx <= std::numeric_limits<qint16>::max());
+ _overrideIndex = qint16(idx);
+ }
+
+ int coreIndex() const { return _coreIndex; }
+ void setCoreIndex(int idx)
+ {
+ Q_ASSERT(idx >= std::numeric_limits<qint16>::min());
+ Q_ASSERT(idx <= std::numeric_limits<qint16>::max());
+ _coreIndex = qint16(idx);
+ }
int revision() const { return _revision; }
void setRevision(int rev)
@@ -191,6 +215,9 @@ public:
_revision = qint16(rev);
}
+ QQmlPropertyCacheMethodArguments *arguments() const { return _arguments; }
+ void setArguments(QQmlPropertyCacheMethodArguments *args) { _arguments = args; }
+
int metaObjectOffset() const { return _metaObjectOffset; }
void setMetaObjectOffset(int off)
{
@@ -199,51 +226,35 @@ public:
_metaObjectOffset = qint16(off);
}
- bool overrideIndexIsProperty() const { return _flags.overrideIndexIsProperty; }
- void setOverrideIndexIsProperty(bool onoff) { _flags.overrideIndexIsProperty = onoff; }
-
- int overrideIndex() const { return _overrideIndex; }
- void setOverrideIndex(int idx)
- {
- Q_ASSERT(idx >= std::numeric_limits<qint16>::min());
- Q_ASSERT(idx <= std::numeric_limits<qint16>::max());
- _overrideIndex = idx;
- }
-
QQmlAccessors *accessors() const { return _accessors; }
void setAccessors(QQmlAccessors *acc) { _accessors = acc; }
- int coreIndex() const { return _coreIndex; }
- void setCoreIndex(int idx) { _coreIndex = idx; }
-
private:
- int _propType; // When !NotFullyResolved
- union {
- // The notify index is in the range returned by QObjectPrivate::signalIndex().
- // This is different from QMetaMethod::methodIndex().
- int _notifyIndex; // When !IsFunction
- QQmlPropertyCacheMethodArguments *_arguments; // When IsFunction && HasArguments
- };
+ Flags _flags;
+ qint16 _coreIndex;
+ quint16 _propType;
- union {
- struct { // When !HasAccessors
- qint16 _revision;
- qint16 _metaObjectOffset;
+ // The notify index is in the range returned by QObjectPrivate::signalIndex().
+ // This is different from QMetaMethod::methodIndex().
+ qint16 _notifyIndex;
+ qint16 _overrideIndex;
- signed int _overrideIndex; // When !IsValueTypeVirtual
- };
- struct { // When HasAccessors
- QQmlAccessors *_accessors;
- };
- };
+ qint16 _revision;
+ qint16 _metaObjectOffset;
- int _coreIndex;
- Flags _flags;
+ QQmlPropertyCacheMethodArguments *_arguments;
+ QQmlAccessors *_accessors;
friend class QQmlPropertyData;
friend class QQmlPropertyCache;
};
+#if QT_POINTER_SIZE == 4
+Q_STATIC_ASSERT(sizeof(QQmlPropertyRawData) == 24);
+#else // QT_POINTER_SIZE == 8
+Q_STATIC_ASSERT(sizeof(QQmlPropertyRawData) == 32);
+#endif
+
class QQmlPropertyData : public QQmlPropertyRawData
{
public:
@@ -564,7 +575,6 @@ QQmlPropertyRawData::Flags::Flags()
, isFinal(false)
, isOverridden(false)
, isDirect(false)
- , hasAccessors(false)
, type(OtherType)
, isVMEFunction(false)
, hasArguments(false)
@@ -588,7 +598,6 @@ bool QQmlPropertyRawData::Flags::operator==(const QQmlPropertyRawData::Flags &ot
isAlias == other.isAlias &&
isFinal == other.isFinal &&
isOverridden == other.isOverridden &&
- hasAccessors == other.hasAccessors &&
type == other.type &&
isVMEFunction == other.isVMEFunction &&
hasArguments == other.hasArguments &&
@@ -619,12 +628,14 @@ void QQmlPropertyRawData::Flags::copyPropertyTypeFlags(QQmlPropertyRawData::Flag
QQmlPropertyData::QQmlPropertyData()
{
+ setCoreIndex(-1);
setPropType(0);
setNotifyIndex(-1);
setOverrideIndex(-1);
setRevision(0);
setMetaObjectOffset(-1);
- setCoreIndex(-1);
+ setArguments(nullptr);
+ setAccessors(nullptr);
}
QQmlPropertyData::QQmlPropertyData(const QQmlPropertyRawData &d)
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index fd36f76d0e..5d70b17ece 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -42,6 +42,7 @@
#include <QtQml/qqmlcomponent.h>
#include <private/qqmlengine_p.h>
#include <private/qqmlcomponent_p.h>
+#include <private/qqmlloggingcategory_p.h>
#include <private/qqmlstringconverters_p.h>
#include <private/qqmllocale_p.h>
#include <private/qv8engine_p.h>
@@ -76,6 +77,8 @@
#include <QtCore/qcoreapplication.h>
#include <QtCore/qloggingcategory.h>
+#include <QDebug>
+
QT_BEGIN_NAMESPACE
using namespace QV4;
@@ -1491,11 +1494,26 @@ static QString jsStack(QV4::ExecutionEngine *engine) {
static QV4::ReturnedValue writeToConsole(ConsoleLogTypes logType, CallContext *ctx,
bool printStack = false)
{
+ QLoggingCategory *loggingCategory = 0;
QString result;
QV4::ExecutionEngine *v4 = ctx->d()->engine;
- for (int i = 0; i < ctx->argc(); ++i) {
- if (i != 0)
+ int start = 0;
+ if (ctx->argc() > 0) {
+ if (const QObjectWrapper* wrapper = ctx->args()[0].as<QObjectWrapper>()) {
+ if (QQmlLoggingCategory* category = qobject_cast<QQmlLoggingCategory*>(wrapper->object())) {
+ if (category->category())
+ loggingCategory = category->category();
+ else
+ V4THROW_ERROR("A QmlLoggingCatgory was provided without a valid name");
+ start = 1;
+ }
+ }
+ }
+
+
+ for (int i = start; i < ctx->argc(); ++i) {
+ if (i != start)
result.append(QLatin1Char(' '));
if (ctx->args()[i].as<ArrayObject>())
@@ -1510,7 +1528,8 @@ static QV4::ReturnedValue writeToConsole(ConsoleLogTypes logType, CallContext *c
static QLoggingCategory qmlLoggingCategory("qml");
static QLoggingCategory jsLoggingCategory("js");
- QLoggingCategory *loggingCategory = v4->qmlEngine() ? &qmlLoggingCategory : &jsLoggingCategory;
+ if (!loggingCategory)
+ loggingCategory = v4->qmlEngine() ? &qmlLoggingCategory : &jsLoggingCategory;
QV4::StackFrame frame = v4->currentStackFrame();
const QByteArray baSource = frame.source.toUtf8();
const QByteArray baFunction = frame.function.toUtf8();
diff --git a/src/qmltest/quicktestevent.cpp b/src/qmltest/quicktestevent.cpp
index b83aaa1ea5..f722fab6c4 100644
--- a/src/qmltest/quicktestevent.cpp
+++ b/src/qmltest/quicktestevent.cpp
@@ -45,6 +45,10 @@
QT_BEGIN_NAMESPACE
+namespace QTest {
+ extern int Q_TESTLIB_EXPORT defaultMouseDelay();
+}
+
QuickTestEvent::QuickTestEvent(QObject *parent)
: QObject(parent)
{
@@ -54,6 +58,11 @@ QuickTestEvent::~QuickTestEvent()
{
}
+int QuickTestEvent::defaultMouseDelay() const
+{
+ return QTest::defaultMouseDelay();
+}
+
bool QuickTestEvent::keyPress(int key, int modifiers, int delay)
{
QWindow *window = activeWindow();
@@ -111,10 +120,6 @@ bool QuickTestEvent::keyClickChar(const QString &character, int modifiers, int d
return true;
}
-namespace QTest {
- extern int Q_TESTLIB_EXPORT defaultMouseDelay();
-};
-
namespace QtQuickTest
{
enum MouseAction { MousePress, MouseRelease, MouseClick, MouseDoubleClick, MouseMove, MouseDoubleClickSequence };
diff --git a/src/qmltest/quicktestevent_p.h b/src/qmltest/quicktestevent_p.h
index 02b8b2c46b..1adf8f3317 100644
--- a/src/qmltest/quicktestevent_p.h
+++ b/src/qmltest/quicktestevent_p.h
@@ -59,9 +59,11 @@ QT_BEGIN_NAMESPACE
class Q_QUICK_TEST_EXPORT QuickTestEvent : public QObject
{
Q_OBJECT
+ Q_PROPERTY(int defaultMouseDelay READ defaultMouseDelay FINAL)
public:
QuickTestEvent(QObject *parent = 0);
~QuickTestEvent();
+ int defaultMouseDelay() const;
public Q_SLOTS:
bool keyPress(int key, int modifiers, int delay);
diff --git a/src/quick/accessible/qaccessiblequickitem.cpp b/src/quick/accessible/qaccessiblequickitem.cpp
index a56d098717..acea958e20 100644
--- a/src/quick/accessible/qaccessiblequickitem.cpp
+++ b/src/quick/accessible/qaccessiblequickitem.cpp
@@ -160,9 +160,9 @@ int QAccessibleQuickItem::indexOfChild(const QAccessibleInterface *iface) const
static void unignoredChildren(QQuickItem *item, QList<QQuickItem *> *items, bool paintOrder)
{
- QList<QQuickItem*> childItems = paintOrder ? QQuickItemPrivate::get(item)->paintOrderChildItems()
+ const QList<QQuickItem*> childItems = paintOrder ? QQuickItemPrivate::get(item)->paintOrderChildItems()
: item->childItems();
- Q_FOREACH (QQuickItem *child, childItems) {
+ for (QQuickItem *child : childItems) {
if (QQuickItemPrivate::get(child)->isAccessible) {
items->append(child);
} else {
diff --git a/src/quick/designer/qquickdesignercustomobjectdata.cpp b/src/quick/designer/qquickdesignercustomobjectdata.cpp
index 3c8f4b281c..e37254d165 100644
--- a/src/quick/designer/qquickdesignercustomobjectdata.cpp
+++ b/src/quick/designer/qquickdesignercustomobjectdata.cpp
@@ -145,10 +145,10 @@ void QQuickDesignerCustomObjectData::keepBindingFromGettingDeleted(QObject *obje
void QQuickDesignerCustomObjectData::populateResetHashes()
{
- QQuickDesignerSupport::PropertyNameList propertyNameList =
+ const QQuickDesignerSupport::PropertyNameList propertyNameList =
QQuickDesignerSupportProperties::propertyNameListForWritableProperties(object());
- Q_FOREACH (const QQuickDesignerSupport::PropertyName &propertyName, propertyNameList) {
+ for (const QQuickDesignerSupport::PropertyName &propertyName : propertyNameList) {
QQmlProperty property(object(), QString::fromUtf8(propertyName), QQmlEngine::contextForObject(object()));
QQmlAbstractBinding::Ptr binding = QQmlAbstractBinding::Ptr(QQmlPropertyPrivate::binding(property));
diff --git a/src/quick/designer/qquickdesignersupport.cpp b/src/quick/designer/qquickdesignersupport.cpp
index f063cd3a81..44be12bb78 100644
--- a/src/quick/designer/qquickdesignersupport.cpp
+++ b/src/quick/designer/qquickdesignersupport.cpp
@@ -236,7 +236,8 @@ bool QQuickDesignerSupport::isAnchoredTo(QQuickItem *fromItem, QQuickItem *toIte
bool QQuickDesignerSupport::areChildrenAnchoredTo(QQuickItem *fromItem, QQuickItem *toItem)
{
- Q_FOREACH (QQuickItem *childItem, fromItem->childItems()) {
+ const auto childItems = fromItem->childItems();
+ for (QQuickItem *childItem : childItems) {
if (childItem) {
if (isAnchoredTo(childItem, toItem))
return true;
@@ -392,10 +393,10 @@ void QQuickDesignerSupport::emitComponentCompleteSignalForAttachedProperty(QQuic
QList<QObject*> QQuickDesignerSupport::statesForItem(QQuickItem *item)
{
QList<QObject*> objectList;
- QList<QQuickState *> stateList = QQuickItemPrivate::get(item)->_states()->states();
+ const QList<QQuickState *> stateList = QQuickItemPrivate::get(item)->_states()->states();
objectList.reserve(stateList.size());
- Q_FOREACH (QQuickState* state, stateList)
+ for (QQuickState* state : stateList)
objectList.append(state);
return objectList;
diff --git a/src/quick/designer/qquickdesignersupportitems.cpp b/src/quick/designer/qquickdesignersupportitems.cpp
index 544ca04754..2003b484ad 100644
--- a/src/quick/designer/qquickdesignersupportitems.cpp
+++ b/src/quick/designer/qquickdesignersupportitems.cpp
@@ -118,16 +118,16 @@ static void allSubObjects(QObject *object, QObjectList &objectList)
}
// search recursive in object children list
- Q_FOREACH (QObject *childObject, object->children()) {
+ for (QObject *childObject : object->children()) {
allSubObjects(childObject, objectList);
}
// search recursive in quick item childItems list
QQuickItem *quickItem = qobject_cast<QQuickItem*>(object);
if (quickItem) {
- Q_FOREACH (QQuickItem *childItem, quickItem->childItems()) {
+ const auto childItems = quickItem->childItems();
+ for (QQuickItem *childItem : childItems)
allSubObjects(childItem, objectList);
- }
}
}
@@ -135,7 +135,7 @@ void QQuickDesignerSupportItems::tweakObjects(QObject *object)
{
QObjectList objectList;
allSubObjects(object, objectList);
- Q_FOREACH (QObject* childObject, objectList) {
+ for (QObject* childObject : qAsConst(objectList)) {
stopAnimation(childObject);
if (fixResourcePathsForObjectCallBack)
fixResourcePathsForObjectCallBack(childObject);
@@ -254,7 +254,8 @@ QObject *QQuickDesignerSupportItems::createComponent(const QUrl &componentUrl, Q
if (component.isError()) {
qWarning() << "Error in:" << Q_FUNC_INFO << componentUrl;
- Q_FOREACH (const QQmlError &error, component.errors())
+ const auto errors = component.errors();
+ for (const QQmlError &error : errors)
qWarning() << error;
}
return object;
@@ -282,7 +283,8 @@ void QQuickDesignerSupportItems::disableNativeTextRendering(QQuickItem *item)
void QQuickDesignerSupportItems::disableTextCursor(QQuickItem *item)
{
- Q_FOREACH (QQuickItem *childItem, item->childItems())
+ const auto childItems = item->childItems();
+ for (QQuickItem *childItem : childItems)
disableTextCursor(childItem);
QQuickTextInput *textInput = qobject_cast<QQuickTextInput*>(item);
diff --git a/src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc b/src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc
index bbc64f1484..9ce26e1bb8 100644
--- a/src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc
+++ b/src/quick/doc/src/concepts/visualcanvas/adaptations.qdoc
@@ -150,7 +150,7 @@ develpoment files are present. In practice this currently means Visual Studio
The adaptation is available both in normal, OpenGL-enabled Qt builds and also
when Qt was configured with \c{-no-opengl}. However, it is never the default,
meaning the user or the application has to explicitly request it by setting the
-\c{QT_QUICK_BACKEND} environment variable or by calling
+\c{QT_QUICK_BACKEND} environment variable to \c{d3d12} or by calling
QQuickWindow::setSceneGraphBackend().
\section2 Motivation
@@ -165,7 +165,7 @@ vendor-supported solution. This means that there are fewer problems anticipated
with drivers, operations like window resizes, and special events like graphics
device loss caused by device resets or graphics driver updates.
-Peformance-wise the general expectation is a somewhat lower CPU usage compared
+Performance-wise the general expectation is a somewhat lower CPU usage compared
to OpenGL due to lower driver overhead, and a higher GPU utilization with less
wasted idle time. The backend does not heavily utilize threads yet, which means
there are opportunities for further improvements in the future, for example to
diff --git a/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc b/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
index c820e08e1b..2e41c85873 100644
--- a/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
+++ b/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
@@ -269,7 +269,7 @@ animations, process events, etc.
\endlist
The threaded renderer is currently used by default on Windows with
-opengl32.dll, Linux with non-Mesa based drivers, OS X, mobile
+opengl32.dll, Linux with non-Mesa based drivers, \macos, mobile
platforms, and Embedded Linux with EGLFS but this is subject to
change. It is possible to force use of the threaded renderer by
setting \c {QSG_RENDER_LOOP=threaded} in the environment.
diff --git a/src/quick/items/items.pri b/src/quick/items/items.pri
index beaf3540bc..d91705451e 100644
--- a/src/quick/items/items.pri
+++ b/src/quick/items/items.pri
@@ -147,7 +147,7 @@ SOURCES += \
$$PWD/qquickanimatedsprite.cpp
# Items that depend on OpenGL Renderer
-contains(QT_CONFIG, opengl(es1|es2)?) {
+qtConfig(opengl(es1|es2)?) {
SOURCES += \
$$PWD/qquickopenglinfo.cpp \
$$PWD/qquickopenglshadereffect.cpp \
diff --git a/src/quick/items/qquickclipnode.cpp b/src/quick/items/qquickclipnode.cpp
index 7c7fee4a42..747e844172 100644
--- a/src/quick/items/qquickclipnode.cpp
+++ b/src/quick/items/qquickclipnode.cpp
@@ -93,7 +93,7 @@ void QQuickDefaultClipNode::updateGeometry()
int segments = qMin(30, qCeil(radius)); // Number of segments per corner.
- g->allocate((segments + 1) * 2);
+ g->allocate((segments + 1) * 4);
QVector2D *vertices = (QVector2D *)g->vertexData();
diff --git a/src/quick/items/qquickdroparea.cpp b/src/quick/items/qquickdroparea.cpp
index 1701441240..8dcc13971e 100644
--- a/src/quick/items/qquickdroparea.cpp
+++ b/src/quick/items/qquickdroparea.cpp
@@ -235,7 +235,7 @@ bool QQuickDropAreaPrivate::hasMatchingKey(const QStringList &keys) const
return true;
QRegExp copy = keyRegExp;
- foreach (const QString &key, keys) {
+ for (const QString &key : keys) {
if (copy.exactMatch(key))
return true;
}
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index 47cfec14da..89434f3804 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -385,7 +385,7 @@ Item {
\qmlproperty point QtQuick::WheelEvent::pixelDelta
This property holds the delta in screen pixels and is available in platforms that
- have high-resolution trackpads, such as OS X.
+ have high-resolution trackpads, such as \macos.
The x and y cordinate of this property holds the delta in horizontal and
vertical orientation. The value should be used directly to scroll content on screen.
diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp
index b4650a215a..d521abec6a 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -56,6 +56,8 @@
#include <QtCore/qmath.h>
#include "qplatformdefs.h"
+#include <cmath>
+
QT_BEGIN_NAMESPACE
// FlickThreshold determines how far the "mouse" must have moved
@@ -70,6 +72,21 @@ static const int RetainGrabVelocity = 100;
static const int MovementEndingTimerInterval = 100;
#endif
+// Currently std::round can't be used on Android when using ndk g++, so
+// use C version instead. We could just define two versions of Round, one
+// for float and one for double, but then only one of them would be used
+// and compiler would trigger a warning about unused function.
+//
+// See https://code.google.com/p/android/issues/detail?id=54418
+template<typename T>
+static T Round(T t) {
+ return round(t);
+}
+template<>
+Q_DECL_UNUSED float Round<float>(float f) {
+ return roundf(f);
+}
+
static qreal EaseOvershoot(qreal t) {
return qAtan(t);
}
@@ -352,7 +369,7 @@ bool QQuickFlickablePrivate::flick(AxisData &data, qreal minExtent, qreal maxExt
qreal dist = v2 / (accel * 2.0);
if (v > 0)
dist = -dist;
- qreal target = -qRound(-(data.move.value() - dist));
+ qreal target = -Round(-(data.move.value() - dist));
dist = -target + data.move.value();
accel = v2 / (2.0f * qAbs(dist));
@@ -456,18 +473,18 @@ void QQuickFlickablePrivate::fixup(AxisData &data, qreal minExtent, qreal maxExt
} else if (data.move.value() <= maxExtent) {
resetTimeline(data);
adjustContentPos(data, maxExtent);
- } else if (-qRound(-data.move.value()) != data.move.value()) {
+ } else if (-Round(-data.move.value()) != data.move.value()) {
// We could animate, but since it is less than 0.5 pixel it's probably not worthwhile.
resetTimeline(data);
qreal val = data.move.value();
- if (qAbs(-qRound(-val) - val) < 0.25) // round small differences
- val = -qRound(-val);
+ if (std::abs(-Round(-val) - val) < 0.25) // round small differences
+ val = -Round(-val);
else if (data.smoothVelocity.value() > 0) // continue direction of motion for larger
- val = -qFloor(-val);
+ val = -std::floor(-val);
else if (data.smoothVelocity.value() < 0)
- val = -qCeil(-val);
+ val = -std::ceil(-val);
else // otherwise round
- val = -qRound(-val);
+ val = -Round(-val);
timeline.set(data.move, val);
}
data.inOvershoot = false;
@@ -887,7 +904,7 @@ QQuickFlickableVisibleArea *QQuickFlickable::visibleArea()
\li Flickable.AutoFlickIfNeeded - allows flicking vertically if the
\e contentHeight is greater than the \e height of the Flickable.
Allows flicking horizontally if the \e contentWidth is greater than
- to the \e width of the Flickable.
+ to the \e width of the Flickable. (since \c{QtQuick 2.7})
\li Flickable.HorizontalFlick - allows flicking horizontally.
\li Flickable.VerticalFlick - allows flicking vertically.
\li Flickable.HorizontalAndVerticalFlick - allows flicking in both directions.
@@ -1235,13 +1252,17 @@ void QQuickFlickablePrivate::handleMouseMoveEvent(QMouseEvent *event)
return;
qint64 currentTimestamp = computeCurrentTime(event);
- qreal elapsed = qreal(currentTimestamp - (lastPos.isNull() ? lastPressTime : lastPosTime)) / 1000.;
QVector2D deltas = QVector2D(event->localPos() - pressPos);
bool overThreshold = false;
QVector2D velocity = QGuiApplicationPrivate::mouseEventVelocity(event);
// TODO guarantee that events always have velocity so that it never needs to be computed here
- if (!(QGuiApplicationPrivate::mouseEventCaps(event) & QTouchDevice::Velocity))
+ if (!(QGuiApplicationPrivate::mouseEventCaps(event) & QTouchDevice::Velocity)) {
+ qint64 lastTimestamp = (lastPos.isNull() ? lastPressTime : lastPosTime);
+ if (currentTimestamp == lastTimestamp)
+ return; // events are too close together: velocity would be infinite
+ qreal elapsed = qreal(currentTimestamp - lastTimestamp) / 1000.;
velocity = QVector2D(event->localPos() - (lastPos.isNull() ? pressPos : lastPos)) / elapsed;
+ }
if (q->yflick())
overThreshold |= QQuickWindowPrivate::dragOverThreshold(deltas.y(), Qt::YAxis, event);
@@ -1550,12 +1571,12 @@ void QQuickFlickablePrivate::replayDelayedPress()
//XXX pixelAligned ignores the global position of the Flickable, i.e. assumes Flickable itself is pixel aligned.
void QQuickFlickablePrivate::setViewportX(qreal x)
{
- contentItem->setX(pixelAligned ? -qRound(-x) : x);
+ contentItem->setX(pixelAligned ? -Round(-x) : x);
}
void QQuickFlickablePrivate::setViewportY(qreal y)
{
- contentItem->setY(pixelAligned ? -qRound(-y) : y);
+ contentItem->setY(pixelAligned ? -Round(-y) : y);
}
void QQuickFlickable::timerEvent(QTimerEvent *event)
diff --git a/src/quick/items/qquickframebufferobject.cpp b/src/quick/items/qquickframebufferobject.cpp
index d8147a48a5..857cd44b15 100644
--- a/src/quick/items/qquickframebufferobject.cpp
+++ b/src/quick/items/qquickframebufferobject.cpp
@@ -44,6 +44,7 @@
#include <private/qquickitem_p.h>
#include <QSGSimpleTextureNode>
+#include <QSGRendererInterface>
QT_BEGIN_NAMESPACE
@@ -260,6 +261,12 @@ public:
int devicePixelRatio;
};
+static inline bool isOpenGL(QSGRenderContext *rc)
+{
+ QSGRendererInterface *rif = rc->sceneGraphContext()->rendererInterface(rc);
+ return !rif || rif->graphicsApi() == QSGRendererInterface::OpenGL;
+}
+
/*!
* \internal
*/
@@ -278,6 +285,8 @@ QSGNode *QQuickFramebufferObject::updatePaintNode(QSGNode *node, UpdatePaintNode
Q_D(QQuickFramebufferObject);
if (!n) {
+ if (!isOpenGL(d->sceneGraphRenderContext()))
+ return 0;
if (!d->node)
d->node = new QSGFramebufferObjectNode;
n = d->node;
@@ -360,6 +369,8 @@ QSGTextureProvider *QQuickFramebufferObject::textureProvider() const
qWarning("QQuickFramebufferObject::textureProvider: can only be queried on the rendering thread of an exposed window");
return 0;
}
+ if (!isOpenGL(d->sceneGraphRenderContext()))
+ return 0;
if (!d->node)
d->node = new QSGFramebufferObjectNode;
return d->node;
diff --git a/src/quick/items/qquickgridview.cpp b/src/quick/items/qquickgridview.cpp
index b5d5e43f7a..14ea43f123 100644
--- a/src/quick/items/qquickgridview.cpp
+++ b/src/quick/items/qquickgridview.cpp
@@ -2612,7 +2612,7 @@ bool QQuickGridViewPrivate::needsRefillForAddedOrRemovedIndex(int modelIndex) co
*/
/*!
- \qmlmethod int QtQuick::GridView::indexAt(int x, int y)
+ \qmlmethod int QtQuick::GridView::indexAt(real x, real y)
Returns the index of the visible item containing the point \a x, \a y in content
coordinates. If there is no item at the point specified, or the item is
@@ -2625,7 +2625,7 @@ bool QQuickGridViewPrivate::needsRefillForAddedOrRemovedIndex(int modelIndex) co
*/
/*!
- \qmlmethod Item QtQuick::GridView::itemAt(int x, int y)
+ \qmlmethod Item QtQuick::GridView::itemAt(real x, real y)
Returns the visible item containing the point \a x, \a y in content
coordinates. If there is no item at the point specified, or the item is
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index a4be47380e..e5d8c164c5 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -100,7 +100,8 @@ void debugFocusTree(QQuickItem *item, QQuickItem *scope = 0, int depth = 1)
<< item->hasActiveFocus()
<< item->isFocusScope()
<< item;
- for (QQuickItem *child : item->childItems()) {
+ const auto childItems = item->childItems();
+ for (QQuickItem *child : childItems) {
debugFocusTree(
child,
item->isFocusScope() || !scope ? item : scope,
@@ -4110,7 +4111,8 @@ bool QQuickItem::childMouseEventFilter(QQuickItem *item, QEvent *event)
*/
void QQuickItem::windowDeactivateEvent()
{
- foreach (QQuickItem* item, childItems()) {
+ const auto children = childItems();
+ for (QQuickItem* item : children) {
item->windowDeactivateEvent();
}
}
diff --git a/src/quick/items/qquickitemview.cpp b/src/quick/items/qquickitemview.cpp
index d3f045f35c..e017d6564a 100644
--- a/src/quick/items/qquickitemview.cpp
+++ b/src/quick/items/qquickitemview.cpp
@@ -181,7 +181,7 @@ void QQuickItemViewChangeSet::applyChanges(const QQmlChangeSet &changeSet)
int moveId = -1;
int moveOffset = 0;
- foreach (const QQmlChangeSet::Change &r, changeSet.removes()) {
+ for (const QQmlChangeSet::Change &r : changeSet.removes()) {
itemCount -= r.count;
if (moveId == -1 && newCurrentIndex >= r.index + r.count) {
newCurrentIndex -= r.count;
@@ -200,7 +200,7 @@ void QQuickItemViewChangeSet::applyChanges(const QQmlChangeSet &changeSet)
currentChanged = true;
}
}
- foreach (const QQmlChangeSet::Change &i, changeSet.inserts()) {
+ for (const QQmlChangeSet::Change &i : changeSet.inserts()) {
if (moveId == -1) {
if (itemCount && newCurrentIndex >= i.index) {
newCurrentIndex += i.count;
@@ -1622,12 +1622,10 @@ qreal QQuickItemViewPrivate::contentStartOffset() const
int QQuickItemViewPrivate::findLastVisibleIndex(int defaultValue) const
{
- if (visibleItems.count()) {
- int i = visibleItems.count() - 1;
- while (i > 0 && visibleItems.at(i)->index == -1)
- --i;
- if (visibleItems.at(i)->index != -1)
- return visibleItems.at(i)->index;
+ for (auto it = visibleItems.rbegin(), end = visibleItems.rend(); it != end; ++it) {
+ auto item = *it;
+ if (item->index != -1)
+ return item->index;
}
return defaultValue;
}
@@ -1658,9 +1656,10 @@ FxViewItem *QQuickItemViewPrivate::firstVisibleItem() const {
int QQuickItemViewPrivate::findLastIndexInView() const
{
const qreal viewEndPos = isContentFlowReversed() ? -position() : position() + size();
- for (int i=visibleItems.count() - 1; i>=0; i--) {
- if (visibleItems.at(i)->position() <= viewEndPos && visibleItems.at(i)->index != -1)
- return visibleItems.at(i)->index;
+ for (auto it = visibleItems.rbegin(), end = visibleItems.rend(); it != end; ++it) {
+ auto item = *it;
+ if (item->index != -1 && item->position() <= viewEndPos)
+ return item->index;
}
return -1;
}
diff --git a/src/quick/items/qquicklistview.cpp b/src/quick/items/qquicklistview.cpp
index 50d75d3dab..47efecdb2d 100644
--- a/src/quick/items/qquicklistview.cpp
+++ b/src/quick/items/qquicklistview.cpp
@@ -3352,7 +3352,7 @@ void QQuickListViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex
*/
/*!
- \qmlmethod int QtQuick::ListView::indexAt(int x, int y)
+ \qmlmethod int QtQuick::ListView::indexAt(real x, real y)
Returns the index of the visible item containing the point \a x, \a y in content
coordinates. If there is no item at the point specified, or the item is
@@ -3365,7 +3365,7 @@ void QQuickListViewPrivate::translateAndTransitionItemsAfter(int afterModelIndex
*/
/*!
- \qmlmethod Item QtQuick::ListView::itemAt(int x, int y)
+ \qmlmethod Item QtQuick::ListView::itemAt(real x, real y)
Returns the visible item containing the point \a x, \a y in content
coordinates. If there is no item at the point specified, or the item is
diff --git a/src/quick/items/qquickmultipointtoucharea.cpp b/src/quick/items/qquickmultipointtoucharea.cpp
index d31807de7f..d68cb8e3f6 100644
--- a/src/quick/items/qquickmultipointtoucharea.cpp
+++ b/src/quick/items/qquickmultipointtoucharea.cpp
@@ -362,7 +362,7 @@ QQuickMultiPointTouchArea::QQuickMultiPointTouchArea(QQuickItem *parent)
QQuickMultiPointTouchArea::~QQuickMultiPointTouchArea()
{
clearTouchLists();
- foreach (QObject *obj, _touchPoints) {
+ for (QObject *obj : qAsConst(_touchPoints)) {
QQuickTouchPoint *dtp = static_cast<QQuickTouchPoint*>(obj);
if (!dtp->isQmlDefined())
delete dtp;
@@ -524,7 +524,7 @@ void QQuickMultiPointTouchArea::updateTouchData(QEvent *event)
}
int numTouchPoints = touchPoints.count();
//always remove released touches, and make sure we handle all releases before adds.
- foreach (const QTouchEvent::TouchPoint &p, touchPoints) {
+ for (const QTouchEvent::TouchPoint &p : qAsConst(touchPoints)) {
Qt::TouchPointState touchPointState = p.state();
int id = p.id();
if (touchPointState & Qt::TouchPointReleased) {
@@ -539,7 +539,7 @@ void QQuickMultiPointTouchArea::updateTouchData(QEvent *event)
}
}
if (numTouchPoints >= _minimumTouchPoints && numTouchPoints <= _maximumTouchPoints) {
- foreach (const QTouchEvent::TouchPoint &p, touchPoints) {
+ for (const QTouchEvent::TouchPoint &p : qAsConst(touchPoints)) {
Qt::TouchPointState touchPointState = p.state();
int id = p.id();
if (touchPointState & Qt::TouchPointReleased) {
@@ -565,7 +565,7 @@ void QQuickMultiPointTouchArea::updateTouchData(QEvent *event)
if (!_stealMouse /* !ignoring gesture*/) {
bool offerGrab = false;
const int dragThreshold = QGuiApplication::styleHints()->startDragDistance();
- foreach (const QTouchEvent::TouchPoint &p, touchPoints) {
+ for (const QTouchEvent::TouchPoint &p : qAsConst(touchPoints)) {
if (p.state() == Qt::TouchPointReleased)
continue;
const QPointF &currentPos = p.scenePos();
@@ -599,7 +599,7 @@ void QQuickMultiPointTouchArea::updateTouchData(QEvent *event)
void QQuickMultiPointTouchArea::clearTouchLists()
{
- foreach (QObject *obj, _releasedTouchPoints) {
+ for (QObject *obj : qAsConst(_releasedTouchPoints)) {
QQuickTouchPoint *dtp = static_cast<QQuickTouchPoint*>(obj);
if (!dtp->isQmlDefined()) {
_touchPoints.remove(dtp->pointId());
@@ -616,7 +616,7 @@ void QQuickMultiPointTouchArea::clearTouchLists()
void QQuickMultiPointTouchArea::addTouchPoint(const QTouchEvent::TouchPoint *p)
{
QQuickTouchPoint *dtp = 0;
- foreach (QQuickTouchPoint* tp, _touchPrototypes) {
+ for (QQuickTouchPoint* tp : qAsConst(_touchPrototypes)) {
if (!tp->inUse()) {
tp->setInUse(true);
dtp = tp;
@@ -636,7 +636,7 @@ void QQuickMultiPointTouchArea::addTouchPoint(const QTouchEvent::TouchPoint *p)
void QQuickMultiPointTouchArea::addTouchPoint(const QMouseEvent *e)
{
QQuickTouchPoint *dtp = 0;
- foreach (QQuickTouchPoint *tp, _touchPrototypes)
+ for (QQuickTouchPoint *tp : qAsConst(_touchPrototypes))
if (!tp->inUse()) {
tp->setInUse(true);
dtp = tp;
@@ -782,11 +782,11 @@ void QQuickMultiPointTouchArea::ungrab()
ungrabTouchPoints();
if (_touchPoints.count()) {
- foreach (QObject *obj, _touchPoints)
+ for (QObject *obj : qAsConst(_touchPoints))
static_cast<QQuickTouchPoint*>(obj)->setPressed(false);
emit canceled(_touchPoints.values());
clearTouchLists();
- foreach (QObject *obj, _touchPoints) {
+ for (QObject *obj : qAsConst(_touchPoints)) {
QQuickTouchPoint *dtp = static_cast<QQuickTouchPoint*>(obj);
if (!dtp->isQmlDefined())
delete dtp;
@@ -901,7 +901,7 @@ bool QQuickMultiPointTouchArea::shouldFilter(QEvent *event)
case QEvent::TouchUpdate:
case QEvent::TouchEnd: {
QTouchEvent *te = static_cast<QTouchEvent*>(event);
- foreach (const QTouchEvent::TouchPoint &point, te->touchPoints()) {
+ for (const QTouchEvent::TouchPoint &point : te->touchPoints()) {
if (contains(mapFromScene(point.scenePos()))) {
containsPoint = true;
break;
diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp
index 1de20ed5b9..e54ee66fe5 100644
--- a/src/quick/items/qquickpathview.cpp
+++ b/src/quick/items/qquickpathview.cpp
@@ -191,7 +191,8 @@ void QQuickPathView::initItem(int index, QObject *object)
att->m_view = this;
qreal percent = d->positionOfIndex(index);
if (percent < 1.0 && d->path) {
- foreach (const QString &attr, d->path->attributes())
+ const auto attributes = d->path->attributes();
+ for (const QString &attr : attributes)
att->setValue(attr.toUtf8(), d->path->attributeAt(attr, percent));
item->setZ(d->requestedZ);
}
@@ -230,7 +231,8 @@ QQmlOpenMetaObjectType *QQuickPathViewPrivate::attachedType()
// pre-create one metatype to share with all attached objects
attType = new QQmlOpenMetaObjectType(&QQuickPathViewAttached::staticMetaObject, qmlEngine(q));
if (path) {
- foreach (const QString &attr, path->attributes())
+ const auto attributes = path->attributes();
+ for (const QString &attr : attributes)
attType->createProperty(attr.toUtf8());
}
}
@@ -244,10 +246,9 @@ void QQuickPathViewPrivate::clear()
releaseItem(currentItem);
currentItem = 0;
}
- for (int i=0; i<items.count(); i++){
- QQuickItem *p = items.at(i);
+ for (QQuickItem *p : qAsConst(items))
releaseItem(p);
- }
+
if (requestedIndex >= 0) {
if (model)
model->cancel(requestedIndex);
@@ -296,6 +297,8 @@ qreal QQuickPathViewPrivate::positionOfIndex(qreal index) const
// account the circular space.
bool QQuickPathViewPrivate::isInBound(qreal position, qreal lower, qreal upper) const
{
+ if (lower == upper)
+ return true;
if (lower > upper) {
if (position > upper && position > lower)
position -= mappedRange;
@@ -415,12 +418,9 @@ void QQuickPathViewPrivate::setHighlightPosition(qreal pos)
void QQuickPathView::pathUpdated()
{
Q_D(QQuickPathView);
- QList<QQuickItem*>::iterator it = d->items.begin();
- while (it != d->items.end()) {
- QQuickItem *item = *it;
+ for (QQuickItem *item : qAsConst(d->items)) {
if (QQuickPathViewAttached *att = d->attached(item))
att->m_percent = -1;
- ++it;
}
refill();
}
@@ -433,7 +433,8 @@ void QQuickPathViewPrivate::updateItem(QQuickItem *item, qreal percent)
if (qFuzzyCompare(att->m_percent, percent))
return;
att->m_percent = percent;
- foreach (const QString &attr, path->attributes())
+ const auto attributes = path->attributes();
+ for (const QString &attr : attributes)
att->setValue(attr.toUtf8(), path->attributeAt(attr, percent));
att->setOnPath(percent < 1.0);
}
@@ -1506,7 +1507,7 @@ void QQuickPathView::positionViewAtIndex(int index, int mode)
}
/*!
- \qmlmethod int QtQuick::PathView::indexAt(int x, int y)
+ \qmlmethod int QtQuick::PathView::indexAt(real x, real y)
Returns the index of the item containing the point \a x, \a y in content
coordinates. If there is no item at the point specified, -1 is returned.
@@ -1516,21 +1517,12 @@ void QQuickPathView::positionViewAtIndex(int index, int mode)
int QQuickPathView::indexAt(qreal x, qreal y) const
{
Q_D(const QQuickPathView);
- if (!d->isValid())
- return -1;
-
- for (int idx = 0; idx < d->items.count(); ++idx) {
- QQuickItem *item = d->items.at(idx);
- QPointF p = item->mapFromItem(this, QPointF(x, y));
- if (item->contains(p))
- return d->model->indexOf(item, 0);
- }
-
- return -1;
+ QQuickItem *item = itemAt(x, y);
+ return item ? d->model->indexOf(item, 0) : -1;
}
/*!
- \qmlmethod Item QtQuick::PathView::itemAt(int x, int y)
+ \qmlmethod Item QtQuick::PathView::itemAt(real x, real y)
Returns the item containing the point \a x, \a y in content
coordinates. If there is no item at the point specified, null is returned.
@@ -1543,8 +1535,7 @@ QQuickItem *QQuickPathView::itemAt(qreal x, qreal y) const
if (!d->isValid())
return 0;
- for (int idx = 0; idx < d->items.count(); ++idx) {
- QQuickItem *item = d->items.at(idx);
+ for (QQuickItem *item : d->items) {
QPointF p = item->mapFromItem(this, QPointF(x, y));
if (item->contains(p))
return item;
@@ -1555,8 +1546,9 @@ QQuickItem *QQuickPathView::itemAt(qreal x, qreal y) const
QPointF QQuickPathViewPrivate::pointNear(const QPointF &point, qreal *nearPercent) const
{
- qreal samples = qMin(path->path().length()/5, qreal(500.0));
- qreal res = path->path().length()/samples;
+ const auto pathLength = path->path().length();
+ qreal samples = qMin(pathLength / 5, qreal(500.0));
+ qreal res = pathLength / samples;
qreal mindist = 1e10; // big number
QPointF nearPoint = path->pointAt(0);
@@ -1753,12 +1745,13 @@ void QQuickPathViewPrivate::handleMouseReleaseEvent(QMouseEvent *)
qreal velocity = calcVelocity();
qreal count = pathItems == -1 ? modelCount : qMin(pathItems, modelCount);
- qreal pixelVelocity = (path->path().length()/count) * velocity;
+ const auto averageItemLength = path->path().length() / count;
+ qreal pixelVelocity = averageItemLength * velocity;
if (qAbs(pixelVelocity) > MinimumFlickVelocity) {
if (qAbs(pixelVelocity) > maximumFlickVelocity || snapMode == QQuickPathView::SnapOneItem) {
// limit velocity
qreal maxVel = velocity < 0 ? -maximumFlickVelocity : maximumFlickVelocity;
- velocity = maxVel / (path->path().length()/count);
+ velocity = maxVel / averageItemLength;
}
// Calculate the distance to be travelled
qreal v2 = velocity*velocity;
@@ -1903,6 +1896,14 @@ void QQuickPathView::updatePolish()
refill();
}
+static inline int currentIndexRemainder(int currentIndex, int modelCount) Q_DECL_NOTHROW
+{
+ if (currentIndex < 0)
+ return modelCount + currentIndex % modelCount;
+ else
+ return currentIndex % modelCount;
+}
+
void QQuickPathView::componentComplete()
{
Q_D(QQuickPathView);
@@ -1914,7 +1915,7 @@ void QQuickPathView::componentComplete()
if (d->model) {
d->modelCount = d->model->count();
if (d->modelCount && d->currentIndex != 0) // an initial value has been provided for currentIndex
- d->offset = qmlMod(d->modelCount - d->currentIndex, d->modelCount);
+ d->offset = qmlMod(d->modelCount - currentIndexRemainder(d->currentIndex, d->modelCount), d->modelCount);
}
d->createHighlight();
@@ -1988,7 +1989,8 @@ void QQuickPathView::refill()
qreal endPos;
int startIdx = 0;
qreal startPos = 0.0;
- if (d->items.count()) {
+ const bool wasEmpty = d->items.isEmpty();
+ if (!wasEmpty) {
//Find the beginning and end, items may not be in sorted order
endPos = -1.0;
startPos = 2.0;
@@ -2047,7 +2049,8 @@ void QQuickPathView::refill()
}
//Prepend
- idx = startIdx - 1;
+ idx = (wasEmpty ? d->calcCurrentIndex() : startIdx) - 1;
+
if (idx < 0)
idx = d->modelCount - 1;
nextPos = d->positionOfIndex(idx);
@@ -2086,27 +2089,33 @@ void QQuickPathView::refill()
idx = startIdx;
QQuickItem *lastItem = d->items.at(0);
while (idx != endIdx) {
- //This gets the reference from the delegate model, and will not re-create
- QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1.0);
- if (!item) {
- waiting = true;
- break;
- }
- if (!d->items.contains(item)) { //We found a hole
- nextPos = d->positionOfIndex(idx);
- qCDebug(lcItemViewDelegateLifecycle) << "middle insert" << idx << "@" << nextPos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count();
- if (d->currentIndex == idx) {
- currentVisible = true;
- d->currentItemOffset = nextPos;
+ nextPos = d->positionOfIndex(idx);
+ if (d->isInBound(nextPos, d->mappedRange - d->mappedCache, 1.0 + d->mappedCache)) {
+ //This gets the reference from the delegate model, and will not re-create
+ QQuickItem *item = d->getItem(idx, idx+1, nextPos >= 1.0);
+ if (!item) {
+ waiting = true;
+ break;
}
- int lastListIdx = d->items.indexOf(lastItem);
- d->items.insert(lastListIdx + 1, item);
- d->updateItem(item, nextPos);
- } else {
- d->releaseItem(item);
+
+ if (!d->items.contains(item)) { //We found a hole
+ qCDebug(lcItemViewDelegateLifecycle) << "middle insert" << idx << "@" << nextPos
+ << (d->currentIndex == idx ? "current" : "")
+ << "items count was" << d->items.count();
+ if (d->currentIndex == idx) {
+ currentVisible = true;
+ d->currentItemOffset = nextPos;
+ }
+ int lastListIdx = d->items.indexOf(lastItem);
+ d->items.insert(lastListIdx + 1, item);
+ d->updateItem(item, nextPos);
+ } else {
+ d->releaseItem(item);
+ }
+
+ lastItem = item;
}
- lastItem = item;
++idx;
if (idx >= d->modelCount)
idx = 0;
@@ -2146,8 +2155,9 @@ void QQuickPathView::refill()
if (QQuickPathViewAttached *att = d->attached(d->highlightItem))
att->setOnPath(currentVisible);
}
- while (d->itemCache.count())
- d->releaseItem(d->itemCache.takeLast());
+ for (QQuickItem *item : qAsConst(d->itemCache))
+ d->releaseItem(item);
+ d->itemCache.clear();
d->inRefill = false;
if (currentChanged)
@@ -2175,7 +2185,7 @@ void QQuickPathView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
int moveOffset = 0;
bool currentChanged = false;
bool changedOffset = false;
- foreach (const QQmlChangeSet::Change &r, changeSet.removes()) {
+ for (const QQmlChangeSet::Change &r : changeSet.removes()) {
if (moveId == -1 && d->currentIndex >= r.index + r.count) {
d->currentIndex -= r.count;
currentChanged = true;
@@ -2201,7 +2211,7 @@ void QQuickPathView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
}
d->modelCount -= r.count;
}
- foreach (const QQmlChangeSet::Change &i, changeSet.inserts()) {
+ for (const QQmlChangeSet::Change &i : changeSet.inserts()) {
if (d->modelCount) {
if (moveId == -1 && i.index <= d->currentIndex) {
d->currentIndex += i.count;
@@ -2231,8 +2241,9 @@ void QQuickPathView::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
d->items.clear();
if (!d->modelCount) {
- while (d->itemCache.count())
- d->releaseItem(d->itemCache.takeLast());
+ for (QQuickItem * item : qAsConst(d->itemCache))
+ d->releaseItem(item);
+ d->itemCache.clear();
d->offset = 0;
changedOffset = true;
d->tl.reset(d->moveOffset);
diff --git a/src/quick/items/qquickpincharea.cpp b/src/quick/items/qquickpincharea.cpp
index f3791a49ee..fd8971c845 100644
--- a/src/quick/items/qquickpincharea.cpp
+++ b/src/quick/items/qquickpincharea.cpp
@@ -245,7 +245,7 @@ QQuickPinchAreaPrivate::~QQuickPinchAreaPrivate()
\since 5.5
This signal is emitted when the pinch area detects the smart zoom gesture.
- This gesture occurs only on certain operating systems such as OS X.
+ This gesture occurs only on certain operating systems such as \macos.
The \l {PinchEvent}{pinch} parameter provides information about the pinch
gesture, including the location where the gesture occurred. \c pinch.scale
diff --git a/src/quick/items/qquickrepeater.cpp b/src/quick/items/qquickrepeater.cpp
index 198573fda5..4f46f41b0d 100644
--- a/src/quick/items/qquickrepeater.cpp
+++ b/src/quick/items/qquickrepeater.cpp
@@ -461,7 +461,7 @@ void QQuickRepeater::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
int difference = 0;
QHash<int, QVector<QPointer<QQuickItem> > > moved;
- foreach (const QQmlChangeSet::Change &remove, changeSet.removes()) {
+ for (const QQmlChangeSet::Change &remove : changeSet.removes()) {
int index = qMin(remove.index, d->deletables.count());
int count = qMin(remove.index + remove.count, d->deletables.count()) - index;
if (remove.isMove()) {
@@ -483,7 +483,7 @@ void QQuickRepeater::modelUpdated(const QQmlChangeSet &changeSet, bool reset)
difference -= remove.count;
}
- foreach (const QQmlChangeSet::Change &insert, changeSet.inserts()) {
+ for (const QQmlChangeSet::Change &insert : changeSet.inserts()) {
int index = qMin(insert.index, d->deletables.count());
if (insert.isMove()) {
QVector<QPointer<QQuickItem> > items = moved.value(insert.moveId);
diff --git a/src/quick/items/qquickspriteengine.cpp b/src/quick/items/qquickspriteengine.cpp
index db04a83afc..10e0d51709 100644
--- a/src/quick/items/qquickspriteengine.cpp
+++ b/src/quick/items/qquickspriteengine.cpp
@@ -110,10 +110,10 @@ QQuickSpriteEngine::QQuickSpriteEngine(QObject *parent)
{
}
-QQuickSpriteEngine::QQuickSpriteEngine(QList<QQuickSprite*> sprites, QObject *parent)
+QQuickSpriteEngine::QQuickSpriteEngine(const QList<QQuickSprite *> &sprites, QObject *parent)
: QQuickSpriteEngine(parent)
{
- foreach (QQuickSprite* sprite, sprites)
+ for (QQuickSprite* sprite : sprites)
m_states << (QQuickStochasticState*)sprite;
}
@@ -329,7 +329,7 @@ QQuickPixmap::Status QQuickSpriteEngine::status()//Composed status of all Sprite
return QQuickPixmap::Null;
int null, loading, ready;
null = loading = ready = 0;
- foreach (QQuickSprite* s, m_sprites) {
+ for (QQuickSprite* s : qAsConst(m_sprites)) {
switch (s->m_pix.status()) {
// ### Maybe add an error message here, because this null shouldn't be reached but when it does, the image fails without an error message.
case QQuickPixmap::Null : null++; break;
@@ -358,7 +358,7 @@ void QQuickSpriteEngine::startAssemblingImage()
QList<QQuickStochasticState*> removals;
- foreach (QQuickStochasticState* s, m_states){
+ for (QQuickStochasticState* s : qAsConst(m_states)) {
QQuickSprite* sprite = qobject_cast<QQuickSprite*>(s);
if (sprite) {
m_sprites << sprite;
@@ -367,7 +367,7 @@ void QQuickSpriteEngine::startAssemblingImage()
qDebug() << "Error: Non-sprite in QQuickSpriteEngine";
}
}
- foreach (QQuickStochasticState* s, removals)
+ for (QQuickStochasticState* s : qAsConst(removals))
m_states.removeAll(s);
m_startedImageAssembly = true;
}
@@ -376,7 +376,7 @@ QImage QQuickSpriteEngine::assembledImage(int maxSize)
{
QQuickPixmap::Status stat = status();
if (!m_errorsPrinted && stat == QQuickPixmap::Error) {
- foreach (QQuickSprite* s, m_sprites)
+ for (QQuickSprite* s : qAsConst(m_sprites))
if (s->m_pix.isError())
qmlInfo(s) << s->m_pix.error();
m_errorsPrinted = true;
@@ -390,7 +390,7 @@ QImage QQuickSpriteEngine::assembledImage(int maxSize)
m_maxFrames = 0;
m_imageStateCount = 0;
- foreach (QQuickSprite* state, m_sprites){
+ for (QQuickSprite* state : qAsConst(m_sprites)) {
if (state->frames() > m_maxFrames)
m_maxFrames = state->frames();
@@ -441,7 +441,7 @@ QImage QQuickSpriteEngine::assembledImage(int maxSize)
image.fill(0);
QPainter p(&image);
int y = 0;
- foreach (QQuickSprite* state, m_sprites){
+ for (QQuickSprite* state : qAsConst(m_sprites)) {
QImage img(state->m_pix.image());
int frameWidth = state->m_frameWidth;
int frameHeight = state->m_frameHeight;
@@ -665,7 +665,8 @@ uint QQuickStochasticEngine::updateSprites(uint time)//### would returning a lis
m_timeOffset = time;
m_addAdvance = false;
while (!m_stateUpdates.isEmpty() && time >= m_stateUpdates.constFirst().first){
- foreach (int idx, m_stateUpdates.constFirst().second)
+ const auto copy = m_stateUpdates.constFirst().second;
+ for (int idx : copy)
advance(idx);
m_stateUpdates.pop_front();
}
diff --git a/src/quick/items/qquickspriteengine_p.h b/src/quick/items/qquickspriteengine_p.h
index 424fa18a54..485afc16e5 100644
--- a/src/quick/items/qquickspriteengine_p.h
+++ b/src/quick/items/qquickspriteengine_p.h
@@ -266,7 +266,7 @@ class Q_QUICK_PRIVATE_EXPORT QQuickSpriteEngine : public QQuickStochasticEngine
Q_PROPERTY(QQmlListProperty<QQuickSprite> sprites READ sprites)
public:
explicit QQuickSpriteEngine(QObject *parent = 0);
- QQuickSpriteEngine(QList<QQuickSprite*> sprites, QObject *parent=0);
+ QQuickSpriteEngine(const QList<QQuickSprite*> &sprites, QObject *parent = 0);
~QQuickSpriteEngine();
QQmlListProperty<QQuickSprite> sprites()
{
diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp
index 4dc59b100a..14268b472e 100644
--- a/src/quick/items/qquicktext.cpp
+++ b/src/quick/items/qquicktext.cpp
@@ -322,7 +322,7 @@ void QQuickText::imageDownloadFinished()
if (d->extra.isAllocated() && d->extra->nbActiveDownloads == 0) {
bool needToUpdateLayout = false;
- foreach (QQuickStyledTextImgTag *img, d->extra->visibleImgTags) {
+ for (QQuickStyledTextImgTag *img : qAsConst(d->extra->visibleImgTags)) {
if (!img->size.isValid()) {
img->size = img->pix->implicitSize();
needToUpdateLayout = true;
@@ -1115,7 +1115,7 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal
QList<QQuickStyledTextImgTag *> imagesInLine;
if (extra.isAllocated()) {
- foreach (QQuickStyledTextImgTag *image, extra->imgTags) {
+ for (QQuickStyledTextImgTag *image : qAsConst(extra->imgTags)) {
if (image->position >= line.textStart() &&
image->position < line.textStart() + line.textLength()) {
@@ -1152,7 +1152,7 @@ void QQuickTextPrivate::setLineGeometry(QTextLine &line, qreal lineWidth, qreal
}
}
- foreach (QQuickStyledTextImgTag *image, imagesInLine) {
+ for (QQuickStyledTextImgTag *image : qAsConst(imagesInLine)) {
totalLineHeight = qMax(totalLineHeight, textTop + image->pos.y() + image->size.height());
const int leadX = line.cursorToX(image->position);
const int trailX = line.cursorToX(image->position, QTextLine::Trailing);
@@ -2062,6 +2062,7 @@ void QQuickText::setTextFormat(TextFormat format)
}
d->updateLayout();
setAcceptHoverEvents(d->richText || d->styledText);
+ setAcceptedMouseButtons(d->richText || d->styledText ? Qt::LeftButton : Qt::NoButton);
emit textFormatChanged(d->format);
}
@@ -2341,7 +2342,7 @@ QSGNode *QQuickText::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *data
node->addTextLayout(QPointF(dx, dy), d->elideLayout, color, d->style, styleColor, linkColor);
if (d->extra.isAllocated()) {
- foreach (QQuickStyledTextImgTag *img, d->extra->visibleImgTags) {
+ for (QQuickStyledTextImgTag *img : qAsConst(d->extra->visibleImgTags)) {
QQuickPixmap *pix = img->pix;
if (pix && pix->isReady())
node->addImage(QRectF(img->pos.x() + dx, img->pos.y() + dy, pix->width(), pix->height()), pix->image());
@@ -2595,7 +2596,8 @@ QString QQuickTextPrivate::anchorAt(const QTextLayout *layout, const QPointF &mo
QTextLine line = layout->lineAt(i);
if (line.naturalTextRect().contains(mousePos)) {
int charPos = line.xToCursor(mousePos.x(), QTextLine::CursorOnCharacter);
- foreach (const QTextLayout::FormatRange &formatRange, layout->formats()) {
+ const auto formats = layout->formats();
+ for (const QTextLayout::FormatRange &formatRange : formats) {
if (formatRange.format.isAnchor()
&& charPos >= formatRange.start
&& charPos < formatRange.start + formatRange.length) {
diff --git a/src/quick/items/qquicktextdocument.cpp b/src/quick/items/qquicktextdocument.cpp
index 3eacfd61bc..1dc54eb107 100644
--- a/src/quick/items/qquicktextdocument.cpp
+++ b/src/quick/items/qquicktextdocument.cpp
@@ -219,7 +219,7 @@ QQuickPixmap *QQuickTextDocumentWithImageResources::loadPixmap(
void QQuickTextDocumentWithImageResources::clearResources()
{
- foreach (QQuickPixmap *pixmap, m_resources)
+ for (QQuickPixmap *pixmap : qAsConst(m_resources))
pixmap->clear(this);
qDeleteAll(m_resources);
m_resources.clear();
diff --git a/src/quick/items/qquicktextedit.cpp b/src/quick/items/qquicktextedit.cpp
index d6d9d53a3b..c81544cbdb 100644
--- a/src/quick/items/qquicktextedit.cpp
+++ b/src/quick/items/qquicktextedit.cpp
@@ -2065,7 +2065,7 @@ QSGNode *QQuickTextEdit::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData *
// Having nodes spanning across frame boundaries will break the current bookkeeping mechanism. We need to prevent that.
QList<int> frameBoundaries;
frameBoundaries.reserve(frames.size());
- Q_FOREACH (QTextFrame *frame, frames)
+ for (QTextFrame *frame : qAsConst(frames))
frameBoundaries.append(frame->firstPosition());
std::sort(frameBoundaries.begin(), frameBoundaries.end());
@@ -2499,7 +2499,7 @@ void QQuickTextEdit::updateWholeDocument()
{
Q_D(QQuickTextEdit);
if (!d->textNodeMap.isEmpty()) {
- Q_FOREACH (TextNode* node, d->textNodeMap)
+ for (TextNode* node : qAsConst(d->textNodeMap))
node->setDirty();
}
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index 0078c4ac21..fd158207c6 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -84,7 +84,7 @@ DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
and setting \l echoMode to an appropriate value enables TextInput to be used for
a password input field.
- On OS X, the Up/Down key bindings for Home/End are explicitly disabled.
+ On \macos, the Up/Down key bindings for Home/End are explicitly disabled.
If you want such bindings (on any platform), you will need to construct them in QML.
\sa TextEdit, Text
@@ -2992,7 +2992,7 @@ void QQuickTextInputPrivate::updateLayout()
if (inLayout) // probably the result of a binding loop, but by letting it
return; // get this far we'll get a warning to that effect.
}
- qreal lineWidth = q->widthValid() ? q->width() - q->leftPadding() - q->rightPadding() : INT_MAX;
+ qreal lineWidth = q->widthValid() || !isImplicitResizeEnabled() ? q->width() - q->leftPadding() - q->rightPadding() : INT_MAX;
qreal height = 0;
qreal width = 0;
do {
diff --git a/src/quick/items/qquickview.cpp b/src/quick/items/qquickview.cpp
index 8b74d26576..d79d8ba3cd 100644
--- a/src/quick/items/qquickview.cpp
+++ b/src/quick/items/qquickview.cpp
@@ -264,8 +264,8 @@ void QQuickView::setContent(const QUrl& url, QQmlComponent *component, QObject*
d->component = component;
if (d->component && d->component->isError()) {
- QList<QQmlError> errorList = d->component->errors();
- foreach (const QQmlError &error, errorList) {
+ const QList<QQmlError> errorList = d->component->errors();
+ for (const QQmlError &error : errorList) {
QMessageLogger(error.url().toString().toLatin1().constData(), error.line(), 0).warning()
<< error;
}
@@ -475,8 +475,8 @@ void QQuickView::continueExecute()
disconnect(d->component, SIGNAL(statusChanged(QQmlComponent::Status)), this, SLOT(continueExecute()));
if (d->component->isError()) {
- QList<QQmlError> errorList = d->component->errors();
- foreach (const QQmlError &error, errorList) {
+ const QList<QQmlError> errorList = d->component->errors();
+ for (const QQmlError &error : errorList) {
QMessageLogger(error.url().toString().toLatin1().constData(), error.line(), 0).warning()
<< error;
}
@@ -487,8 +487,8 @@ void QQuickView::continueExecute()
QObject *obj = d->component->create();
if (d->component->isError()) {
- QList<QQmlError> errorList = d->component->errors();
- foreach (const QQmlError &error, errorList) {
+ const QList<QQmlError> errorList = d->component->errors();
+ for (const QQmlError &error : errorList) {
QMessageLogger(error.url().toString().toLatin1().constData(), error.line(), 0).warning()
<< error;
}
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 4df2a8d9b1..fc6bfc43a4 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -764,7 +764,8 @@ void QQuickWindowPrivate::grabTouchPoints(QQuickItem *grabber, const QVector<int
QSet<QQuickItem*> ungrab;
for (int i = 0; i < ids.count(); ++i) {
// FIXME: deprecate this function, we need a device
- for (auto device: QQuickPointerDevice::touchDevices()) {
+ const auto touchDevices = QQuickPointerDevice::touchDevices();
+ for (auto device : touchDevices) {
auto point = device->pointerEvent()->pointById(ids.at(i));
if (!point)
continue;
@@ -783,7 +784,7 @@ void QQuickWindowPrivate::grabTouchPoints(QQuickItem *grabber, const QVector<int
setMouseGrabber(nullptr);
}
}
- foreach (QQuickItem *oldGrabber, ungrab)
+ for (QQuickItem *oldGrabber : qAsConst(ungrab))
oldGrabber->touchUngrabEvent();
}
@@ -791,7 +792,8 @@ void QQuickWindowPrivate::removeGrabber(QQuickItem *grabber, bool mouse, bool to
{
Q_Q(QQuickWindow);
if (Q_LIKELY(touch)) {
- for (auto device: QQuickPointerDevice::touchDevices()) {
+ const auto touchDevices = QQuickPointerDevice::touchDevices();
+ for (auto device : touchDevices) {
auto pointerEvent = device->pointerEvent();
for (int i = 0; i < pointerEvent->pointCount(); ++i) {
if (pointerEvent->point(i)->grabber() == grabber) {
@@ -1477,7 +1479,7 @@ bool QQuickWindowPrivate::clearHover(ulong timestamp)
QPointF pos = q->mapFromGlobal(QGuiApplicationPrivate::lastCursorPosition.toPoint());
bool accepted = false;
- foreach (QQuickItem* item, hoverItems)
+ for (QQuickItem* item : qAsConst(hoverItems))
accepted = sendHoverEvent(QEvent::HoverLeave, item, pos, pos, QGuiApplication::keyboardModifiers(), timestamp, true) || accepted;
hoverItems.clear();
return accepted;
@@ -2205,9 +2207,9 @@ void QQuickWindowPrivate::deliverTouchEvent(QQuickPointerTouchEvent *event)
// Deliver touch points to existing grabbers
bool QQuickWindowPrivate::deliverUpdatedTouchPoints(QQuickPointerTouchEvent *event, QSet<QQuickItem *> *hasFiltered)
{
- for (auto grabber: event->grabbers()) {
+ const auto grabbers = event->grabbers();
+ for (auto grabber : grabbers)
deliverMatchingPointsToItem(grabber, event, hasFiltered);
- }
return false;
}
diff --git a/src/quick/qtquick2.cpp b/src/quick/qtquick2.cpp
index c36adf56ec..9a50250ebb 100644
--- a/src/quick/qtquick2.cpp
+++ b/src/quick/qtquick2.cpp
@@ -133,7 +133,7 @@ void QQmlQtQuick2DebugStatesDelegate::updateBinding(QQmlContext *context,
typedef QPointer<QQuickState> QuickStatePointer;
QObject *object = property.object();
QString propertyName = property.name();
- foreach (const QuickStatePointer& statePointer, m_allStates) {
+ for (const QuickStatePointer& statePointer : qAsConst(m_allStates)) {
if (QQuickState *state = statePointer.data()) {
// here we assume that the revert list on itself defines the base state
if (state->isStateActive() && state->containsPropertyInRevertList(object, propertyName)) {
diff --git a/src/quick/quick.pro b/src/quick/quick.pro
index e89db182f3..9f96ae2e33 100644
--- a/src/quick/quick.pro
+++ b/src/quick/quick.pro
@@ -34,7 +34,7 @@ include(scenegraph/scenegraph.pri)
include(items/items.pri)
include(handlers/handlers.pri)
include(designer/designer.pri)
-contains(QT_CONFIG, accessibility) {
+qtConfig(accessibility) {
include(accessible/accessible.pri)
}
diff --git a/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp b/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp
index a6cb99ae05..2ff180ea99 100644
--- a/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp
+++ b/src/quick/scenegraph/adaptations/software/qsgabstractsoftwarerenderer.cpp
@@ -67,9 +67,7 @@ QSGAbstractSoftwareRenderer::~QSGAbstractSoftwareRenderer()
// Cleanup RenderableNodes
delete m_background;
- for (QSGSoftwareRenderableNode *node : m_nodes.values()) {
- delete node;
- }
+ qDeleteAll(m_nodes);
delete m_nodeUpdater;
}
diff --git a/src/quick/scenegraph/coreapi/qsgmaterial.cpp b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
index 42a4c4abd3..4bec7b19f4 100644
--- a/src/quick/scenegraph/coreapi/qsgmaterial.cpp
+++ b/src/quick/scenegraph/coreapi/qsgmaterial.cpp
@@ -67,9 +67,9 @@ void qsg_set_material_failure()
#ifndef QT_NO_OPENGL
const char *QSGMaterialShaderPrivate::loadShaderSource(QOpenGLShader::ShaderType type) const
{
- QStringList files = m_sourceFiles[type];
+ const QStringList files = m_sourceFiles[type];
QSGShaderSourceBuilder builder;
- Q_FOREACH (const QString &file, files)
+ for (const QString &file : files)
builder.appendSourceFile(file);
m_sources[type] = builder.source();
return m_sources[type].constData();
diff --git a/src/quick/scenegraph/qsgcontext_p.h b/src/quick/scenegraph/qsgcontext_p.h
index 43cf1c28ab..899278843e 100644
--- a/src/quick/scenegraph/qsgcontext_p.h
+++ b/src/quick/scenegraph/qsgcontext_p.h
@@ -139,7 +139,8 @@ public Q_SLOTS:
void textureFactoryDestroyed(QObject *o);
protected:
- QSGContext *m_sg;
+ // Hold m_sg with QPointer in the rare case it gets deleted before us.
+ QPointer<QSGContext> m_sg;
QMutex m_mutex;
QHash<QQuickTextureFactory *, QSGTexture *> m_textures;
diff --git a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
index afb9b673d9..f0a336e229 100644
--- a/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
+++ b/src/quick/scenegraph/qsgdefaultdistancefieldglyphcache.cpp
@@ -259,7 +259,8 @@ void QSGDefaultDistanceFieldGlyphCache::createTexture(TextureInfo *texInfo, int
const GLenum format = GL_ALPHA;
#endif
- m_funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, 0);
+ QByteArray zeroBuf(width * height, 0);
+ m_funcs->glTexImage2D(GL_TEXTURE_2D, 0, internalFormat, width, height, 0, format, GL_UNSIGNED_BYTE, zeroBuf.constData());
texInfo->size = QSize(width, height);
diff --git a/src/quick/scenegraph/qsgdefaultrendercontext.cpp b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
index 4fcc81fb18..6f10611ba3 100644
--- a/src/quick/scenegraph/qsgdefaultrendercontext.cpp
+++ b/src/quick/scenegraph/qsgdefaultrendercontext.cpp
@@ -70,6 +70,9 @@ QSGDefaultRenderContext::QSGDefaultRenderContext(QSGContext *context)
*/
void QSGDefaultRenderContext::initialize(void *context)
{
+ if (!m_sg)
+ return;
+
QOpenGLContext *openglContext = static_cast<QOpenGLContext *>(context);
QOpenGLFunctions *funcs = QOpenGLContext::currentContext()->functions();
@@ -163,7 +166,8 @@ void QSGDefaultRenderContext::invalidate()
m_gl->setProperty(QSG_RENDERCONTEXT_PROPERTY, QVariant());
m_gl = 0;
- m_sg->renderContextInvalidated(this);
+ if (m_sg)
+ m_sg->renderContextInvalidated(this);
emit invalidated();
}
diff --git a/src/quick/scenegraph/scenegraph.pri b/src/quick/scenegraph/scenegraph.pri
index 4ef8b0f638..a659ca5e10 100644
--- a/src/quick/scenegraph/scenegraph.pri
+++ b/src/quick/scenegraph/scenegraph.pri
@@ -1,5 +1,3 @@
-!contains(QT_CONFIG, egl):DEFINES += QT_NO_EGL
-
# DEFINES += QSG_SEPARATE_INDEX_BUFFER
# DEFINES += QSG_DISTANCEFIELD_CACHE_DEBUG
@@ -29,7 +27,7 @@ SOURCES += \
$$PWD/coreapi/qsgrendernode.cpp \
$$PWD/coreapi/qsgrendererinterface.cpp
-contains(QT_CONFIG, opengl(es1|es2)?) {
+qtConfig(opengl(es1|es2)?) {
HEADERS += \
$$PWD/coreapi/qsgbatchrenderer_p.h
SOURCES += \
@@ -73,7 +71,7 @@ SOURCES += \
$$PWD/util/qsgimagenode.cpp \
$$PWD/util/qsgninepatchnode.cpp
-contains(QT_CONFIG, opengl(es1|es2)?) {
+qtConfig(opengl(es1|es2)?) {
HEADERS += \
$$PWD/util/qsgdepthstencilbuffer_p.h \
$$PWD/util/qsgshadersourcebuilder_p.h \
@@ -104,7 +102,7 @@ SOURCES += \
$$PWD/qsgbasicglyphnode.cpp \
$$PWD/qsgrenderloop.cpp
-contains(QT_CONFIG, opengl(es1|es2)?) {
+qtConfig(opengl(es1|es2)?) {
SOURCES += \
$$PWD/qsgdefaultglyphnode.cpp \
$$PWD/qsgdefaultglyphnode_p.cpp \
@@ -150,7 +148,7 @@ RESOURCES += \
$$PWD/scenegraph.qrc
# OpenGL Shaders
-contains(QT_CONFIG, opengl(es1|es2)?) {
+qtConfig(opengl(es1|es2)?) {
OTHER_FILES += \
$$PWD/shaders/24bittextmask.frag \
$$PWD/shaders/8bittextmask.frag \
diff --git a/src/quick/util/qquickanimation.cpp b/src/quick/util/qquickanimation.cpp
index d782f9309f..206b92eb81 100644
--- a/src/quick/util/qquickanimation.cpp
+++ b/src/quick/util/qquickanimation.cpp
@@ -2643,7 +2643,7 @@ QQuickStateActions QQuickPropertyAnimation::createTransitionActions(QQuickStateA
}
if (!successfullyCreatedDefaultProperty) {
- foreach (const QString &errorMessage, errorMessages)
+ for (const QString &errorMessage : qAsConst(errorMessages))
qmlInfo(this) << errorMessage;
}
}
diff --git a/src/quick/util/qquickanimatorcontroller.cpp b/src/quick/util/qquickanimatorcontroller.cpp
index eb902b2972..6d8167413e 100644
--- a/src/quick/util/qquickanimatorcontroller.cpp
+++ b/src/quick/util/qquickanimatorcontroller.cpp
@@ -69,14 +69,14 @@ QQuickAnimatorController::~QQuickAnimatorController()
{
// The proxy job might already have been deleted, in which case we
// need to avoid calling functions on them. Then delete the job.
- foreach (QAbstractAnimationJob *job, m_deleting) {
+ for (QAbstractAnimationJob *job : qAsConst(m_deleting)) {
m_starting.take(job);
m_stopping.take(job);
m_animatorRoots.take(job);
delete job;
}
- foreach (QQuickAnimatorProxyJob *proxy, m_animatorRoots)
+ for (QQuickAnimatorProxyJob *proxy : qAsConst(m_animatorRoots))
proxy->controllerWasDeleted();
for (auto it = m_animatorRoots.keyBegin(), end = m_animatorRoots.keyEnd(); it != end; ++it)
delete *it;
@@ -171,7 +171,7 @@ static void qquick_initialize_helper(QAbstractAnimationJob *job, QQuickAnimatorC
void QQuickAnimatorController::beforeNodeSync()
{
- foreach (QAbstractAnimationJob *job, m_deleting) {
+ for (QAbstractAnimationJob *job : qAsConst(m_deleting)) {
m_starting.take(job);
m_stopping.take(job);
m_animatorRoots.take(job);
@@ -182,7 +182,7 @@ void QQuickAnimatorController::beforeNodeSync()
if (m_starting.size())
m_window->update();
- foreach (QQuickAnimatorProxyJob *proxy, m_starting) {
+ for (QQuickAnimatorProxyJob *proxy : qAsConst(m_starting)) {
QAbstractAnimationJob *job = proxy->job();
job->addAnimationChangeListener(this, QAbstractAnimationJob::Completion);
qquick_initialize_helper(job, this, true);
@@ -192,7 +192,7 @@ void QQuickAnimatorController::beforeNodeSync()
}
m_starting.clear();
- foreach (QQuickAnimatorProxyJob *proxy, m_stopping) {
+ for (QQuickAnimatorProxyJob *proxy : qAsConst(m_stopping)) {
QAbstractAnimationJob *job = proxy->job();
job->stop();
}
@@ -208,7 +208,7 @@ void QQuickAnimatorController::beforeNodeSync()
m_nodesAreInvalid = false;
}
- foreach (QQuickAnimatorJob *job, m_activeLeafAnimations) {
+ for (QQuickAnimatorJob *job : qAsConst(m_activeLeafAnimations)) {
if (!job->target())
continue;
else if (m_deletedSinceLastFrame.contains(job->target()))
@@ -218,7 +218,7 @@ void QQuickAnimatorController::beforeNodeSync()
xform->transformHelper()->sync();
}
}
- foreach (QQuickItem *wiped, m_deletedSinceLastFrame) {
+ for (QQuickItem *wiped : qAsConst(m_deletedSinceLastFrame)) {
QQuickTransformAnimatorJob::Helper *helper = m_transforms.take(wiped);
// Helper will now already have been reset in all animators referencing it.
delete helper;
@@ -229,7 +229,7 @@ void QQuickAnimatorController::beforeNodeSync()
void QQuickAnimatorController::afterNodeSync()
{
- foreach (QQuickAnimatorJob *job, m_activeLeafAnimations) {
+ for (QQuickAnimatorJob *job : qAsConst(m_activeLeafAnimations)) {
if (job->target())
job->afterNodeSync();
}
@@ -249,10 +249,10 @@ void QQuickAnimatorController::stopProxyJobs()
// to be outside the lock. It is also safe because deletion of
// proxies happens on the GUI thread, where this code is also executing.
lock();
- QSet<QQuickAnimatorProxyJob *> jobs = m_proxiesToStop;
+ const QSet<QQuickAnimatorProxyJob *> jobs = m_proxiesToStop;
m_proxiesToStop.clear();
unlock();
- foreach (QQuickAnimatorProxyJob *p, jobs)
+ for (QQuickAnimatorProxyJob *p : jobs)
p->stop();
}
diff --git a/src/quick/util/qquickpath.cpp b/src/quick/util/qquickpath.cpp
index dfed4c1885..25a4433a9b 100644
--- a/src/quick/util/qquickpath.cpp
+++ b/src/quick/util/qquickpath.cpp
@@ -358,7 +358,7 @@ QPainterPath QQuickPath::createPath(const QPointF &startPoint, const QPointF &en
bool usesPercent = false;
int index = 0;
- foreach (QQuickPathElement *pathElement, d->_pathElements) {
+ for (QQuickPathElement *pathElement : qAsConst(d->_pathElements)) {
if (QQuickCurve *curve = qobject_cast<QQuickCurve *>(pathElement)) {
QQuickPathData data;
data.index = index;
@@ -432,17 +432,17 @@ void QQuickPath::classBegin()
void QQuickPath::disconnectPathElements()
{
- Q_D(QQuickPath);
+ Q_D(const QQuickPath);
- foreach (QQuickPathElement *pathElement, d->_pathElements)
+ for (QQuickPathElement *pathElement : d->_pathElements)
disconnect(pathElement, SIGNAL(changed()), this, SLOT(processPath()));
}
void QQuickPath::connectPathElements()
{
- Q_D(QQuickPath);
+ Q_D(const QQuickPath);
- foreach (QQuickPathElement *pathElement, d->_pathElements)
+ for (QQuickPathElement *pathElement : d->_pathElements)
connect(pathElement, SIGNAL(changed()), this, SLOT(processPath()));
}
@@ -453,7 +453,7 @@ void QQuickPath::gatherAttributes()
QSet<QString> attributes;
// First gather up all the attributes
- foreach (QQuickPathElement *pathElement, d->_pathElements) {
+ for (QQuickPathElement *pathElement : qAsConst(d->_pathElements)) {
if (QQuickCurve *curve = qobject_cast<QQuickCurve *>(pathElement))
d->_pathCurves.append(curve);
else if (QQuickPathAttribute *attribute = qobject_cast<QQuickPathAttribute *>(pathElement))
@@ -488,7 +488,7 @@ QStringList QQuickPath::attributes() const
QSet<QString> attrs;
// First gather up all the attributes
- foreach (QQuickPathElement *pathElement, d->_pathElements) {
+ for (QQuickPathElement *pathElement : d->_pathElements) {
if (QQuickPathAttribute *attribute =
qobject_cast<QQuickPathAttribute *>(pathElement))
attrs.insert(attribute->name());
diff --git a/src/quick/util/qquickpixmapcache.cpp b/src/quick/util/qquickpixmapcache.cpp
index 49956de822..9722bf544b 100644
--- a/src/quick/util/qquickpixmapcache.cpp
+++ b/src/quick/util/qquickpixmapcache.cpp
@@ -448,7 +448,7 @@ QQuickPixmapReader::~QQuickPixmapReader()
mutex.lock();
// manually cancel all outstanding jobs.
- foreach (QQuickPixmapReply *reply, jobs) {
+ for (QQuickPixmapReply *reply : qAsConst(jobs)) {
if (reply->data && reply->data->reply == reply)
reply->data->reply = 0;
delete reply;
diff --git a/src/quick/util/qquickpropertychanges.cpp b/src/quick/util/qquickpropertychanges.cpp
index 555533a44e..37a910876e 100644
--- a/src/quick/util/qquickpropertychanges.cpp
+++ b/src/quick/util/qquickpropertychanges.cpp
@@ -256,7 +256,7 @@ void QQuickPropertyChangesPrivate::decode()
if (decoded)
return;
- foreach (const QV4::CompiledData::Binding *binding, bindings)
+ for (const QV4::CompiledData::Binding *binding : qAsConst(bindings))
decodeBinding(QString(), compilationUnit->data, binding);
bindings.clear();
diff --git a/src/quick/util/qquickshortcut.cpp b/src/quick/util/qquickshortcut.cpp
index 66c29474cc..9725ddd671 100644
--- a/src/quick/util/qquickshortcut.cpp
+++ b/src/quick/util/qquickshortcut.cpp
@@ -144,7 +144,7 @@ void QQuickShortcut::setSequence(const QVariant &sequence)
\since 5.6
This property provides the shortcut's key sequence as a platform specific
- string. This means that it will be shown translated, and on OS X it will
+ string. This means that it will be shown translated, and on \macos it will
resemble a key sequence from the menu bar. It is best to display this text
to the user (for example, on a tooltip).
diff --git a/src/quick/util/qquickstate.cpp b/src/quick/util/qquickstate.cpp
index 947a5b6e4e..2d3934cce8 100644
--- a/src/quick/util/qquickstate.cpp
+++ b/src/quick/util/qquickstate.cpp
@@ -334,7 +334,7 @@ QQuickStatePrivate::generateActionList() const
}
}
- foreach(QQuickStateOperation *op, operations)
+ for (QQuickStateOperation *op : operations)
applyList << op->actions();
inState = false;
@@ -676,7 +676,7 @@ void QQuickState::apply(QQuickTransition *trans, QQuickState *revert)
#ifndef QT_NO_DEBUG_STREAM
// Output for debugging
if (stateChangeDebug()) {
- foreach(const QQuickStateAction &action, applyList) {
+ for (const QQuickStateAction &action : qAsConst(applyList)) {
if (action.event)
qWarning() << " QQuickStateAction event:" << action.event->type();
else
diff --git a/src/quick/util/qquicktransitionmanager.cpp b/src/quick/util/qquicktransitionmanager.cpp
index 60f710549b..714e6d62b6 100644
--- a/src/quick/util/qquicktransitionmanager.cpp
+++ b/src/quick/util/qquicktransitionmanager.cpp
@@ -106,7 +106,7 @@ void QQuickTransitionManager::complete()
void QQuickTransitionManagerPrivate::applyBindings()
{
- foreach(const QQuickStateAction &action, bindingsList) {
+ for (const QQuickStateAction &action : qAsConst(bindingsList)) {
if (action.toBinding) {
QQmlPropertyPrivate::setBinding(action.toBinding.data());
} else if (action.event) {
@@ -133,7 +133,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
QQuickStateOperation::ActionList applyList = list;
// Determine which actions are binding changes and disable any current bindings
- foreach(const QQuickStateAction &action, applyList) {
+ for (const QQuickStateAction &action : qAsConst(applyList)) {
if (action.toBinding)
d->bindingsList << action;
if (action.fromBinding)
@@ -184,7 +184,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
}
// Revert back to the original values
- foreach(const QQuickStateAction &action, applyList) {
+ for (const QQuickStateAction &action : qAsConst(applyList)) {
if (action.event) {
if (action.event->isReversable()) {
action.event->clearBindings();
@@ -239,7 +239,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
// be applied immediately. We skip applying bindings, as they are all
// applied at the end in applyBindings() to avoid any nastiness mid
// transition
- foreach(const QQuickStateAction &action, applyList) {
+ for (const QQuickStateAction &action : qAsConst(applyList)) {
if (action.event && !action.event->changesBindings()) {
if (action.event->isReversable() && action.reverseEvent)
action.event->reverse();
@@ -251,7 +251,7 @@ void QQuickTransitionManager::transition(const QList<QQuickStateAction> &list,
}
#ifndef QT_NO_DEBUG_STREAM
if (stateChangeDebug()) {
- foreach(const QQuickStateAction &action, applyList) {
+ for (const QQuickStateAction &action : qAsConst(applyList)) {
if (action.event)
qWarning() << " No transition for event:" << action.event->type();
else
diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp
index b8c5b900c9..c608697c94 100644
--- a/src/quickwidgets/qquickwidget.cpp
+++ b/src/quickwidgets/qquickwidget.cpp
@@ -1603,7 +1603,8 @@ void QQuickWidget::paintEvent(QPaintEvent *event)
painter.drawImage(rect(), d->softwareImage);
} else {
//Paint only the updated areas
- for (auto targetRect : d->updateRegion.rects()) {
+ const auto rects = d->updateRegion.rects();
+ for (auto targetRect : rects) {
auto sourceRect = QRect(targetRect.topLeft() * devicePixelRatio(), targetRect.size() * devicePixelRatio());
painter.drawImage(targetRect, d->softwareImage, sourceRect);
}
diff --git a/src/src.pro b/src/src.pro
index fbc4feaec4..fc1cea67cd 100644
--- a/src/src.pro
+++ b/src/src.pro
@@ -5,9 +5,8 @@ SUBDIRS += \
quick \
qmltest
-qtHaveModule(gui):contains(QT_CONFIG, opengl(es1|es2)?) {
+qtHaveModule(gui):qtConfig(opengl(es1|es2)?): \
SUBDIRS += particles
-}
qtHaveModule(gui): qtHaveModule(widgets): SUBDIRS += quickwidgets
diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro
index b72a43d742..556f5ddc7a 100644
--- a/tests/auto/auto.pro
+++ b/tests/auto/auto.pro
@@ -8,12 +8,15 @@ SUBDIRS=\
installed_cmake \
toolsupport
-qtHaveModule(gui):contains(QT_CONFIG, opengl(es1|es2)?) {
+qtHaveModule(gui):qtConfig(opengl(es1|es2)?) {
SUBDIRS += particles
qtHaveModule(widgets): SUBDIRS += quickwidgets
}
+# console applications not supported
+uikit: SUBDIRS -= qmltest
+
qmldevtools.CONFIG = host_build
installed_cmake.depends = cmake
diff --git a/tests/auto/particles/particles.pro b/tests/auto/particles/particles.pro
index 265a1eabc7..6ee1290dbb 100644
--- a/tests/auto/particles/particles.pro
+++ b/tests/auto/particles/particles.pro
@@ -25,6 +25,5 @@ PRIVATETESTS += \
qquickturbulence \
qquickwander
-contains(QT_CONFIG, private_tests) {
+qtConfig(private_tests): \
SUBDIRS += $$PRIVATETESTS
-}
diff --git a/tests/auto/particles/qquickage/tst_qquickage.cpp b/tests/auto/particles/qquickage/tst_qquickage.cpp
index 04c6fbd9e4..a233b30043 100644
--- a/tests/auto/particles/qquickage/tst_qquickage.cpp
+++ b/tests/auto/particles/qquickage/tst_qquickage.cpp
@@ -61,7 +61,7 @@ void tst_qquickage::test_kill()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -86,7 +86,7 @@ void tst_qquickage::test_jump()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -112,7 +112,7 @@ void tst_qquickage::test_onceOff()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -138,7 +138,7 @@ void tst_qquickage::test_sustained()
//TODO: Ensure some particles have lived to 0.4s point despite unified timer
//Can't verify size, because particles never die. It will constantly grow.
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickangleddirection/tst_qquickangleddirection.cpp b/tests/auto/particles/qquickangleddirection/tst_qquickangleddirection.cpp
index 4ff72f159d..b3fc01caa6 100644
--- a/tests/auto/particles/qquickangleddirection/tst_qquickangleddirection.cpp
+++ b/tests/auto/particles/qquickangleddirection/tst_qquickangleddirection.cpp
@@ -58,7 +58,7 @@ void tst_qquickangleddirection::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickcumulativedirection/tst_qquickcumulativedirection.cpp b/tests/auto/particles/qquickcumulativedirection/tst_qquickcumulativedirection.cpp
index 795fcaf42e..360b222367 100644
--- a/tests/auto/particles/qquickcumulativedirection/tst_qquickcumulativedirection.cpp
+++ b/tests/auto/particles/qquickcumulativedirection/tst_qquickcumulativedirection.cpp
@@ -57,7 +57,7 @@ void tst_qquickcumulativedirection::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp b/tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp
index fb15af4dd1..ee05fb29c9 100644
--- a/tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp
+++ b/tests/auto/particles/qquickcustomaffector/tst_qquickcustomaffector.cpp
@@ -59,7 +59,7 @@ void tst_qquickcustomaffector::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
//in CI the whole simulation often happens at once, so dead particles end up missing out
@@ -92,7 +92,7 @@ void tst_qquickcustomaffector::test_move()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
if (!d->stillAlive(system))
diff --git a/tests/auto/particles/qquickcustomparticle/tst_qquickcustomparticle.cpp b/tests/auto/particles/qquickcustomparticle/tst_qquickcustomparticle.cpp
index a722508a3e..60c6a37899 100644
--- a/tests/auto/particles/qquickcustomparticle/tst_qquickcustomparticle.cpp
+++ b/tests/auto/particles/qquickcustomparticle/tst_qquickcustomparticle.cpp
@@ -60,7 +60,7 @@ void tst_qquickcustomparticle::test_basic()
bool oneNonZero = false;
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickellipseextruder/tst_qquickellipseextruder.cpp b/tests/auto/particles/qquickellipseextruder/tst_qquickellipseextruder.cpp
index ac8e2bac49..a1fe5b225d 100644
--- a/tests/auto/particles/qquickellipseextruder/tst_qquickellipseextruder.cpp
+++ b/tests/auto/particles/qquickellipseextruder/tst_qquickellipseextruder.cpp
@@ -74,7 +74,7 @@ void tst_qquickellipseextruder::test_basic()
//Filled
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -91,7 +91,7 @@ void tst_qquickellipseextruder::test_basic()
//Just border
QCOMPARE(system->groupData[1]->size(), 500);
- foreach (QQuickParticleData *d, system->groupData[1]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[1]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickfriction/tst_qquickfriction.cpp b/tests/auto/particles/qquickfriction/tst_qquickfriction.cpp
index 70e0291330..ab682c591e 100644
--- a/tests/auto/particles/qquickfriction/tst_qquickfriction.cpp
+++ b/tests/auto/particles/qquickfriction/tst_qquickfriction.cpp
@@ -59,7 +59,7 @@ void tst_qquickfriction::test_basic()
//Default is just slowed a little
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -76,7 +76,7 @@ void tst_qquickfriction::test_basic()
//Nondefault comes to a complete stop within the first half of its life
QCOMPARE(system->groupData[1]->size(), 500);
- foreach (QQuickParticleData *d, system->groupData[1]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[1]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -103,7 +103,7 @@ void tst_qquickfriction::test_threshold()
//Velocity capped at 50, but it might take a frame or two to get there
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1.0f)
continue; //Particle data unused
if (myFuzzyGEQ(d->t, ((qreal)system->timeInt/1000.0) - 0.1))
diff --git a/tests/auto/particles/qquickgravity/tst_qquickgravity.cpp b/tests/auto/particles/qquickgravity/tst_qquickgravity.cpp
index 8ef075dc9b..34566b90eb 100644
--- a/tests/auto/particles/qquickgravity/tst_qquickgravity.cpp
+++ b/tests/auto/particles/qquickgravity/tst_qquickgravity.cpp
@@ -58,7 +58,7 @@ void tst_qquickgravity::test_basic()
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
float mag = 707.10678f;
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1 || !d->stillAlive(system))
continue; //Particle data unused or dead
diff --git a/tests/auto/particles/qquickgroupgoal/tst_qquickgroupgoal.cpp b/tests/auto/particles/qquickgroupgoal/tst_qquickgroupgoal.cpp
index fc270b991f..1228b4cc68 100644
--- a/tests/auto/particles/qquickgroupgoal/tst_qquickgroupgoal.cpp
+++ b/tests/auto/particles/qquickgroupgoal/tst_qquickgroupgoal.cpp
@@ -58,7 +58,7 @@ void tst_qquickgroupgoal::test_instantTransition()
ensureAnimTime(600, system->m_animation);
QVERIFY(system->groupData[0]->size() <= 500 && system->groupData[0]->size() >= 450);
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickimageparticle/tst_qquickimageparticle.cpp b/tests/auto/particles/qquickimageparticle/tst_qquickimageparticle.cpp
index cd684ec59b..7e07878d39 100644
--- a/tests/auto/particles/qquickimageparticle/tst_qquickimageparticle.cpp
+++ b/tests/auto/particles/qquickimageparticle/tst_qquickimageparticle.cpp
@@ -72,7 +72,7 @@ void tst_qquickimageparticle::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -116,7 +116,7 @@ void tst_qquickimageparticle::test_colored()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -160,7 +160,7 @@ void tst_qquickimageparticle::test_colorVariance()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -205,7 +205,7 @@ void tst_qquickimageparticle::test_deformed()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -249,7 +249,7 @@ void tst_qquickimageparticle::test_tabled()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -294,7 +294,7 @@ void tst_qquickimageparticle::test_sprite()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp b/tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp
index 98aac71e93..d9791cdb33 100644
--- a/tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp
+++ b/tests/auto/particles/qquickitemparticle/tst_qquickitemparticle.cpp
@@ -60,7 +60,7 @@ void tst_qquickitemparticle::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquicklineextruder/tst_qquicklineextruder.cpp b/tests/auto/particles/qquicklineextruder/tst_qquicklineextruder.cpp
index 1f36874f0f..6baf8539d3 100644
--- a/tests/auto/particles/qquicklineextruder/tst_qquicklineextruder.cpp
+++ b/tests/auto/particles/qquicklineextruder/tst_qquicklineextruder.cpp
@@ -57,7 +57,7 @@ void tst_qquicklineextruder::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -73,7 +73,7 @@ void tst_qquicklineextruder::test_basic()
}
QCOMPARE(system->groupData[1]->size(), 500);
- foreach (QQuickParticleData *d, system->groupData[1]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[1]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickmaskextruder/tst_qquickmaskextruder.cpp b/tests/auto/particles/qquickmaskextruder/tst_qquickmaskextruder.cpp
index a3d0988019..d8481efc47 100644
--- a/tests/auto/particles/qquickmaskextruder/tst_qquickmaskextruder.cpp
+++ b/tests/auto/particles/qquickmaskextruder/tst_qquickmaskextruder.cpp
@@ -57,7 +57,7 @@ void tst_qquickmaskextruder::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickparticlegroup/tst_qquickparticlegroup.cpp b/tests/auto/particles/qquickparticlegroup/tst_qquickparticlegroup.cpp
index 8b7224623a..8791d19db6 100644
--- a/tests/auto/particles/qquickparticlegroup/tst_qquickparticlegroup.cpp
+++ b/tests/auto/particles/qquickparticlegroup/tst_qquickparticlegroup.cpp
@@ -58,7 +58,7 @@ void tst_qquickparticlegroup::test_instantTransition()
//A frame or two worth of particles will be missed, the transition doesn't take effect on the frame it's spawned (QTBUG-21781)
QVERIFY(system->groupData[0]->size() <= 500 && system->groupData[0]->size() >= 450);
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickparticlesystem/tst_qquickparticlesystem.cpp b/tests/auto/particles/qquickparticlesystem/tst_qquickparticlesystem.cpp
index 4a3c5cdc74..5c82b946e5 100644
--- a/tests/auto/particles/qquickparticlesystem/tst_qquickparticlesystem.cpp
+++ b/tests/auto/particles/qquickparticlesystem/tst_qquickparticlesystem.cpp
@@ -58,7 +58,7 @@ void tst_qquickparticlesystem::test_basic()
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
int stillAlive = 0;
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickpointattractor/tst_qquickpointattractor.cpp b/tests/auto/particles/qquickpointattractor/tst_qquickpointattractor.cpp
index 99a8530d3a..c0d7d38512 100644
--- a/tests/auto/particles/qquickpointattractor/tst_qquickpointattractor.cpp
+++ b/tests/auto/particles/qquickpointattractor/tst_qquickpointattractor.cpp
@@ -57,7 +57,7 @@ void tst_qquickpointattractor::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickpointdirection/tst_qquickpointdirection.cpp b/tests/auto/particles/qquickpointdirection/tst_qquickpointdirection.cpp
index 0d150fb86d..5cc23e0306 100644
--- a/tests/auto/particles/qquickpointdirection/tst_qquickpointdirection.cpp
+++ b/tests/auto/particles/qquickpointdirection/tst_qquickpointdirection.cpp
@@ -57,7 +57,7 @@ void tst_qquickpointdirection::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickrectangleextruder/tst_qquickrectangleextruder.cpp b/tests/auto/particles/qquickrectangleextruder/tst_qquickrectangleextruder.cpp
index 24b30bf9ab..414e2d36f7 100644
--- a/tests/auto/particles/qquickrectangleextruder/tst_qquickrectangleextruder.cpp
+++ b/tests/auto/particles/qquickrectangleextruder/tst_qquickrectangleextruder.cpp
@@ -57,7 +57,7 @@ void tst_qquickrectangleextruder::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -76,7 +76,7 @@ void tst_qquickrectangleextruder::test_basic()
}
QCOMPARE(system->groupData[1]->size(), 500);
- foreach (QQuickParticleData *d, system->groupData[1]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[1]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickspritegoal/tst_qquickspritegoal.cpp b/tests/auto/particles/qquickspritegoal/tst_qquickspritegoal.cpp
index 8249159e43..ca5d9171f9 100644
--- a/tests/auto/particles/qquickspritegoal/tst_qquickspritegoal.cpp
+++ b/tests/auto/particles/qquickspritegoal/tst_qquickspritegoal.cpp
@@ -57,7 +57,7 @@ void tst_qquickspritegoal::test_instantTransition()
ensureAnimTime(600, system->m_animation);
QVERIFY(system->groupData[0]->size() <= 500 && system->groupData[0]->size() >= 450);
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquicktargetdirection/tst_qquicktargetdirection.cpp b/tests/auto/particles/qquicktargetdirection/tst_qquicktargetdirection.cpp
index 8d9556fdac..2f45263c37 100644
--- a/tests/auto/particles/qquicktargetdirection/tst_qquicktargetdirection.cpp
+++ b/tests/auto/particles/qquicktargetdirection/tst_qquicktargetdirection.cpp
@@ -57,7 +57,7 @@ void tst_qquicktargetdirection::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquicktrailemitter/tst_qquicktrailemitter.cpp b/tests/auto/particles/qquicktrailemitter/tst_qquicktrailemitter.cpp
index 99ecd7a06a..27d9bf01c9 100644
--- a/tests/auto/particles/qquicktrailemitter/tst_qquicktrailemitter.cpp
+++ b/tests/auto/particles/qquicktrailemitter/tst_qquicktrailemitter.cpp
@@ -57,7 +57,7 @@ void tst_qquicktrailemitter::test_basic()
ensureAnimTime(600, system->m_animation);
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -74,7 +74,7 @@ void tst_qquicktrailemitter::test_basic()
}
QVERIFY(extremelyFuzzyCompare(system->groupData[1]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[1]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[1]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickturbulence/tst_qquickturbulence.cpp b/tests/auto/particles/qquickturbulence/tst_qquickturbulence.cpp
index c8024470e4..74fafdc1d2 100644
--- a/tests/auto/particles/qquickturbulence/tst_qquickturbulence.cpp
+++ b/tests/auto/particles/qquickturbulence/tst_qquickturbulence.cpp
@@ -59,7 +59,7 @@ void tst_qquickturbulence::test_basic()
//Note that the noise image built-in provides the 'randomness', so this test should be stable so long as it and the size
//of the Turbulence item remain the same
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 500, 10));
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/particles/qquickwander/tst_qquickwander.cpp b/tests/auto/particles/qquickwander/tst_qquickwander.cpp
index 6e37fc648c..51ef7a272e 100644
--- a/tests/auto/particles/qquickwander/tst_qquickwander.cpp
+++ b/tests/auto/particles/qquickwander/tst_qquickwander.cpp
@@ -61,7 +61,7 @@ void tst_qquickwander::test_basic()
//the 500 was randomly changed from 0.0 in velocity
bool vxChanged = false;
bool vyChanged = false;
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/auto/qml/debugger/debugger.pro b/tests/auto/qml/debugger/debugger.pro
index ccb2d71c53..a50411e18b 100644
--- a/tests/auto/qml/debugger/debugger.pro
+++ b/tests/auto/qml/debugger/debugger.pro
@@ -20,6 +20,6 @@ PRIVATETESTS += \
SUBDIRS += $$PUBLICTESTS
-contains(QT_CONFIG, private_tests) {
+qtConfig(private_tests): \
SUBDIRS += $$PRIVATETESTS
-}
+
diff --git a/tests/auto/qml/qml.pro b/tests/auto/qml/qml.pro
index a1daa7a0c4..68a2eace19 100644
--- a/tests/auto/qml/qml.pro
+++ b/tests/auto/qml/qml.pro
@@ -8,7 +8,6 @@ PUBLICTESTS += \
qjsvalueiterator \
qjsonbinding \
qmlmin \
- qmlplugindump \
qqmlcomponent \
qqmlconsole \
qqmlengine \
@@ -74,14 +73,13 @@ qtHaveModule(widgets) {
SUBDIRS += $$PUBLICTESTS \
qqmlextensionplugin
SUBDIRS += $$METATYPETESTS
-!winrt { # no QProcess on winrt
+!uikit:!winrt { # no QProcess on uikit/winrt
!contains(QT_CONFIG, no-qml-debug): SUBDIRS += debugger
- SUBDIRS += qmllint
+ SUBDIRS += qmllint qmlplugindump
}
-contains(QT_CONFIG, private_tests) {
+qtConfig(private_tests): \
SUBDIRS += $$PRIVATETESTS
-}
qtNomakeTools( \
qmlplugindump \
diff --git a/tests/auto/qml/qqmlconsole/data/categorized_logging.qml b/tests/auto/qml/qqmlconsole/data/categorized_logging.qml
new file mode 100644
index 0000000000..d19b6ecc41
--- /dev/null
+++ b/tests/auto/qml/qqmlconsole/data/categorized_logging.qml
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Pelagicore AG
+** Contact: https://www.qt.io/licensing/
+**
+** This file is part of the QtQml module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** Commercial License Usage
+** Licensees holding valid commercial Qt licenses may use this file in
+** accordance with the commercial license agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in
+** a written agreement between you and The Qt Company. For licensing terms
+** and conditions see https://www.qt.io/terms-conditions. For further
+** information use the contact form at https://www.qt.io/contact-us.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 3 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL3 included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 3 requirements
+** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU
+** General Public License version 2.0 or (at your option) the GNU General
+** Public license version 3 or any later version approved by the KDE Free
+** Qt Foundation. The licenses are as published by the Free Software
+** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3
+** included in the packaging of this file. Please review the following
+** information to ensure the GNU General Public License requirements will
+** be met: https://www.gnu.org/licenses/gpl-2.0.html and
+** https://www.gnu.org/licenses/gpl-3.0.html.
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.8
+
+Item {
+ id:root
+
+ LoggingCategory {
+ id: testCategory
+ name: "qt.test"
+ }
+
+ LoggingCategory {
+ id: emptyCategory
+ }
+
+ Component.onCompleted: {
+ console.debug(testCategory, "console.debug");
+ console.log(testCategory, "console.log");
+ console.info(testCategory, "console.info");
+ console.warn(testCategory, "console.warn");
+ console.error(testCategory, "console.error");
+
+ testCategory.name = "qt.test2";
+
+ console.error(emptyCategory, "console.error");
+ }
+}
diff --git a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp
index f12656c5fe..f832143935 100644
--- a/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp
+++ b/tests/auto/qml/qqmlconsole/tst_qqmlconsole.cpp
@@ -40,6 +40,7 @@ public:
private slots:
void logging();
+ void categorized_logging();
void tracing();
void profiling();
void testAssert();
@@ -87,6 +88,41 @@ void tst_qqmlconsole::logging()
delete object;
}
+void tst_qqmlconsole::categorized_logging()
+{
+ QUrl testUrl = testFileUrl("categorized_logging.qml");
+ QQmlTestMessageHandler messageHandler;
+ messageHandler.setIncludeCategoriesEnabled(true);
+
+ QLoggingCategory testCategory("qt.test");
+ testCategory.setEnabled(QtDebugMsg, true);
+ QVERIFY(testCategory.isDebugEnabled());
+ QVERIFY(testCategory.isWarningEnabled());
+ QVERIFY(testCategory.isCriticalEnabled());
+
+ QQmlComponent component(&engine, testUrl);
+ QObject *object = component.create();
+ QVERIFY2(object != 0, component.errorString().toUtf8());
+
+ QVERIFY(messageHandler.messages().contains("qt.test: console.info"));
+ QVERIFY(messageHandler.messages().contains("qt.test: console.warn"));
+ QVERIFY(messageHandler.messages().contains("qt.test: console.error"));
+
+ QString emptyCategory = "default: " + QString::fromLatin1("%1:%2:%3: ").arg(testUrl.toString()).arg(50).arg(5) +
+ "QML LoggingCategory: Declaring the name of the LoggingCategory is mandatory and cannot be changed later !";
+ QVERIFY(messageHandler.messages().contains(emptyCategory));
+
+ QString changedCategory = "default: " + QString::fromLatin1("%1:%2:%3: ").arg(testUrl.toString()).arg(45).arg(5) +
+ "QML LoggingCategory: The name of a LoggingCategory cannot be changed after the Item is created";
+ QVERIFY(messageHandler.messages().contains(changedCategory));
+
+ QString useEmptyCategory = "default: " + QString::fromLatin1("%1:%2: ").arg(testUrl.toString()).arg(63) +
+ "Error: A QmlLoggingCatgory was provided without a valid name";
+ QVERIFY(messageHandler.messages().contains(useEmptyCategory));
+
+ delete object;
+}
+
void tst_qqmlconsole::tracing()
{
QUrl testUrl = testFileUrl("tracing.qml");
diff --git a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
index e0cde6c86f..f49fd391ac 100644
--- a/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
+++ b/tests/auto/qml/qqmlcontext/tst_qqmlcontext.cpp
@@ -61,6 +61,7 @@ private slots:
void qtbug_22535();
void evalAfterInvalidate();
void qobjectDerived();
+ void qtbug_49232();
private:
QQmlEngine engine;
@@ -200,6 +201,8 @@ class TestObject : public QObject
Q_PROPERTY(int a READ a NOTIFY aChanged)
Q_PROPERTY(int b READ b NOTIFY bChanged)
Q_PROPERTY(int c READ c NOTIFY cChanged)
+ Q_PROPERTY(char d READ d NOTIFY dChanged)
+ Q_PROPERTY(uchar e READ e NOTIFY eChanged)
public:
TestObject() : _a(10), _b(10), _c(10) {}
@@ -213,15 +216,25 @@ public:
int c() const { return _c; }
void setC(int c) { _c = c; emit cChanged(); }
+ char d() const { return _d; }
+ void setD(char d) { _d = d; emit dChanged(); }
+
+ uchar e() const { return _e; }
+ void setE(uchar e) { _e = e; emit eChanged(); }
+
signals:
void aChanged();
void bChanged();
void cChanged();
+ void dChanged();
+ void eChanged();
private:
int _a;
int _b;
int _c;
+ char _d;
+ uchar _e;
};
#define TEST_CONTEXT_PROPERTY(ctxt, name, value) \
@@ -694,6 +707,22 @@ void tst_qqmlcontext::qobjectDerived()
QCOMPARE(command.count, 2);
}
+void tst_qqmlcontext::qtbug_49232()
+{
+ TestObject testObject;
+ testObject.setD('a');
+ testObject.setE(97);
+
+ QQmlEngine engine;
+ engine.rootContext()->setContextProperty("TestObject", &testObject);
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0; QtObject { property int valueOne: TestObject.d; property int valueTwo: TestObject.e }", QUrl());
+ QScopedPointer<QObject> obj(component.create());
+
+ QCOMPARE(obj->property("valueOne"), QVariant('a'));
+ QCOMPARE(obj->property("valueTwo"), QVariant(97));
+}
+
QTEST_MAIN(tst_qqmlcontext)
#include "tst_qqmlcontext.moc"
diff --git a/tests/auto/qml/qqmlecmascript/data/DestructionHelper.qml b/tests/auto/qml/qqmlecmascript/data/DestructionHelper.qml
new file mode 100644
index 0000000000..8bb0a3554e
--- /dev/null
+++ b/tests/auto/qml/qqmlecmascript/data/DestructionHelper.qml
@@ -0,0 +1,3 @@
+import Test 1.0
+WeakReferenceMutator {
+}
diff --git a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
index 30ecfa7d96..a5373ccbcd 100644
--- a/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
+++ b/tests/auto/qml/qqmlecmascript/tst_qqmlecmascript.cpp
@@ -44,6 +44,8 @@
#include <private/qv4scopedvalue_p.h>
#include <private/qv4alloca_p.h>
#include <private/qv4runtime_p.h>
+#include <private/qv4object_p.h>
+#include <private/qqmlcomponentattached_p.h>
#ifdef Q_CC_MSVC
#define NO_INLINE __declspec(noinline)
@@ -283,6 +285,7 @@ private slots:
void replaceBinding();
void deleteRootObjectInCreation();
void onDestruction();
+ void onDestructionViaGC();
void bindingSuppression();
void signalEmitted();
void threadSignal();
@@ -7200,6 +7203,105 @@ void tst_qqmlecmascript::onDestruction()
}
}
+class WeakReferenceMutator : public QObject
+{
+ Q_OBJECT
+public:
+ WeakReferenceMutator()
+ : resultPtr(Q_NULLPTR)
+ , weakRef(Q_NULLPTR)
+ {}
+
+ void init(QV4::ExecutionEngine *v4, QV4::WeakValue *weakRef, bool *resultPtr)
+ {
+ QV4::QObjectWrapper::wrap(v4, this);
+ QQmlEngine::setObjectOwnership(this, QQmlEngine::JavaScriptOwnership);
+
+ this->resultPtr = resultPtr;
+ this->weakRef = weakRef;
+
+ QObject::connect(QQmlComponent::qmlAttachedProperties(this), &QQmlComponentAttached::destruction, this, &WeakReferenceMutator::reviveFirstWeakReference);
+ }
+
+private slots:
+ void reviveFirstWeakReference() {
+ *resultPtr = weakRef->valueRef() && weakRef->isNullOrUndefined();
+ if (!*resultPtr)
+ return;
+ QV4::ExecutionEngine *v4 = QV8Engine::getV4(qmlEngine(this));
+ weakRef->set(v4, v4->newObject());
+ *resultPtr = weakRef->valueRef() && !weakRef->isNullOrUndefined();
+ }
+
+public:
+ bool *resultPtr;
+
+ QV4::WeakValue *weakRef;
+};
+
+QT_BEGIN_NAMESPACE
+
+namespace QV4 {
+
+namespace Heap {
+struct WeakReferenceSentinel : public Object {
+ WeakReferenceSentinel(WeakValue *weakRef, bool *resultPtr)
+ : weakRef(weakRef)
+ , resultPtr(resultPtr) {
+
+ }
+
+ ~WeakReferenceSentinel() {
+ *resultPtr = weakRef->isNullOrUndefined();
+ }
+
+ WeakValue *weakRef;
+ bool *resultPtr;
+};
+} // namespace Heap
+
+struct WeakReferenceSentinel : public Object {
+ V4_OBJECT2(WeakReferenceSentinel, Object)
+ V4_NEEDS_DESTROY
+};
+
+} // namespace QV4
+
+QT_END_NAMESPACE
+
+DEFINE_OBJECT_VTABLE(QV4::WeakReferenceSentinel);
+
+void tst_qqmlecmascript::onDestructionViaGC()
+{
+ qmlRegisterType<WeakReferenceMutator>("Test", 1, 0, "WeakReferenceMutator");
+
+ QQmlEngine engine;
+ QV4::ExecutionEngine *v4 = QV8Engine::getV4(&engine);
+
+ QQmlComponent component(&engine, testFileUrl("DestructionHelper.qml"));
+
+ QScopedPointer<QV4::WeakValue> weakRef;
+
+ bool mutatorResult = false;
+ bool sentinelResult = false;
+
+ {
+ weakRef.reset(new QV4::WeakValue);
+ weakRef->set(v4, v4->newObject());
+ QVERIFY(!weakRef->isNullOrUndefined());
+
+ QPointer<WeakReferenceMutator> weakReferenceMutator = qobject_cast<WeakReferenceMutator *>(component.create());
+ QVERIFY2(!weakReferenceMutator.isNull(), qPrintable(component.errorString()));
+ weakReferenceMutator->init(v4, weakRef.data(), &mutatorResult);
+
+ v4->memoryManager->allocObject<QV4::WeakReferenceSentinel>(weakRef.data(), &sentinelResult);
+ }
+ gc(engine);
+
+ QVERIFY2(mutatorResult, "We failed to re-assign the weak reference a new value during GC");
+ QVERIFY2(sentinelResult, "The weak reference was not cleared properly");
+}
+
struct EventProcessor : public QObject
{
Q_OBJECT
diff --git a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
index 21e6d9efe6..fe73610bcc 100644
--- a/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
+++ b/tests/auto/qml/qqmlproperty/tst_qqmlproperty.cpp
@@ -327,11 +327,8 @@ class PropertyObject : public QObject
Q_PROPERTY(MyQmlObject *qmlObject READ qmlObject)
Q_PROPERTY(MyQObject *qObject READ qObject WRITE setQObject NOTIFY qObjectChanged)
Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty)
- Q_PROPERTY(char charProperty READ charProperty WRITE setCharProperty)
Q_PROPERTY(QChar qcharProperty READ qcharProperty WRITE setQcharProperty)
Q_PROPERTY(QChar constQChar READ constQChar STORED false CONSTANT FINAL)
- Q_PROPERTY(char constChar READ constChar STORED false CONSTANT FINAL)
- Q_PROPERTY(int constInt READ constInt STORED false CONSTANT FINAL)
Q_CLASSINFO("DefaultProperty", "defaultProperty")
public:
@@ -368,15 +365,11 @@ public:
}
QString stringProperty() const { return m_stringProperty;}
- char charProperty() const { return m_charProperty; }
QChar qcharProperty() const { return m_qcharProperty; }
QChar constQChar() const { return 0x25cf; /* Unicode: black circle */ }
- char constChar() const { return 'A'; }
- int constInt() const { return 123456; }
void setStringProperty(QString arg) { m_stringProperty = arg; }
- void setCharProperty(char arg) { m_charProperty = arg; }
void setQcharProperty(QChar arg) { m_qcharProperty = arg; }
signals:
@@ -393,7 +386,6 @@ private:
MyQmlObject m_qmlObject;
MyQObject *m_qObject;
QString m_stringProperty;
- char m_charProperty;
QChar m_qcharProperty;
};
@@ -1418,23 +1410,14 @@ void tst_qqmlproperty::write()
// Char/string-property
{
PropertyObject o;
- QQmlProperty charProperty(&o, "charProperty");
QQmlProperty qcharProperty(&o, "qcharProperty");
QQmlProperty stringProperty(&o, "stringProperty");
const int black_circle = 0x25cf;
- QCOMPARE(charProperty.write(QString("foo")), false);
- QCOMPARE(charProperty.write('Q'), true);
- QCOMPARE(charProperty.read(), QVariant('Q'));
- QCOMPARE(charProperty.write(QString("t")), true);
- QCOMPARE(charProperty.read(), QVariant('t'));
-
QCOMPARE(qcharProperty.write(QString("foo")), false);
QCOMPARE(qcharProperty.write('Q'), true);
QCOMPARE(qcharProperty.read(), QVariant('Q'));
- QCOMPARE(qcharProperty.write(QString("t")), true);
- QCOMPARE(qcharProperty.read(), QVariant('t'));
QCOMPARE(qcharProperty.write(QChar(black_circle)), true);
QCOMPARE(qcharProperty.read(), QVariant(QChar(black_circle)));
@@ -1443,19 +1426,10 @@ void tst_qqmlproperty::write()
QCOMPARE(o.stringProperty(), QString("bar"));
QCOMPARE(stringProperty.write(QVariant(1234)), true);
QCOMPARE(stringProperty.read().toString(), QString::number(1234));
+ QCOMPARE(stringProperty.write('A'), true);
+ QCOMPARE(stringProperty.read().toString(), QString::number('A'));
QCOMPARE(stringProperty.write(QChar(black_circle)), true);
- QCOMPARE(stringProperty.read(), QVariant(QString(QChar(black_circle))));
-
- { // char -> QString
- QQmlComponent component(&engine);
- component.setData("import Test 1.0\nPropertyObject { stringProperty: constChar }", QUrl());
- PropertyObject *obj = qobject_cast<PropertyObject*>(component.create());
- QVERIFY(obj != 0);
- if (obj) {
- QQmlProperty stringProperty(obj, "stringProperty");
- QCOMPARE(stringProperty.read(), QVariant(QString(obj->constChar())));
- }
- }
+ QCOMPARE(stringProperty.read(), QVariant(QChar(black_circle)));
{ // QChar -> QString
QQmlComponent component(&engine);
@@ -1468,16 +1442,6 @@ void tst_qqmlproperty::write()
}
}
- { // int -> QString
- QQmlComponent component(&engine);
- component.setData("import Test 1.0\nPropertyObject { stringProperty: constInt }", QUrl());
- PropertyObject *obj = qobject_cast<PropertyObject*>(component.create());
- QVERIFY(obj != 0);
- if (obj) {
- QQmlProperty stringProperty(obj, "stringProperty");
- QCOMPARE(stringProperty.read(), QVariant(QString::number(obj->constInt())));
- }
- }
}
// VariantMap-property
diff --git a/tests/auto/qmldevtools/compile/compile.pro b/tests/auto/qmldevtools/compile/compile.pro
index 54430eb668..832700698f 100644
--- a/tests/auto/qmldevtools/compile/compile.pro
+++ b/tests/auto/qmldevtools/compile/compile.pro
@@ -5,7 +5,7 @@ force_bootstrap {
!build_pass: CONFIG += release
} else {
QT = core
- !build_pass:contains(QT_CONFIG, debug_and_release): CONFIG += release
+ !build_pass:qtConfig(debug_and_release): CONFIG += release
}
QT += qmldevtools-private
macx:CONFIG -= app_bundle
diff --git a/tests/auto/qmldevtools/qmldevtools.pro b/tests/auto/qmldevtools/qmldevtools.pro
index a0ca1bff87..a9352d4df3 100644
--- a/tests/auto/qmldevtools/qmldevtools.pro
+++ b/tests/auto/qmldevtools/qmldevtools.pro
@@ -1,6 +1,4 @@
TEMPLATE = subdirs
-contains(QT_CONFIG, private_tests) {
- SUBDIRS += \
- compile
-}
+qtConfig(private_tests): \
+ SUBDIRS += compile
diff --git a/tests/auto/qmltest/listview/tst_listview.qml b/tests/auto/qmltest/listview/tst_listview.qml
index 98d7ea4cb7..65f736f305 100644
--- a/tests/auto/qmltest/listview/tst_listview.qml
+++ b/tests/auto/qmltest/listview/tst_listview.qml
@@ -320,9 +320,13 @@ Item {
function test_listInteractiveCurrentIndexEnforce() {
mousePress(listInteractiveCurrentIndexEnforce, 10, 50);
+ wait(1); // because Flickable pays attention to velocity, we need some time between movements
mouseMove(listInteractiveCurrentIndexEnforce, 10, 40);
+ wait(1);
mouseMove(listInteractiveCurrentIndexEnforce, 10, 30);
+ wait(1);
mouseMove(listInteractiveCurrentIndexEnforce, 10, 20);
+ wait(1);
mouseMove(listInteractiveCurrentIndexEnforce, 10, 10);
compare(listInteractiveCurrentIndexEnforce.interactive, false);
mouseRelease(listInteractiveCurrentIndexEnforce, 10, 10);
diff --git a/tests/auto/quick/qquickflickable/data/contentXY.qml b/tests/auto/quick/qquickflickable/data/contentXY.qml
new file mode 100644
index 0000000000..8215976949
--- /dev/null
+++ b/tests/auto/quick/qquickflickable/data/contentXY.qml
@@ -0,0 +1,6 @@
+import QtQuick 2.0
+
+Flickable {
+ width: 400; height: 400
+ contentWidth: 1e11; contentHeight: 1e11
+}
diff --git a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
index e1678b9acd..a03e3b8170 100644
--- a/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
+++ b/tests/auto/quick/qquickflickable/tst_qquickflickable.cpp
@@ -91,6 +91,7 @@ private slots:
void cleanup();
void contentSize();
void ratios_smallContent();
+ void contentXYNotTruncatedToInt();
private:
void flickWithTouch(QQuickWindow *window, QTouchDevice *touchDevice, const QPoint &from, const QPoint &to);
@@ -1841,6 +1842,26 @@ void tst_qquickflickable::ratios_smallContent()
QCOMPARE(obj->property("widthRatioIs").toDouble(), 1.);
}
+// QTBUG-48018
+void tst_qquickflickable::contentXYNotTruncatedToInt()
+{
+ QScopedPointer<QQuickView> window(new QQuickView);
+ window->setSource(testFileUrl("contentXY.qml"));
+ QTRY_COMPARE(window->status(), QQuickView::Ready);
+ QQuickViewTestUtil::centerOnScreen(window.data());
+ QQuickViewTestUtil::moveMouseAway(window.data());
+ window->show();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+
+ QQuickFlickable *flickable = qobject_cast<QQuickFlickable*>(window->rootObject());
+ QVERIFY(flickable);
+
+ flickable->setContentX(1e10);
+ flick(window.data(), QPoint(200, 100), QPoint(100, 100), 50);
+
+ // make sure we are not clipped at 2^31
+ QVERIFY(flickable->contentX() > qreal(1e10));
+}
QTEST_MAIN(tst_qquickflickable)
diff --git a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
index adf0d282c5..7baff93574 100644
--- a/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
+++ b/tests/auto/quick/qquickmousearea/tst_qquickmousearea.cpp
@@ -1079,17 +1079,17 @@ void tst_QQuickMouseArea::clickThrough()
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
+ // to avoid generating a double click.
+ const int doubleClickInterval = qApp->styleHints()->mouseDoubleClickInterval() + 10;
+
QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTRY_COMPARE(window->rootObject()->property("presses").toInt(), 0);
QTRY_COMPARE(window->rootObject()->property("clicks").toInt(), 1);
- // to avoid generating a double click.
- int doubleClickInterval = qApp->styleHints()->mouseDoubleClickInterval() + 10;
- QTest::qWait(doubleClickInterval);
-
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QCOMPARE(window->rootObject()->property("doubleClicks").toInt(), 0);
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100), doubleClickInterval);
QTest::qWait(1000);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
@@ -1119,9 +1119,7 @@ void tst_QQuickMouseArea::clickThrough()
QCOMPARE(window->rootObject()->property("presses").toInt(), 0);
QCOMPARE(window->rootObject()->property("clicks").toInt(), 0);
- QTest::qWait(doubleClickInterval); // to avoid generating a double click.
-
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100), doubleClickInterval);
QTest::qWait(1000);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(100);
@@ -1140,15 +1138,13 @@ void tst_QQuickMouseArea::clickThrough()
window->rootObject()->setProperty("letThrough", QVariant(true));
- QTest::qWait(doubleClickInterval); // to avoid generating a double click.
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100), doubleClickInterval);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QCOMPARE(window->rootObject()->property("presses").toInt(), 0);
QTRY_COMPARE(window->rootObject()->property("clicks").toInt(), 1);
- QTest::qWait(doubleClickInterval); // to avoid generating a double click.
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100), doubleClickInterval);
QTest::qWait(1000);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(100);
@@ -1167,12 +1163,10 @@ void tst_QQuickMouseArea::clickThrough()
window->rootObject()->setProperty("noPropagation", QVariant(true));
- QTest::qWait(doubleClickInterval); // to avoid generating a double click.
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100), doubleClickInterval);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
- QTest::qWait(doubleClickInterval); // to avoid generating a double click.
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100), doubleClickInterval);
QTest::qWait(1000);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QTest::qWait(100);
@@ -1193,7 +1187,7 @@ void tst_QQuickMouseArea::clickThrough()
QVERIFY(QTest::qWaitForWindowExposed(window.data()));
QVERIFY(window->rootObject() != 0);
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100), doubleClickInterval);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QCOMPARE(window->rootObject()->property("clicksEnabled").toInt(), 1);
@@ -1201,8 +1195,7 @@ void tst_QQuickMouseArea::clickThrough()
window->rootObject()->setProperty("disableLower", QVariant(true));
- QTest::qWait(doubleClickInterval); // to avoid generating a double click.
- QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100));
+ QTest::mousePress(window.data(), Qt::LeftButton, 0, QPoint(100,100), doubleClickInterval);
QTest::mouseRelease(window.data(), Qt::LeftButton, 0, QPoint(100,100));
QCOMPARE(window->rootObject()->property("clicksEnabled").toInt(), 2);
diff --git a/tests/auto/quick/qquickpathview/data/qtbug37815.qml b/tests/auto/quick/qquickpathview/data/qtbug37815.qml
new file mode 100644
index 0000000000..3fd4daca63
--- /dev/null
+++ b/tests/auto/quick/qquickpathview/data/qtbug37815.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Netris
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 600
+ height: 400
+ PathView {
+ objectName: "pathView"
+ model: 10
+ anchors.fill: parent
+ pathItemCount: 5
+ cacheItemCount: 5
+ highlightRangeMode: PathView.StrictlyEnforceRange
+ preferredHighlightBegin: 0.5
+ preferredHighlightEnd: 0.5
+
+ path: Path {
+ startX: 0
+ startY: 50
+ PathLine {
+ x: 600
+ y: 50
+ }
+ }
+
+ delegate: Component {
+ Text {
+ width: 50
+ height: 50
+ text: index
+ objectName: "delegate" + index
+ font.pixelSize: 24
+ color: PathView.isCurrentItem ? "green" : "black"
+ }
+ }
+ }
+}
+
diff --git a/tests/auto/quick/qquickpathview/data/qtbug53464.qml b/tests/auto/quick/qquickpathview/data/qtbug53464.qml
new file mode 100644
index 0000000000..d30d404e68
--- /dev/null
+++ b/tests/auto/quick/qquickpathview/data/qtbug53464.qml
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 Netris
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.0
+
+Rectangle {
+ width: 600
+ height: 400
+ PathView {
+ objectName: "pathView"
+ model: 10
+ anchors.fill: parent
+ pathItemCount: 5
+ highlightRangeMode: PathView.StrictlyEnforceRange
+ preferredHighlightBegin: 0.5
+ preferredHighlightEnd: 0.5
+ currentIndex: 8
+
+ path: Path {
+ startX: 0
+ startY: 50
+ PathLine {
+ x: 600
+ y: 50
+ }
+ }
+
+ delegate: Component {
+ Text {
+ width: 50
+ height: 50
+ text: index
+ objectName: "delegate" + index
+ font.pixelSize: 24
+ color: PathView.isCurrentItem ? "green" : "black"
+ }
+ }
+ }
+}
+
diff --git a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
index 6761313210..d013d190ec 100644
--- a/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
+++ b/tests/auto/quick/qquickpathview/tst_qquickpathview.cpp
@@ -135,7 +135,9 @@ private slots:
void nestedinFlickable();
void flickableDelegate();
void jsArrayChange();
+ void qtbug37815();
void qtbug42716();
+ void qtbug53464();
void addCustomAttribute();
void movementDirection_data();
void movementDirection();
@@ -2330,6 +2332,31 @@ void tst_QQuickPathView::jsArrayChange()
QCOMPARE(spy.count(), 1);
}
+void tst_QQuickPathView::qtbug37815()
+{
+ QScopedPointer<QQuickView> window(createView());
+
+ window->setSource(testFileUrl("qtbug37815.qml"));
+ window->show();
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+
+ // cache items will be created async. Let's wait...
+ QTest::qWait(1000);
+
+ QQuickPathView *pathView = findItem<QQuickPathView>(window->rootObject(), "pathView");
+ QVERIFY(pathView != Q_NULLPTR);
+
+ const int pathItemCount = pathView->pathItemCount();
+ const int cacheItemCount = pathView->cacheItemCount();
+ int totalCount = 0;
+ foreach (QQuickItem *item, pathView->childItems()) {
+ if (item->objectName().startsWith(QLatin1String("delegate")))
+ ++totalCount;
+ }
+ QCOMPARE(pathItemCount + cacheItemCount, totalCount);
+}
+
/* This bug was one where if you jump the list such that the sole missing item needed to be
* added in the middle of the list, it would instead move an item somewhere else in the list
* to the middle (messing it up very badly).
@@ -2378,6 +2405,29 @@ void tst_QQuickPathView::qtbug42716()
QVERIFY(!itemMiss);
}
+void tst_QQuickPathView::qtbug53464()
+{
+ QScopedPointer<QQuickView> window(createView());
+
+ window->setSource(testFileUrl("qtbug53464.qml"));
+ window->show();
+ window->requestActivate();
+ QVERIFY(QTest::qWaitForWindowActive(window.data()));
+
+ QQuickPathView *pathView = findItem<QQuickPathView>(window->rootObject(), "pathView");
+ QVERIFY(pathView != Q_NULLPTR);
+ const int currentIndex = pathView->currentIndex();
+ QCOMPARE(currentIndex, 8);
+
+ const int pathItemCount = pathView->pathItemCount();
+ int totalCount = 0;
+ foreach (QQuickItem *item, pathView->childItems()) {
+ if (item->objectName().startsWith(QLatin1String("delegate")))
+ ++totalCount;
+ }
+ QCOMPARE(pathItemCount, totalCount);
+}
+
void tst_QQuickPathView::addCustomAttribute()
{
const QScopedPointer<QQuickView> window(createView());
diff --git a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
index 942eb67563..8dc3053d89 100644
--- a/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
+++ b/tests/auto/quick/qquicktextinput/tst_qquicktextinput.cpp
@@ -201,6 +201,8 @@ private slots:
void implicitSize();
void implicitSizeBinding_data();
void implicitSizeBinding();
+ void implicitResize_data();
+ void implicitResize();
void negativeDimensions();
@@ -6010,6 +6012,39 @@ void tst_qquicktextinput::implicitSizeBinding()
QCOMPARE(textObject->height(), textObject->implicitHeight());
}
+void tst_qquicktextinput::implicitResize_data()
+{
+ QTest::addColumn<int>("alignment");
+ QTest::newRow("left") << int(Qt::AlignLeft);
+ QTest::newRow("center") << int(Qt::AlignHCenter);
+ QTest::newRow("right") << int(Qt::AlignRight);
+}
+
+void tst_qquicktextinput::implicitResize()
+{
+ QFETCH(int, alignment);
+
+ QQmlComponent component(&engine);
+ component.setData("import QtQuick 2.0\nTextInput { }", QUrl::fromLocalFile(""));
+
+ QScopedPointer<QQuickTextInput> textInput(qobject_cast<QQuickTextInput *>(component.create()));
+ QVERIFY(!textInput.isNull());
+
+ QScopedPointer<QQuickTextInput> textField(qobject_cast<QQuickTextInput *>(component.create()));
+ QVERIFY(!textField.isNull());
+ QQuickTextInputPrivate::get(textField.data())->setImplicitResizeEnabled(false);
+
+ textInput->setWidth(200);
+ textField->setImplicitWidth(200);
+
+ textInput->setHAlign(QQuickTextInput::HAlignment(alignment));
+ textField->setHAlign(QQuickTextInput::HAlignment(alignment));
+
+ textInput->setText("Qt");
+ textField->setText("Qt");
+
+ QCOMPARE(textField->positionToRectangle(0), textInput->positionToRectangle(0));
+}
void tst_qquicktextinput::negativeDimensions()
{
diff --git a/tests/auto/quick/quick.pro b/tests/auto/quick/quick.pro
index 8bf805e18d..2428084c40 100644
--- a/tests/auto/quick/quick.pro
+++ b/tests/auto/quick/quick.pro
@@ -4,7 +4,7 @@ PUBLICTESTS += \
geometry \
qquickpixmapcache
-contains(QT_CONFIG, opengl(es1|es2)?) {
+qtConfig(opengl(es1|es2)?) {
PUBLICTESTS += \
rendernode
qtHaveModule(widgets): PUBLICTESTS += nodes
@@ -89,9 +89,9 @@ QUICKTESTS = \
SUBDIRS += $$PUBLICTESTS
-!contains(QT_CONFIG, accessibility):QUICKTESTS -= qquickaccessible
+!qtConfig(accessibility):QUICKTESTS -= qquickaccessible
-contains(QT_CONFIG, private_tests) {
+qtConfig(private_tests) {
SUBDIRS += $$PRIVATETESTS
SUBDIRS += $$QUICKTESTS
}
diff --git a/tests/auto/shared/util.cpp b/tests/auto/shared/util.cpp
index 55041eeb4d..96beb51612 100644
--- a/tests/auto/shared/util.cpp
+++ b/tests/auto/shared/util.cpp
@@ -101,11 +101,15 @@ Q_GLOBAL_STATIC(QMutex, qQmlTestMessageHandlerMutex)
QQmlTestMessageHandler *QQmlTestMessageHandler::m_instance = 0;
-void QQmlTestMessageHandler::messageHandler(QtMsgType, const QMessageLogContext &, const QString &message)
+void QQmlTestMessageHandler::messageHandler(QtMsgType, const QMessageLogContext &context, const QString &message)
{
QMutexLocker locker(qQmlTestMessageHandlerMutex());
- if (QQmlTestMessageHandler::m_instance)
- QQmlTestMessageHandler::m_instance->m_messages.push_back(message);
+ if (QQmlTestMessageHandler::m_instance) {
+ if (QQmlTestMessageHandler::m_instance->m_includeCategories)
+ QQmlTestMessageHandler::m_instance->m_messages.push_back(QString("%1: %2").arg(context.category, message));
+ else
+ QQmlTestMessageHandler::m_instance->m_messages.push_back(message);
+ }
}
QQmlTestMessageHandler::QQmlTestMessageHandler()
@@ -114,6 +118,7 @@ QQmlTestMessageHandler::QQmlTestMessageHandler()
Q_ASSERT(!QQmlTestMessageHandler::m_instance);
QQmlTestMessageHandler::m_instance = this;
m_oldHandler = qInstallMessageHandler(messageHandler);
+ m_includeCategories = false;
}
QQmlTestMessageHandler::~QQmlTestMessageHandler()
diff --git a/tests/auto/shared/util.h b/tests/auto/shared/util.h
index 47a4aae231..33d7cbd1d0 100644
--- a/tests/auto/shared/util.h
+++ b/tests/auto/shared/util.h
@@ -87,12 +87,15 @@ public:
void clear() { m_messages.clear(); }
+ void setIncludeCategoriesEnabled(bool enabled) { m_includeCategories = enabled; }
+
private:
- static void messageHandler(QtMsgType, const QMessageLogContext &, const QString &message);
+ static void messageHandler(QtMsgType, const QMessageLogContext &context, const QString &message);
static QQmlTestMessageHandler *m_instance;
QStringList m_messages;
QtMessageHandler m_oldHandler;
+ bool m_includeCategories;
};
#endif // QQMLTESTUTILS_H
diff --git a/tests/benchmarks/benchmarks.pro b/tests/benchmarks/benchmarks.pro
index bd071ecf5c..5e6bc65815 100644
--- a/tests/benchmarks/benchmarks.pro
+++ b/tests/benchmarks/benchmarks.pro
@@ -1,5 +1,5 @@
TEMPLATE = subdirs
SUBDIRS = qml script
-contains(QT_CONFIG, private_tests) {
- contains(QT_CONFIG, opengl(es1|es2)?):SUBDIRS += particles
+qtConfig(private_tests) {
+ qtConfig(opengl(es1|es2)?):SUBDIRS += particles
}
diff --git a/tests/benchmarks/particles/affectors/tst_affectors.cpp b/tests/benchmarks/particles/affectors/tst_affectors.cpp
index 475b8d28ec..99d175564b 100644
--- a/tests/benchmarks/particles/affectors/tst_affectors.cpp
+++ b/tests/benchmarks/particles/affectors/tst_affectors.cpp
@@ -86,7 +86,7 @@ void tst_affectors::test_basic()
int stillAlive = 0;
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 1000, 10));//Small simulation variance is permissible.
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
@@ -126,7 +126,7 @@ void tst_affectors::test_filtered()
int stillAlive = 0;
QVERIFY(extremelyFuzzyCompare(system->groupData[1]->size(), 1000, 10));//Small simulation variance is permissible.
- foreach (QQuickParticleData *d, system->groupData[1]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[1]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/benchmarks/particles/emission/tst_emission.cpp b/tests/benchmarks/particles/emission/tst_emission.cpp
index b107120a28..fe08305f68 100644
--- a/tests/benchmarks/particles/emission/tst_emission.cpp
+++ b/tests/benchmarks/particles/emission/tst_emission.cpp
@@ -79,7 +79,7 @@ void tst_emission::test_basic()
int stillAlive = 0;
QVERIFY(extremelyFuzzyCompare(system->groupData[0]->size(), 1000, 10));//Small simulation variance is permissible.
- foreach (QQuickParticleData *d, system->groupData[0]->data) {
+ for (QQuickParticleData *d : qAsConst(system->groupData[0]->data)) {
if (d->t == -1)
continue; //Particle data unused
diff --git a/tests/benchmarks/qml/animation/tst_animation.cpp b/tests/benchmarks/qml/animation/tst_animation.cpp
index 4f693f9fa8..59f5a57f5c 100644
--- a/tests/benchmarks/qml/animation/tst_animation.cpp
+++ b/tests/benchmarks/qml/animation/tst_animation.cpp
@@ -107,8 +107,8 @@ void tst_animation::animationelements_data()
{
QTest::addColumn<QString>("type");
- QSet<QString> types = QQmlMetaType::qmlTypeNames().toSet();
- foreach (const QString &type, types) {
+ const QSet<QString> types = QQmlMetaType::qmlTypeNames().toSet();
+ for (const QString &type : types) {
if (type.contains(QLatin1String("Animation")))
QTest::newRow(type.toLatin1()) << type;
}
diff --git a/tests/benchmarks/qml/creation/creation.pro b/tests/benchmarks/qml/creation/creation.pro
index bb4d2841fe..42faf729a0 100644
--- a/tests/benchmarks/qml/creation/creation.pro
+++ b/tests/benchmarks/qml/creation/creation.pro
@@ -1,7 +1,7 @@
CONFIG += benchmark
TEMPLATE = app
TARGET = tst_creation
-QT += core-private gui-private qml-private quick-private widgets testlib
+QT += core-private gui-private qml-private quick-private testlib
macx:CONFIG -= app_bundle
SOURCES += tst_creation.cpp
diff --git a/tests/benchmarks/qml/creation/tst_creation.cpp b/tests/benchmarks/qml/creation/tst_creation.cpp
index ca5802a8e7..a1c09db158 100644
--- a/tests/benchmarks/qml/creation/tst_creation.cpp
+++ b/tests/benchmarks/qml/creation/tst_creation.cpp
@@ -31,8 +31,6 @@
#include <QQmlComponent>
#include <private/qqmlmetatype_p.h>
#include <QDebug>
-#include <QGraphicsScene>
-#include <QGraphicsItem>
#include <QQuickItem>
#include <QQmlContext>
#include <private/qobject_p.h>
@@ -47,7 +45,6 @@ private slots:
void qobject_cpp();
void qobject_qml();
void qobject_qmltype();
- void qobject_alloc();
void qobject_10flat_qml();
void qobject_10flat_cpp();
@@ -62,9 +59,6 @@ private slots:
void itemtree_qml();
void itemtree_scene_cpp();
- void elements_data();
- void elements();
-
void itemtests_qml_data();
void itemtests_qml();
@@ -210,35 +204,6 @@ void tst_creation::qobject_qmltype()
}
}
-struct QObjectFakeData {
- char data[sizeof(QObjectPrivate)];
-};
-
-struct QObjectFake {
- QObjectFake();
- virtual ~QObjectFake();
-private:
- QObjectFakeData *d;
-};
-
-QObjectFake::QObjectFake()
-{
- d = new QObjectFakeData;
-}
-
-QObjectFake::~QObjectFake()
-{
- delete d;
-}
-
-void tst_creation::qobject_alloc()
-{
- QBENCHMARK {
- QObjectFake *obj = new QObjectFake;
- delete obj;
- }
-}
-
struct QQmlGraphics_Derived : public QObject
{
void setParent_noEvent(QObject *parent) {
@@ -333,28 +298,6 @@ void tst_creation::itemtree_scene_cpp()
delete root;
}
-void tst_creation::elements_data()
-{
- QTest::addColumn<QString>("type");
-
- QList<QString> types = QQmlMetaType::qmlTypeNames();
- foreach (QString type, types)
- QTest::newRow(type.toLatin1()) << type;
-}
-
-void tst_creation::elements()
-{
- QFETCH(QString, type);
- QQmlType *t = QQmlMetaType::qmlType(type, 2, 0);
- if (!t || !t->isCreatable())
- QSKIP("Non-creatable type");
-
- QBENCHMARK {
- QObject *obj = t->create();
- delete obj;
- }
-}
-
void tst_creation::itemtests_qml_data()
{
QTest::addColumn<QString>("filepath");
diff --git a/tests/benchmarks/qml/librarymetrics_performance/tst_librarymetrics_performance.cpp b/tests/benchmarks/qml/librarymetrics_performance/tst_librarymetrics_performance.cpp
index 5513dcb9a7..d7c54703ad 100644
--- a/tests/benchmarks/qml/librarymetrics_performance/tst_librarymetrics_performance.cpp
+++ b/tests/benchmarks/qml/librarymetrics_performance/tst_librarymetrics_performance.cpp
@@ -36,9 +36,6 @@
// for the standard set of elements, properties and expressions which
// are provided in the QtDeclarative library (QtQml and QtQuick).
-#define AVERAGE_OVER_N 10
-#define IGNORE_N_OUTLIERS 2
-
class ModuleApi : public QObject
{
Q_OBJECT
@@ -214,123 +211,37 @@ void tst_librarymetrics_performance::compilation()
}
}
- QList<qint64> nResults;
-
- // generate AVERAGE_OVER_N results
- for (int i = 0; i < AVERAGE_OVER_N; ++i) {
+ QBENCHMARK {
cleanState(&e);
- {
- QElapsedTimer et;
- et.start();
- QQmlComponent c(e, this);
- c.loadUrl(qmlfile); // just compile.
- qint64 etime = et.nsecsElapsed();
- nResults.append(etime);
- }
- }
-
- // sort the list
- qSort(nResults);
-
- // remove IGNORE_N_OUTLIERS*2 from ONLY the worst end (remove gc interference)
- for (int i = 0; i < IGNORE_N_OUTLIERS; ++i) {
- if (!nResults.isEmpty()) nResults.removeLast();
- if (!nResults.isEmpty()) nResults.removeLast();
+ QQmlComponent c(e, this);
+ c.loadUrl(qmlfile); // just compile.
}
-
- // now generate an average
- qint64 totaltime = 0;
- if (nResults.size() == 0) nResults.append(9999);
- for (int i = 0; i < nResults.size(); ++i)
- totaltime += nResults.at(i);
- double average = ((double)totaltime) / nResults.count();
-
- // and return it as the result
- QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds);
- QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds); // twice to workaround bug in QTestLib
}
void tst_librarymetrics_performance::instantiation_cached()
{
QFETCH(QUrl, qmlfile);
-
cleanState(&e);
- QList<qint64> nResults;
- // generate AVERAGE_OVER_N results
- for (int i = 0; i < AVERAGE_OVER_N; ++i) {
- QElapsedTimer et;
- et.start();
+ QBENCHMARK {
QQmlComponent c(e, this);
c.loadUrl(qmlfile); // just compile.
QObject *o = c.create();
- qint64 etime = et.nsecsElapsed();
- nResults.append(etime);
delete o;
}
-
- // sort the list
- qSort(nResults);
-
- // remove IGNORE_N_OUTLIERS*2 from ONLY the worst end (remove gc interference)
- for (int i = 0; i < IGNORE_N_OUTLIERS; ++i) {
- if (!nResults.isEmpty()) nResults.removeLast();
- if (!nResults.isEmpty()) nResults.removeLast();
- }
-
- // now generate an average
- qint64 totaltime = 0;
- if (nResults.size() == 0) nResults.append(9999);
- for (int i = 0; i < nResults.size(); ++i)
- totaltime += nResults.at(i);
- double average = ((double)totaltime) / nResults.count();
-
- // and return it as the result
- QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds);
- QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds); // twice to workaround bug in QTestLib
}
void tst_librarymetrics_performance::instantiation()
{
QFETCH(QUrl, qmlfile);
- cleanState(&e);
- QList<qint64> nResults;
-
- // generate AVERAGE_OVER_N results
- for (int i = 0; i < AVERAGE_OVER_N; ++i) {
+ QBENCHMARK {
cleanState(&e);
- {
- QElapsedTimer et;
- et.start();
- QQmlComponent c(e, this);
- c.loadUrl(qmlfile); // just compile.
- QObject *o = c.create();
- qint64 etime = et.nsecsElapsed();
- nResults.append(etime);
- delete o;
- }
- }
-
- // sort the list
- qSort(nResults);
-
- // remove IGNORE_N_OUTLIERS*2 from ONLY the worst end (remove gc interference)
- for (int i = 0; i < IGNORE_N_OUTLIERS; ++i) {
- if (!nResults.isEmpty()) nResults.removeLast();
- if (!nResults.isEmpty()) nResults.removeLast();
+ QQmlComponent c(e, this);
+ c.loadUrl(qmlfile); // just compile.
+ QObject *o = c.create();
+ delete o;
}
-
- // now generate an average
- qint64 totaltime = 0;
- if (nResults.size() == 0) nResults.append(9999);
- for (int i = 0; i < nResults.size(); ++i)
- totaltime += nResults.at(i);
- double average = ((double)totaltime) / nResults.count();
-
- // and return it as the result
- QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds);
- QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds); // twice to workaround bug in QTestLib
}
void tst_librarymetrics_performance::positioners_data()
@@ -351,43 +262,13 @@ void tst_librarymetrics_performance::positioners()
{
QFETCH(QUrl, qmlfile);
- cleanState(&e);
- QList<qint64> nResults;
-
- // generate AVERAGE_OVER_N results
- for (int i = 0; i < AVERAGE_OVER_N; ++i) {
+ QBENCHMARK {
cleanState(&e);
- {
- QElapsedTimer et;
- et.start();
- QQmlComponent c(e, this);
- c.loadUrl(qmlfile); // just compile.
- QObject *o = c.create();
- qint64 etime = et.nsecsElapsed();
- nResults.append(etime);
- delete o;
- }
- }
-
- // sort the list
- qSort(nResults);
-
- // remove IGNORE_N_OUTLIERS*2 from ONLY the worst end (remove gc interference)
- for (int i = 0; i < IGNORE_N_OUTLIERS; ++i) {
- if (!nResults.isEmpty()) nResults.removeLast();
- if (!nResults.isEmpty()) nResults.removeLast();
+ QQmlComponent c(e, this);
+ c.loadUrl(qmlfile); // just compile.
+ QObject *o = c.create();
+ delete o;
}
-
- // now generate an average
- qint64 totaltime = 0;
- if (nResults.size() == 0) nResults.append(9999);
- for (int i = 0; i < nResults.size(); ++i)
- totaltime += nResults.at(i);
- double average = ((double)totaltime) / nResults.count();
-
- // and return it as the result
- QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds);
- QTest::setBenchmarkResult(average, QTest::WalltimeNanoseconds); // twice to workaround bug in QTestLib
}
QTEST_MAIN(tst_librarymetrics_performance)
diff --git a/tests/benchmarks/qml/qml.pro b/tests/benchmarks/qml/qml.pro
index 5d48ec0067..2cf2dff413 100644
--- a/tests/benchmarks/qml/qml.pro
+++ b/tests/benchmarks/qml/qml.pro
@@ -7,13 +7,12 @@ SUBDIRS += \
holistic \
qqmlchangeset \
qqmlcomponent \
- qqmlimage \
qqmlmetaproperty \
librarymetrics_performance \
# script \ ### FIXME: doesn't build
- js
+ js \
+ creation
qtHaveModule(opengl): SUBDIRS += painting qquickwindow
-qtHaveModule(widgets): SUBDIRS += creation
include(../trusted-benchmarks.pri)
diff --git a/tests/benchmarks/qml/qqmlimage/image.png b/tests/benchmarks/qml/qqmlimage/image.png
deleted file mode 100644
index 623d36233d..0000000000
--- a/tests/benchmarks/qml/qqmlimage/image.png
+++ /dev/null
Binary files differ
diff --git a/tests/benchmarks/qml/qqmlimage/qqmlimage.pro b/tests/benchmarks/qml/qqmlimage/qqmlimage.pro
deleted file mode 100644
index 421f232a4f..0000000000
--- a/tests/benchmarks/qml/qqmlimage/qqmlimage.pro
+++ /dev/null
@@ -1,11 +0,0 @@
-CONFIG += benchmark
-TEMPLATE = app
-TARGET = tst_qqmlimage
-QT += qml quick-private testlib
-macx:CONFIG -= app_bundle
-CONFIG += release
-
-SOURCES += tst_qqmlimage.cpp
-
-DEFINES += SRCDIR=\\\"$$PWD\\\"
-
diff --git a/tests/benchmarks/qml/qqmlimage/tst_qqmlimage.cpp b/tests/benchmarks/qml/qqmlimage/tst_qqmlimage.cpp
deleted file mode 100644
index 38fca802c5..0000000000
--- a/tests/benchmarks/qml/qqmlimage/tst_qqmlimage.cpp
+++ /dev/null
@@ -1,95 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** Contact: https://www.qt.io/licensing/
-**
-** This file is part of the test suite of the Qt Toolkit.
-**
-** $QT_BEGIN_LICENSE:GPL-EXCEPT$
-** Commercial License Usage
-** Licensees holding valid commercial Qt licenses may use this file in
-** accordance with the commercial license agreement provided with the
-** Software or, alternatively, in accordance with the terms contained in
-** a written agreement between you and The Qt Company. For licensing terms
-** and conditions see https://www.qt.io/terms-conditions. For further
-** information use the contact form at https://www.qt.io/contact-us.
-**
-** GNU General Public License Usage
-** Alternatively, this file may be used under the terms of the GNU
-** General Public License version 3 as published by the Free Software
-** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
-** included in the packaging of this file. Please review the following
-** information to ensure the GNU General Public License requirements will
-** be met: https://www.gnu.org/licenses/gpl-3.0.html.
-**
-** $QT_END_LICENSE$
-**
-****************************************************************************/
-
-#include <qtest.h>
-#include <QQmlEngine>
-#include <QQmlComponent>
-#include <private/qquickimage_p.h>
-
-class tst_qmlgraphicsimage : public QObject
-{
- Q_OBJECT
-public:
- tst_qmlgraphicsimage() {}
-
-private slots:
- void qmlgraphicsimage();
- void qmlgraphicsimage_file();
- void qmlgraphicsimage_url();
-
-private:
- QQmlEngine engine;
-};
-
-void tst_qmlgraphicsimage::qmlgraphicsimage()
-{
- int x = 0;
- QUrl url(SRCDIR "/image.png");
- QBENCHMARK {
- QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
- QQuickImage *image = new QQuickImage;
- QQmlEngine::setContextForObject(image, engine.rootContext());
- delete image;
- }
-}
-
-void tst_qmlgraphicsimage::qmlgraphicsimage_file()
-{
- int x = 0;
- QUrl url(SRCDIR "/image.png");
- //get rid of initialization effects
- {
- QQuickImage *image = new QQuickImage;
- QQmlEngine::setContextForObject(image, engine.rootContext());
- image->setSource(url);
- }
- QBENCHMARK {
- QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
- QQuickImage *image = new QQuickImage;
- QQmlEngine::setContextForObject(image, engine.rootContext());
- image->setSource(url);
- delete image;
- }
-}
-
-void tst_qmlgraphicsimage::qmlgraphicsimage_url()
-{
- int x = 0;
- QUrl url(SRCDIR "/image.png");
- QBENCHMARK {
- QUrl url2("http://localhost/image" + QString::number(x++) + ".png");
- QQuickImage *image = new QQuickImage;
- QQmlEngine::setContextForObject(image, engine.rootContext());
- image->setSource(url2);
- delete image;
- }
-}
-
-QTEST_MAIN(tst_qmlgraphicsimage)
-
-#include "tst_qqmlimage.moc"
diff --git a/tests/manual/qmlplugindump/tst_qmlplugindump.cpp b/tests/manual/qmlplugindump/tst_qmlplugindump.cpp
index ed00682a83..1bedd4427b 100644
--- a/tests/manual/qmlplugindump/tst_qmlplugindump.cpp
+++ b/tests/manual/qmlplugindump/tst_qmlplugindump.cpp
@@ -92,7 +92,7 @@ public:
{
QRegularExpression re;
QRegularExpressionMatch m;
- Q_FOREACH (const QString &e, m_expected) {
+ for (const QString &e : m_expected) {
re.setPattern(e);
m = re.match(QString::fromLatin1(buffer));
if (!m.hasMatch()) {
@@ -187,7 +187,8 @@ Test createTest(const QString &id, const QJsonObject &def)
return Test(id);
}
QStringList patterns;
- Q_FOREACH (const QJsonValue &x, expected.toArray()) {
+ const auto expectedArray = expected.toArray();
+ for (const QJsonValue &x : expectedArray) {
if (!x.isString()) {
qWarning() << "Wrong definition for test: " << id << ".";
return Test(id);
@@ -331,7 +332,7 @@ void tst_qmlplugindump::plugin_data()
QTest::addColumn<QString>("version");
QTest::addColumn<QStringList>("expected");
- Q_FOREACH (const Test &t, tests) {
+ for (const Test &t : qAsConst(tests)) {
if (t.isNull())
QSKIP("Errors in test definition.");
QTest::newRow(t.id.toLatin1().data()) << t.project << t.version << t.expected;
@@ -357,9 +358,9 @@ void tst_qmlplugindump::plugin()
void tst_qmlplugindump::cleanupTestCase()
{
QSet<const QString> projects;
- Q_FOREACH (const Test &t, tests)
+ for (const Test &t : qAsConst(tests))
projects.insert(t.project);
- Q_FOREACH (const QString &p, projects) {
+ for (const QString &p : qAsConst(projects)) {
if (!cleanUpSample(p))
qWarning() << "Error in cleaning up project" << p << ".";
}
diff --git a/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp b/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp
index 5098d51134..886cfc6599 100644
--- a/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp
+++ b/tests/manual/scenegraph_lancelot/scenegrabber/main.cpp
@@ -183,8 +183,8 @@ int main(int argc, char *argv[])
v.setSource(QUrl::fromLocalFile(ifile));
if (noText) {
- QList<QQuickItem*> items = v.rootObject()->findChildren<QQuickItem*>();
- foreach (QQuickItem *item, items) {
+ const QList<QQuickItem*> items = v.rootObject()->findChildren<QQuickItem*>();
+ for (QQuickItem *item : items) {
if (QByteArray(item->metaObject()->className()).contains("Text"))
item->setVisible(false);
}
diff --git a/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp b/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp
index 426e06ccc2..3f28d90e7b 100644
--- a/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp
+++ b/tests/manual/scenegraph_lancelot/scenegraph/tst_scenegraph.cpp
@@ -156,7 +156,7 @@ void tst_Scenegraph::setupTestSuite(const QByteArray& filter)
}
std::sort(itemFiles.begin(), itemFiles.end());
- foreach (const QString &filePath, itemFiles) {
+ for (const QString &filePath : qAsConst(itemFiles)) {
QByteArray itemName = filePath.mid(testSuitePath.length() + 1).toLatin1();
QBaselineTest::newRow(itemName, checksumFileOrDir(filePath)) << filePath;
numItems++;
@@ -238,7 +238,9 @@ quint16 tst_Scenegraph::checksumFileOrDir(const QString &path)
if (fi.isDir()) {
static const QStringList nameFilters = QStringList() << "*.qml" << "*.cpp" << "*.png" << "*.jpg";
quint16 cs = 0;
- foreach (QString item, QDir(fi.filePath()).entryList(nameFilters, QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot))
+ const auto entryList = QDir(fi.filePath()).entryList(nameFilters,
+ QDir::Dirs | QDir::Files | QDir::NoDotAndDotDot);
+ for (const QString &item : entryList)
cs ^= checksumFileOrDir(path + QLatin1Char('/') + item);
return cs;
}
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp
index d718067616..be62500858 100644
--- a/tools/qml/main.cpp
+++ b/tools/qml/main.cpp
@@ -192,7 +192,7 @@ public Q_SLOTS:
checkForWindow(o);
haveOne = true;
if (conf && qae)
- foreach (PartialScene *ps, conf->completers)
+ for (PartialScene *ps : qAsConst(conf->completers))
if (o->inherits(ps->itemType().toUtf8().constData()))
contain(o, ps->container());
}
@@ -413,8 +413,8 @@ static void loadDummyDataFiles(QQmlEngine &engine, const QString& directory)
QObject *dummyData = comp.create();
if (comp.isError()) {
- QList<QQmlError> errors = comp.errors();
- foreach (const QQmlError &error, errors)
+ const QList<QQmlError> errors = comp.errors();
+ for (const QQmlError &error : errors)
qWarning() << error;
}
@@ -566,7 +566,7 @@ int main(int argc, char *argv[])
if (!dummyDir.isEmpty() && QFileInfo (dummyDir).isDir())
loadDummyDataFiles(e, dummyDir);
- foreach (const QString &path, files) {
+ for (const QString &path : qAsConst(files)) {
//QUrl::fromUserInput doesn't treat no scheme as relative file paths
#ifndef QT_NO_REGULAREXPRESSION
QRegularExpression urlRe("[[:word:]]+://.*");
diff --git a/tools/qmleasing/splineeditor.cpp b/tools/qmleasing/splineeditor.cpp
index ee55931a46..6fee013c62 100644
--- a/tools/qmleasing/splineeditor.cpp
+++ b/tools/qmleasing/splineeditor.cpp
@@ -288,7 +288,7 @@ QHash<QString, QEasingCurve> SplineEditor::presets() const
QString SplineEditor::generateCode()
{
QString s = QLatin1String("[");
- foreach (const QPointF &point, m_controlPoints) {
+ for (const QPointF &point : qAsConst(m_controlPoints)) {
s += QString::number(point.x(), 'g', 2) + QLatin1Char(',')
+ QString::number(point.y(), 'g', 3) + QLatin1Char(',');
}
diff --git a/tools/qmlimportscanner/main.cpp b/tools/qmlimportscanner/main.cpp
index 2371057878..f7f5a5e4e4 100644
--- a/tools/qmlimportscanner/main.cpp
+++ b/tools/qmlimportscanner/main.cpp
@@ -55,6 +55,14 @@ QT_USE_NAMESPACE
QStringList g_qmlImportPaths;
+static inline QString typeLiteral() { return QStringLiteral("type"); }
+static inline QString versionLiteral() { return QStringLiteral("version"); }
+static inline QString nameLiteral() { return QStringLiteral("name"); }
+static inline QString pluginsLiteral() { return QStringLiteral("plugins"); }
+static inline QString pathLiteral() { return QStringLiteral("path"); }
+static inline QString classnamesLiteral() { return QStringLiteral("classnames"); }
+static inline QString dependenciesLiteral() { return QStringLiteral("dependencies"); }
+
static void printUsage(const QString &appNameIn)
{
const std::wstring appName = appNameIn.toStdWString();
@@ -84,14 +92,14 @@ QVariantList findImportsInAst(QQmlJS::AST::UiHeaderItemList *headerItemList, con
// handle directory imports
if (!importNode->fileName.isEmpty()) {
QString name = importNode->fileName.toString();
- import[QStringLiteral("name")] = name;
+ import[nameLiteral()] = name;
if (name.endsWith(QLatin1String(".js"))) {
- import[QStringLiteral("type")] = QStringLiteral("javascript");
+ import[typeLiteral()] = QStringLiteral("javascript");
} else {
- import[QStringLiteral("type")] = QStringLiteral("directory");
+ import[typeLiteral()] = QStringLiteral("directory");
}
- import[QStringLiteral("path")] = QDir::cleanPath(path + QLatin1Char('/') + name);
+ import[pathLiteral()] = QDir::cleanPath(path + QLatin1Char('/') + name);
} else {
// Walk the id chain ("Foo" -> "Bar" -> etc)
QString name;
@@ -103,9 +111,9 @@ QVariantList findImportsInAst(QQmlJS::AST::UiHeaderItemList *headerItemList, con
}
name.chop(1); // remove trailing "."
if (!name.isEmpty())
- import[QStringLiteral("name")] = name;
- import[QStringLiteral("type")] = QStringLiteral("module");
- import[QStringLiteral("version")] = code.mid(importNode->versionToken.offset, importNode->versionToken.length);
+ import[nameLiteral()] = name;
+ import[typeLiteral()] = QStringLiteral("module");
+ import[versionLiteral()] = code.mid(importNode->versionToken.offset, importNode->versionToken.length);
}
imports.append(import);
@@ -117,7 +125,7 @@ QVariantList findImportsInAst(QQmlJS::AST::UiHeaderItemList *headerItemList, con
// Read the qmldir file, extract a list of plugins by
// parsing the "plugin" and "classname" lines.
QVariantMap pluginsForModulePath(const QString &modulePath) {
- QFile qmldirFile(modulePath + QStringLiteral("/qmldir"));
+ QFile qmldirFile(modulePath + QLatin1String("/qmldir"));
if (!qmldirFile.exists())
return QVariantMap();
@@ -141,16 +149,16 @@ QVariantMap pluginsForModulePath(const QString &modulePath) {
if (dep.length() != 3)
std::cerr << "depends: expected 2 arguments: module identifier and version" << std::endl;
else
- dependencies << QString::fromUtf8(dep[1]) + QStringLiteral(" ") + QString::fromUtf8(dep[2]).simplified();
+ dependencies << QString::fromUtf8(dep[1]) + QLatin1Char(' ') + QString::fromUtf8(dep[2]).simplified();
}
} while (line.length() > 0);
QVariantMap pluginInfo;
- pluginInfo[QStringLiteral("plugins")] = plugins.simplified();
- pluginInfo[QStringLiteral("classnames")] = classnames.simplified();
+ pluginInfo[pluginsLiteral()] = plugins.simplified();
+ pluginInfo[classnamesLiteral()] = classnames.simplified();
if (dependencies.length())
- pluginInfo[QStringLiteral("dependencies")] = dependencies;
+ pluginInfo[dependenciesLiteral()] = dependencies;
return pluginInfo;
}
@@ -163,7 +171,7 @@ QString resolveImportPath(const QString &uri, const QString &version)
QString ver = version;
while (true) {
- foreach (const QString &qmlImportPath, g_qmlImportPaths) {
+ for (const QString &qmlImportPath : qAsConst(g_qmlImportPaths)) {
// Search for the most specific version first, and search
// also for the version in parent modules. For example:
// - qml/QtQml/Models.2.0
@@ -210,25 +218,25 @@ QVariantList findPathsForModuleImports(const QVariantList &imports)
for (int i = 0; i < importsCopy.length(); ++i) {
QVariantMap import = qvariant_cast<QVariantMap>(importsCopy[i]);
- if (import[QStringLiteral("type")] == QLatin1String("module")) {
- QString path = resolveImportPath(import.value(QStringLiteral("name")).toString(), import.value(QStringLiteral("version")).toString());
+ if (import[typeLiteral()] == QLatin1String("module")) {
+ QString path = resolveImportPath(import.value(nameLiteral()).toString(), import.value(versionLiteral()).toString());
if (!path.isEmpty())
- import[QStringLiteral("path")] = path;
- QVariantMap plugininfo = pluginsForModulePath(import.value(QStringLiteral("path")).toString());
- QString plugins = plugininfo.value(QStringLiteral("plugins")).toString();
- QString classnames = plugininfo.value(QStringLiteral("classnames")).toString();
+ import[pathLiteral()] = path;
+ QVariantMap plugininfo = pluginsForModulePath(import.value(pathLiteral()).toString());
+ QString plugins = plugininfo.value(pluginsLiteral()).toString();
+ QString classnames = plugininfo.value(classnamesLiteral()).toString();
if (!plugins.isEmpty())
- import[QStringLiteral("plugin")] = plugins;
+ import.insert(QStringLiteral("plugin"), plugins);
if (!classnames.isEmpty())
- import[QStringLiteral("classname")] = classnames;
- if (plugininfo.contains(QStringLiteral("dependencies"))) {
- QStringList dependencies = plugininfo.value(QStringLiteral("dependencies")).toStringList();
- foreach (const QString &line, dependencies) {
+ import.insert(QStringLiteral("classname"), classnames);
+ if (plugininfo.contains(dependenciesLiteral())) {
+ const QStringList dependencies = plugininfo.value(dependenciesLiteral()).toStringList();
+ for (const QString &line : dependencies) {
const auto dep = line.splitRef(QLatin1Char(' '));
QVariantMap depImport;
- depImport[QStringLiteral("type")] = QStringLiteral("module");
- depImport[QStringLiteral("name")] = dep[0].toString();
- depImport[QStringLiteral("version")] = dep[1].toString();
+ depImport[typeLiteral()] = QStringLiteral("module");
+ depImport[nameLiteral()] = dep[0].toString();
+ depImport[versionLiteral()] = dep[1].toString();
importsCopy.append(depImport);
}
}
@@ -277,8 +285,8 @@ struct ImportCollector : public QQmlJS::Directives
virtual void importFile(const QString &jsfile, const QString &module, int line, int column)
{
QVariantMap entry;
- entry[QLatin1String("type")] = QStringLiteral("javascript");
- entry[QLatin1String("path")] = jsfile;
+ entry[typeLiteral()] = QStringLiteral("javascript");
+ entry[pathLiteral()] = jsfile;
imports << entry;
Q_UNUSED(module);
@@ -290,12 +298,12 @@ struct ImportCollector : public QQmlJS::Directives
{
QVariantMap entry;
if (uri.contains(QLatin1Char('/'))) {
- entry[QLatin1String("type")] = QStringLiteral("directory");
- entry[QLatin1String("name")] = uri;
+ entry[typeLiteral()] = QStringLiteral("directory");
+ entry[nameLiteral()] = uri;
} else {
- entry[QLatin1String("type")] = QStringLiteral("module");
- entry[QLatin1String("name")] = uri;
- entry[QLatin1String("version")] = version;
+ entry[typeLiteral()] = QStringLiteral("module");
+ entry[nameLiteral()] = uri;
+ entry[versionLiteral()] = version;
}
imports << entry;
@@ -354,7 +362,7 @@ QVariantList findQmlImportsInFile(const QString &filePath)
QVariantList mergeImports(const QVariantList &a, const QVariantList &b)
{
QVariantList merged = a;
- foreach (const QVariant &variant, b) {
+ for (const QVariant &variant : b) {
if (!merged.contains(variant))
merged.append(variant);
}
@@ -413,19 +421,19 @@ QVariantList findQmlImportsInDirectory(const QString &qmlDir)
continue;
}
- foreach (const QFileInfo &x, entries)
+ for (const QFileInfo &x : entries)
if (x.isFile())
ret = mergeImports(ret, findQmlImportsInFile(x.absoluteFilePath()));
}
return ret;
}
-QSet<QString> importModulePaths(QVariantList imports) {
+QSet<QString> importModulePaths(const QVariantList &imports) {
QSet<QString> ret;
- foreach (const QVariant &importVariant, imports) {
+ for (const QVariant &importVariant : imports) {
QVariantMap import = qvariant_cast<QVariantMap>(importVariant);
- QString path = import.value(QStringLiteral("path")).toString();
- QString type = import.value(QStringLiteral("type")).toString();
+ QString path = import.value(pathLiteral()).toString();
+ QString type = import.value(typeLiteral()).toString();
if (type == QLatin1String("module") && !path.isEmpty())
ret.insert(QDir(path).canonicalPath());
}
@@ -440,13 +448,13 @@ QVariantList findQmlImportsRecursively(const QStringList &qmlDirs, const QString
QVariantList ret;
// scan all app root qml directories for imports
- foreach (const QString &qmlDir, qmlDirs) {
+ for (const QString &qmlDir : qmlDirs) {
QVariantList imports = findQmlImportsInDirectory(qmlDir);
ret = mergeImports(ret, imports);
}
// scan app qml files for imports
- foreach (const QString &file, scanFiles) {
+ for (const QString &file : scanFiles) {
QVariantList imports = findQmlImportsInFile(file);
ret = mergeImports(ret, imports);
}
diff --git a/tools/qmljs/qmljs.cpp b/tools/qmljs/qmljs.cpp
index 4f79546bcc..964afc265b 100644
--- a/tools/qmljs/qmljs.cpp
+++ b/tools/qmljs/qmljs.cpp
@@ -118,7 +118,7 @@ static void showException(QV4::ExecutionContext *ctx, const QV4::Value &exceptio
std::cerr << "Uncaught exception: " << qPrintable(message->toQStringNoThrow()) << std::endl;
}
- foreach (const QV4::StackFrame &frame, trace) {
+ for (const QV4::StackFrame &frame : trace) {
std::cerr << " at " << qPrintable(frame.function) << " (" << qPrintable(frame.source);
if (frame.line >= 0)
std::cerr << ':' << frame.line;
@@ -188,7 +188,7 @@ int main(int argc, char *argv[])
QV4::ScopedObject gc(scope, vm.memoryManager->allocObject<builtins::GC>(ctx));
vm.globalObject->put(QV4::ScopedString(scope, vm.newIdentifier(QStringLiteral("gc"))).getPointer(), gc);
- foreach (const QString &fn, args) {
+ for (const QString &fn : qAsConst(args)) {
QFile file(fn);
if (file.open(QFile::ReadOnly)) {
const QString code = QString::fromUtf8(file.readAll());
diff --git a/tools/qmlmin/main.cpp b/tools/qmlmin/main.cpp
index 2b18a8442b..d2bad9d0d5 100644
--- a/tools/qmlmin/main.cpp
+++ b/tools/qmlmin/main.cpp
@@ -120,7 +120,7 @@ protected:
static QString quote(const QString &string)
{
QString quotedString;
- foreach (const QChar &ch, string) {
+ for (const QChar &ch : string) {
if (ch == QLatin1Char('"'))
quotedString += QLatin1String("\\\"");
else {
diff --git a/tools/qmlplugindump/main.cpp b/tools/qmlplugindump/main.cpp
index 0e5d3646c2..ceffebf14b 100644
--- a/tools/qmlplugindump/main.cpp
+++ b/tools/qmlplugindump/main.cpp
@@ -248,15 +248,15 @@ QSet<const QMetaObject *> collectReachableMetaObjects(QQmlEngine *engine,
QSet<const QQmlType *> baseExports = qmlTypesByCppName.value(it.key());
const QSet<QByteArray> extensionCppNames = it.value();
- foreach (const QByteArray &extensionCppName, extensionCppNames) {
+ for (const QByteArray &extensionCppName : extensionCppNames) {
const QSet<const QQmlType *> extensionExports = qmlTypesByCppName.value(extensionCppName);
// remove extension exports from base imports
// unfortunately the QQmlType pointers don't match, so can't use QSet::subtract
QSet<const QQmlType *> newBaseExports;
- foreach (const QQmlType *baseExport, baseExports) {
+ for (const QQmlType *baseExport : qAsConst(baseExports)) {
bool match = false;
- foreach (const QQmlType *extensionExport, extensionExports) {
+ for (const QQmlType *extensionExport : extensionExports) {
if (baseExport->qmlTypeName() == extensionExport->qmlTypeName()
&& baseExport->majorVersion() == extensionExport->majorVersion()
&& baseExport->minorVersion() == extensionExport->minorVersion()) {
@@ -469,7 +469,7 @@ public:
void dumpComposite(QQmlEngine *engine, const QSet<const QQmlType *> &compositeType, QSet<QByteArray> &defaultReachableNames)
{
- foreach (const QQmlType *type, compositeType)
+ for (const QQmlType *type : compositeType)
dumpCompositeItem(engine, type, defaultReachableNames);
}
@@ -518,7 +518,7 @@ public:
}
}
- foreach (const QMetaObject *meta, objectsToMerge)
+ for (const QMetaObject *meta : qAsConst(objectsToMerge))
writeMetaContent(meta, &knownAttributes);
qml->writeEndObject();
@@ -542,11 +542,11 @@ public:
if (meta->superClass())
qml->writeScriptBinding(QLatin1String("prototype"), enquote(convertToId(meta->superClass())));
- QSet<const QQmlType *> qmlTypes = qmlTypesByCppName.value(meta->className());
+ const QSet<const QQmlType *> qmlTypes = qmlTypesByCppName.value(meta->className());
if (!qmlTypes.isEmpty()) {
QHash<QString, const QQmlType *> exports;
- foreach (const QQmlType *qmlTy, qmlTypes) {
+ for (const QQmlType *qmlTy : qmlTypes) {
const QString exportString = getExportString(qmlTy->qmlTypeName(), qmlTy->majorVersion(), qmlTy->minorVersion());
exports.insert(exportString, qmlTy);
}
@@ -564,7 +564,7 @@ public:
// write meta object revisions
QStringList metaObjectRevisions;
- foreach (const QString &exportString, exportStrings) {
+ for (const QString &exportString : qAsConst(exportStrings)) {
int metaObjectRevision = exports[exportString]->metaObjectRevision();
metaObjectRevisions += QString::number(metaObjectRevision);
}
@@ -749,7 +749,7 @@ static bool readDependenciesData(QString dependenciesFile, const QByteArray &fil
if (verbose) {
std::cerr << "parsing "
<< qPrintable( dependenciesFile ) << " skipping";
- foreach (const QString &uriToSkip, urisToSkip)
+ for (const QString &uriToSkip : urisToSkip)
std::cerr << ' ' << qPrintable(uriToSkip);
std::cerr << std::endl;
}
@@ -763,13 +763,13 @@ static bool readDependenciesData(QString dependenciesFile, const QByteArray &fil
return false;
}
if (doc.isArray()) {
- QStringList requiredKeys = QStringList() << QStringLiteral("name")
- << QStringLiteral("type")
- << QStringLiteral("version");
+ const QStringList requiredKeys = QStringList() << QStringLiteral("name")
+ << QStringLiteral("type")
+ << QStringLiteral("version");
foreach (const QJsonValue &dep, doc.array()) {
if (dep.isObject()) {
QJsonObject obj = dep.toObject();
- foreach (const QString &requiredKey, requiredKeys)
+ for (const QString &requiredKey : requiredKeys)
if (!obj.contains(requiredKey) || obj.value(requiredKey).isString())
continue;
if (obj.value(QStringLiteral("type")).toString() != QLatin1String("module"))
@@ -850,7 +850,7 @@ static bool getDependencies(const QQmlEngine &engine, const QString &pluginImpor
if (!importScanner.waitForFinished()) {
std::cerr << "failure to start " << qPrintable(command);
- foreach (const QString &arg, commandArgs)
+ for (const QString &arg : qAsConst(commandArgs))
std::cerr << ' ' << qPrintable(arg);
std::cerr << std::endl;
return false;
@@ -863,7 +863,7 @@ static bool getDependencies(const QQmlEngine &engine, const QString &pluginImpor
}
QStringList aux;
- foreach (const QString &str, *dependencies) {
+ for (const QString &str : qAsConst(*dependencies)) {
if (!str.startsWith("Qt.test.qtestroot"))
aux += str;
}
@@ -1124,7 +1124,7 @@ int main(int argc, char *argv[])
// load the QtQml builtins and the dependencies
{
QByteArray code(qtQmlImportString.toUtf8());
- foreach (const QString &moduleToImport, dependencies) {
+ for (const QString &moduleToImport : qAsConst(dependencies)) {
code.append("\nimport ");
code.append(moduleToImport.toUtf8());
}
@@ -1154,7 +1154,7 @@ int main(int argc, char *argv[])
QSet<const QMetaObject *> metas;
if (action == Builtins) {
- foreach (const QMetaObject *m, defaultReachable) {
+ for (const QMetaObject *m : qAsConst(defaultReachable)) {
if (m->className() == QLatin1String("Qt")) {
metas.insert(m);
break;
@@ -1175,7 +1175,7 @@ int main(int argc, char *argv[])
return EXIT_INVALIDARGUMENTS;
}
metas = defaultReachable;
- foreach (const QMetaObject *m, defaultReachable) {
+ for (const QMetaObject *m : qAsConst(defaultReachable)) {
if (m->className() == QLatin1String("Qt")) {
metas.remove(m);
break;
@@ -1196,7 +1196,7 @@ int main(int argc, char *argv[])
QString::number(qtObjectType->minorVersion())).toUtf8();
}
// avoid importing dependencies?
- foreach (const QString &moduleToImport, dependencies) {
+ for (const QString &moduleToImport : qAsConst(dependencies)) {
importCode.append("\nimport ");
importCode.append(moduleToImport.toUtf8());
}
@@ -1231,9 +1231,9 @@ int main(int argc, char *argv[])
// Also eliminate meta objects with the same classname.
// This is required because extended objects seem not to share
// a single meta object instance.
- foreach (const QMetaObject *mo, defaultReachable)
+ for (const QMetaObject *mo : qAsConst(defaultReachable))
defaultReachableNames.insert(QByteArray(mo->className()));
- foreach (const QMetaObject *mo, candidates) {
+ for (const QMetaObject *mo : qAsConst(candidates)) {
if (!defaultReachableNames.contains(mo->className()))
metas.insert(mo);
}
@@ -1265,19 +1265,19 @@ int main(int argc, char *argv[])
compactDependencies(&dependencies);
QStringList quotedDependencies;
- foreach (const QString &dep, dependencies)
+ for (const QString &dep : qAsConst(dependencies))
quotedDependencies << enquote(dep);
qml.writeArrayBinding("dependencies", quotedDependencies);
// put the metaobjects into a map so they are always dumped in the same order
QMap<QString, const QMetaObject *> nameToMeta;
- foreach (const QMetaObject *meta, metas)
+ for (const QMetaObject *meta : qAsConst(metas))
nameToMeta.insert(convertToId(meta), meta);
Dumper dumper(&qml);
if (relocatable)
dumper.setRelocatableModuleUri(pluginImportUri);
- foreach (const QMetaObject *meta, nameToMeta) {
+ for (const QMetaObject *meta : qAsConst(nameToMeta)) {
dumper.dump(QQmlEnginePrivate::get(&engine), meta, uncreatableMetas.contains(meta), singletonMetas.contains(meta));
}
diff --git a/tools/qmlplugindump/qmlstreamwriter.cpp b/tools/qmlplugindump/qmlstreamwriter.cpp
index dd3c188fe4..3632cee60d 100644
--- a/tools/qmlplugindump/qmlstreamwriter.cpp
+++ b/tools/qmlplugindump/qmlstreamwriter.cpp
@@ -179,7 +179,7 @@ void QmlStreamWriter::flushPotentialLinesWithNewlines()
{
if (m_maybeOneline)
m_stream->write("\n");
- foreach (const QByteArray &line, m_pendingLines) {
+ for (const QByteArray &line : qAsConst(m_pendingLines)) {
writeIndent();
m_stream->write(line);
m_stream->write("\n");
diff --git a/tools/qmlplugindump/qmltypereader.cpp b/tools/qmlplugindump/qmltypereader.cpp
index 67ba415388..9dfb6fc1e0 100644
--- a/tools/qmlplugindump/qmltypereader.cpp
+++ b/tools/qmlplugindump/qmltypereader.cpp
@@ -40,7 +40,7 @@
#include <iostream>
QStringList readQmlTypes(const QString &filename) {
- QRegularExpression re("import QtQuick.tooling 1.2.*Module {\\s*dependencies:\\[([^\\]]*)\\](.*)}",
+ QRegularExpression re("import QtQuick\\.tooling 1\\.2.*Module {\\s*dependencies:\\s*\\[([^\\]]*)\\](.*)}",
QRegularExpression::DotMatchesEverythingOption);
if (!QFileInfo(filename).exists()) {
std::cerr << "Non existing file: " << filename.toStdString() << std::endl;
diff --git a/tools/qmlprofiler/qmlprofilerapplication.cpp b/tools/qmlprofiler/qmlprofilerapplication.cpp
index 45c32487a2..033492b516 100644
--- a/tools/qmlprofiler/qmlprofilerapplication.cpp
+++ b/tools/qmlprofiler/qmlprofilerapplication.cpp
@@ -274,8 +274,8 @@ quint64 QmlProfilerApplication::parseFeatures(const QStringList &featureList, co
bool exclude)
{
quint64 features = exclude ? std::numeric_limits<quint64>::max() : 0;
- QStringList givenFeatures = values.split(QLatin1Char(','));
- foreach (const QString &f, givenFeatures) {
+ const QStringList givenFeatures = values.split(QLatin1Char(','));
+ for (const QString &f : givenFeatures) {
int index = featureList.indexOf(f);
if (index < 0) {
logError(tr("Unknown feature '%1'").arg(f));
diff --git a/tools/qmlprofiler/qmlprofilerdata.cpp b/tools/qmlprofiler/qmlprofilerdata.cpp
index b651b2724f..048c92bb93 100644
--- a/tools/qmlprofiler/qmlprofilerdata.cpp
+++ b/tools/qmlprofiler/qmlprofilerdata.cpp
@@ -572,7 +572,7 @@ bool QmlProfilerData::save(const QString &filename)
stream.writeEndElement(); // eventData
stream.writeStartElement(QStringLiteral("profilerDataModel"));
- foreach (const QmlRangeEventStartInstance &event, d->startInstanceList) {
+ for (const QmlRangeEventStartInstance &event : qAsConst(d->startInstanceList)) {
stream.writeStartElement(QStringLiteral("range"));
stream.writeAttribute(QStringLiteral("startTime"), QString::number(event.startTime));
if (event.duration >= 0)
diff --git a/tools/qmlscene/main.cpp b/tools/qmlscene/main.cpp
index 0e542ab0c8..9e1002166d 100644
--- a/tools/qmlscene/main.cpp
+++ b/tools/qmlscene/main.cpp
@@ -175,10 +175,10 @@ QFileInfoList findQmlFiles(const QString &dirName)
QFileInfoList ret;
if (dir.exists()) {
- QFileInfoList fileInfos = dir.entryInfoList(QStringList() << "*.qml",
- QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot);
+ const QFileInfoList fileInfos = dir.entryInfoList(QStringList() << "*.qml",
+ QDir::Files | QDir::AllDirs | QDir::NoDotAndDotDot);
- foreach (QFileInfo fileInfo, fileInfos) {
+ for (const QFileInfo &fileInfo : fileInfos) {
if (fileInfo.isDir())
ret += findQmlFiles(fileInfo.filePath());
else if (fileInfo.fileName().length() > 0 && fileInfo.fileName().at(0).isLower())
@@ -196,9 +196,9 @@ static int displayOptionsDialog(Options *options)
QFormLayout *layout = new QFormLayout(&dialog);
QComboBox *qmlFileComboBox = new QComboBox(&dialog);
- QFileInfoList fileInfos = findQmlFiles(":/bundle") + findQmlFiles("./qmlscene-resources");
+ const QFileInfoList fileInfos = findQmlFiles(":/bundle") + findQmlFiles("./qmlscene-resources");
- foreach (QFileInfo fileInfo, fileInfos)
+ for (const QFileInfo &fileInfo : fileInfos)
qmlFileComboBox->addItem(fileInfo.dir().dirName() + QLatin1Char('/') + fileInfo.fileName(), QVariant::fromValue(fileInfo));
QCheckBox *originalCheckBox = new QCheckBox(&dialog);
@@ -319,8 +319,8 @@ static void loadDummyDataFiles(QQmlEngine &engine, const QString& directory)
QObject *dummyData = comp.create();
if(comp.isError()) {
- QList<QQmlError> errors = comp.errors();
- foreach (const QQmlError &error, errors)
+ const QList<QQmlError> errors = comp.errors();
+ for (const QQmlError &error : errors)
fprintf(stderr, "%s\n", qPrintable(error.toString()));
}
@@ -457,7 +457,7 @@ int main(int argc, char ** argv)
options.applicationAttributes.append(Qt::AA_DisableHighDpiScaling);
}
- foreach (Qt::ApplicationAttribute a, options.applicationAttributes)
+ for (Qt::ApplicationAttribute a : qAsConst(options.applicationAttributes))
QCoreApplication::setAttribute(a);
#ifdef QT_WIDGETS_LIB
QApplication app(argc, argv);
diff --git a/tools/tools.pro b/tools/tools.pro
index 18bfe28a8a..5f72588a7e 100644
--- a/tools/tools.pro
+++ b/tools/tools.pro
@@ -23,7 +23,7 @@ qmlimportscanner.CONFIG = host_build
qtHaveModule(widgets): SUBDIRS += qmleasing
}
qtHaveModule(qmltest): SUBDIRS += qmltestrunner
- contains(QT_CONFIG, private_tests): SUBDIRS += qmljs
+ qtConfig(private_tests): SUBDIRS += qmljs
}
qml.depends = qmlimportscanner