aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2016-08-22 11:30:25 +0200
committerOswald Buddenhagen <oswald.buddenhagen@theqtcompany.com>2016-08-22 11:30:26 +0200
commit8eeede619f417904cbd33fd44143f857dfce0996 (patch)
treead89f79cf5fb56f3de5fc4a8dc7c4e2c8e2c419e /src
parentb8f145547e5477cd67f464c2d834f60a84f4aad6 (diff)
parent3ef4fac9ff3f785d3ccbda4b28ec2c0ea2ee1b59 (diff)
Merge dev into 5.8
Diffstat (limited to 'src')
-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/qquickparticlepainter.cpp3
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp34
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12engine_p.h15
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12engine_p_p.h3
-rw-r--r--src/plugins/scenegraph/d3d12/qsgd3d12glyphcache.cpp17
-rw-r--r--src/plugins/scenegraph/d3d12/shaders/textmask.hlsl16
-rw-r--r--src/qml/compiler/qqmlirbuilder.cpp2
-rw-r--r--src/qml/compiler/qqmlirbuilder_p.h1
-rw-r--r--src/qml/compiler/qqmltypecompiler.cpp2
-rw-r--r--src/qml/compiler/qv4codegen.cpp7
-rw-r--r--src/qml/compiler/qv4compilationunitmapper.cpp12
-rw-r--r--src/qml/compiler/qv4compilationunitmapper_win.cpp23
-rw-r--r--src/qml/compiler/qv4compileddata_p.h5
-rw-r--r--src/qml/compiler/qv4compiler.cpp1
-rw-r--r--src/qml/compiler/qv4isel_moth.cpp163
-rw-r--r--src/qml/compiler/qv4jsir_p.h2
-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/jit/qv4isel_masm.cpp1
-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/ftw/qdeletewatcher_p.h111
-rw-r--r--src/qml/qml/qqmlbinding.cpp11
-rw-r--r--src/qml/qml/qqmlbinding_p.h2
-rw-r--r--src/qml/qml/qqmlengine.cpp3
-rw-r--r--src/qml/qml/qqmlexpression_p.h1
-rw-r--r--src/qml/qml/qqmlimport.cpp2
-rw-r--r--src/qml/qml/qqmljavascriptexpression.cpp2
-rw-r--r--src/qml/qml/qqmlobjectcreator.cpp10
-rw-r--r--src/qml/qml/qqmlproperty.cpp25
-rw-r--r--src/qml/qml/qqmlpropertycache.cpp18
-rw-r--r--src/qml/qml/qqmlpropertycache_p.h109
-rw-r--r--src/qml/qml/qqmltypeloader.cpp2
-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/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/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/qsgdefaultdistancefieldglyphcache.cpp3
-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
89 files changed, 663 insertions, 645 deletions
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 9e3cdf3f42..affc1db2c0 100644
--- a/src/imports/imports.pro
+++ b/src/imports/imports.pro
@@ -16,10 +16,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/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 9aae3fd8cd..2644c693ce 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12engine.cpp
@@ -497,14 +497,15 @@ void QSGD3D12Engine::queueTextureResize(uint id, const QSize &size)
d->queueTextureResize(id, size);
}
-void QSGD3D12Engine::queueTextureUpload(uint id, const QImage &image, const QPoint &dstPos)
+void QSGD3D12Engine::queueTextureUpload(uint id, const QImage &image, const QPoint &dstPos, TextureUploadFlags flags)
{
- d->queueTextureUpload(id, QVector<QImage>() << image, QVector<QPoint>() << dstPos);
+ d->queueTextureUpload(id, QVector<QImage>() << image, QVector<QPoint>() << dstPos, flags);
}
-void QSGD3D12Engine::queueTextureUpload(uint id, const QVector<QImage> &images, const QVector<QPoint> &dstPos)
+void QSGD3D12Engine::queueTextureUpload(uint id, const QVector<QImage> &images, const QVector<QPoint> &dstPos,
+ TextureUploadFlags flags)
{
- d->queueTextureUpload(id, images, dstPos);
+ d->queueTextureUpload(id, images, dstPos, flags);
}
void QSGD3D12Engine::releaseTexture(uint id)
@@ -2325,7 +2326,7 @@ uint QSGD3D12EnginePrivate::genTexture()
return id;
}
-static inline DXGI_FORMAT textureFormat(QImage::Format format, bool wantsAlpha, bool mipmap,
+static inline DXGI_FORMAT textureFormat(QImage::Format format, bool wantsAlpha, bool mipmap, bool force32bit,
QImage::Format *imageFormat, int *bytesPerPixel)
{
DXGI_FORMAT f = DXGI_FORMAT_R8G8B8A8_UNORM;
@@ -2337,8 +2338,12 @@ static inline DXGI_FORMAT textureFormat(QImage::Format format, bool wantsAlpha,
case QImage::Format_Grayscale8:
case QImage::Format_Indexed8:
case QImage::Format_Alpha8:
- f = DXGI_FORMAT_R8_UNORM;
- bpp = 1;
+ if (!force32bit) {
+ f = DXGI_FORMAT_R8_UNORM;
+ bpp = 1;
+ } else {
+ convFormat = QImage::Format_RGBA8888;
+ }
break;
case QImage::Format_RGB32:
f = DXGI_FORMAT_B8G8R8A8_UNORM;
@@ -2414,7 +2419,9 @@ void QSGD3D12EnginePrivate::createTexture(uint id, const QSize &size, QImage::Fo
textureDesc.Height = adjustedSize.height();
textureDesc.DepthOrArraySize = 1;
textureDesc.MipLevels = !t.mipmap() ? 1 : QSGD3D12Engine::mipMapLevels(adjustedSize);
- textureDesc.Format = textureFormat(format, t.alpha(), t.mipmap(), nullptr, nullptr);
+ textureDesc.Format = textureFormat(format, t.alpha(), t.mipmap(),
+ createFlags.testFlag(QSGD3D12Engine::TextureAlways32Bit),
+ nullptr, nullptr);
textureDesc.SampleDesc.Count = 1;
textureDesc.Layout = D3D12_TEXTURE_LAYOUT_UNKNOWN;
if (t.mipmap())
@@ -2528,7 +2535,8 @@ void QSGD3D12EnginePrivate::queueTextureResize(uint id, const QSize &size)
qDebug("submitted old content copy for texture %u on the copy queue, fence %llu", id, t.fenceValue);
}
-void QSGD3D12EnginePrivate::queueTextureUpload(uint id, const QVector<QImage> &images, const QVector<QPoint> &dstPos)
+void QSGD3D12EnginePrivate::queueTextureUpload(uint id, const QVector<QImage> &images, const QVector<QPoint> &dstPos,
+ QSGD3D12Engine::TextureUploadFlags flags)
{
Q_ASSERT(id);
Q_ASSERT(images.count() == dstPos.count());
@@ -2565,7 +2573,9 @@ void QSGD3D12EnginePrivate::queueTextureUpload(uint id, const QVector<QImage> &i
int totalSize = 0;
for (const QImage &image : images) {
int bytesPerPixel;
- textureFormat(image.format(), t.alpha(), t.mipmap(), nullptr, &bytesPerPixel);
+ textureFormat(image.format(), t.alpha(), t.mipmap(),
+ flags.testFlag(QSGD3D12Engine::TextureUploadAlways32Bit),
+ nullptr, &bytesPerPixel);
const int w = !t.mipmap() ? image.width() : adjustedTextureSize.width();
const int h = !t.mipmap() ? image.height() : adjustedTextureSize.height();
const int stride = alignedSize(w * bytesPerPixel, D3D12_TEXTURE_DATA_PITCH_ALIGNMENT);
@@ -2597,7 +2607,9 @@ void QSGD3D12EnginePrivate::queueTextureUpload(uint id, const QVector<QImage> &i
for (int i = 0; i < images.count(); ++i) {
QImage::Format convFormat;
int bytesPerPixel;
- textureFormat(images[i].format(), t.alpha(), t.mipmap(), &convFormat, &bytesPerPixel);
+ textureFormat(images[i].format(), t.alpha(), t.mipmap(),
+ flags.testFlag(QSGD3D12Engine::TextureUploadAlways32Bit),
+ &convFormat, &bytesPerPixel);
if (Q_UNLIKELY(debug_texture() && i == 0))
qDebug("source image format %d, target format %d, bpp %d", images[i].format(), convFormat, bytesPerPixel);
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12engine_p.h b/src/plugins/scenegraph/d3d12/qsgd3d12engine_p.h
index 46cd73e63a..b30994fe0d 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12engine_p.h
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12engine_p.h
@@ -349,16 +349,22 @@ public:
static QSize mipMapAdjustedSourceSize(const QSize &size);
enum TextureCreateFlag {
- TextureWithAlpha = 0x1,
- TextureWithMipMaps = 0x2
+ TextureWithAlpha = 0x01,
+ TextureWithMipMaps = 0x02,
+ TextureAlways32Bit = 0x04
};
Q_DECLARE_FLAGS(TextureCreateFlags, TextureCreateFlag)
+ enum TextureUploadFlag {
+ TextureUploadAlways32Bit = 0x01
+ };
+ Q_DECLARE_FLAGS(TextureUploadFlags, TextureUploadFlag)
+
uint genTexture();
void createTexture(uint id, const QSize &size, QImage::Format format, TextureCreateFlags flags);
void queueTextureResize(uint id, const QSize &size);
- void queueTextureUpload(uint id, const QImage &image, const QPoint &dstPos = QPoint());
- void queueTextureUpload(uint id, const QVector<QImage> &images, const QVector<QPoint> &dstPos);
+ void queueTextureUpload(uint id, const QImage &image, const QPoint &dstPos = QPoint(), TextureUploadFlags flags = 0);
+ void queueTextureUpload(uint id, const QVector<QImage> &images, const QVector<QPoint> &dstPos, TextureUploadFlags flags = 0);
void releaseTexture(uint id);
void useTexture(uint id);
@@ -381,6 +387,7 @@ private:
Q_DECLARE_OPERATORS_FOR_FLAGS(QSGD3D12Engine::ClearFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(QSGD3D12Engine::TextureCreateFlags)
+Q_DECLARE_OPERATORS_FOR_FLAGS(QSGD3D12Engine::TextureUploadFlags)
QT_END_NAMESPACE
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12engine_p_p.h b/src/plugins/scenegraph/d3d12/qsgd3d12engine_p_p.h
index b3b244cd86..1048ed63e7 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12engine_p_p.h
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12engine_p_p.h
@@ -170,7 +170,8 @@ public:
uint genTexture();
void createTexture(uint id, const QSize &size, QImage::Format format, QSGD3D12Engine::TextureCreateFlags flags);
void queueTextureResize(uint id, const QSize &size);
- void queueTextureUpload(uint id, const QVector<QImage> &images, const QVector<QPoint> &dstPos);
+ void queueTextureUpload(uint id, const QVector<QImage> &images, const QVector<QPoint> &dstPos,
+ QSGD3D12Engine::TextureUploadFlags flags);
void releaseTexture(uint id);
void useTexture(uint id);
diff --git a/src/plugins/scenegraph/d3d12/qsgd3d12glyphcache.cpp b/src/plugins/scenegraph/d3d12/qsgd3d12glyphcache.cpp
index 45ef202e83..915917c3d5 100644
--- a/src/plugins/scenegraph/d3d12/qsgd3d12glyphcache.cpp
+++ b/src/plugins/scenegraph/d3d12/qsgd3d12glyphcache.cpp
@@ -42,6 +42,11 @@
QT_BEGIN_NAMESPACE
+// Convert A8 glyphs to 32-bit in the engine. This is here to work around
+// QTBUG-55330 for AMD cards.
+// If removing, textmask.hlsl must be adjusted! (.a -> .r)
+#define ALWAYS_32BIT
+
// NOTE: Avoid categorized logging. It is slow.
#define DECLARE_DEBUG_VAR(variable) \
@@ -77,7 +82,11 @@ void QSGD3D12GlyphCache::createTextureData(int width, int height)
const QImage::Format imageFormat =
m_format == QFontEngine::Format_A8 ? QImage::Format_Alpha8 : QImage::Format_ARGB32_Premultiplied;
- m_engine->createTexture(m_id, m_size, imageFormat, QSGD3D12Engine::TextureWithAlpha);
+ m_engine->createTexture(m_id, m_size, imageFormat, QSGD3D12Engine::TextureWithAlpha
+#ifdef ALWAYS_32BIT
+ | QSGD3D12Engine::TextureAlways32Bit
+#endif
+ );
}
void QSGD3D12GlyphCache::resizeTextureData(int width, int height)
@@ -146,7 +155,11 @@ void QSGD3D12GlyphCache::endFillTexture()
Q_ASSERT(m_id);
- m_engine->queueTextureUpload(m_id, m_glyphImages, m_glyphPos);
+ m_engine->queueTextureUpload(m_id, m_glyphImages, m_glyphPos
+#ifdef ALWAYS_32BIT
+ , QSGD3D12Engine::TextureUploadAlways32Bit
+#endif
+ );
// Nothing else left to do, it is up to the text material to call
// useTexture() which will then add the texture dependency to the frame.
diff --git a/src/plugins/scenegraph/d3d12/shaders/textmask.hlsl b/src/plugins/scenegraph/d3d12/shaders/textmask.hlsl
index f9d92e8ee9..bb9381e7c0 100644
--- a/src/plugins/scenegraph/d3d12/shaders/textmask.hlsl
+++ b/src/plugins/scenegraph/d3d12/shaders/textmask.hlsl
@@ -45,7 +45,7 @@ float4 PS_TextMask32(PSInput input) : SV_TARGET
float4 PS_TextMask8(PSInput input) : SV_TARGET
{
- return colorVec * tex.Sample(samp, input.coord).r;
+ return colorVec * tex.Sample(samp, input.coord).a;
}
struct StyledPSInput
@@ -66,8 +66,8 @@ StyledPSInput VS_StyledText(VSInput input)
float4 PS_StyledText(StyledPSInput input) : SV_TARGET
{
- float glyph = tex.Sample(samp, input.coord).r;
- float style = clamp(tex.Sample(samp, input.shiftedCoord).r - glyph, 0.0, 1.0);
+ float glyph = tex.Sample(samp, input.coord).a;
+ float style = clamp(tex.Sample(samp, input.shiftedCoord).a - glyph, 0.0, 1.0);
return style * styleColor + glyph * colorVec;
}
@@ -95,10 +95,10 @@ OutlinedPSInput VS_OutlinedText(VSInput input)
float4 PS_OutlinedText(OutlinedPSInput input) : SV_TARGET
{
- float glyph = tex.Sample(samp, input.coord).r;
- float outline = clamp(clamp(tex.Sample(samp, input.coordUp).r
- + tex.Sample(samp, input.coordDown).r
- + tex.Sample(samp, input.coordLeft).r
- + tex.Sample(samp, input.coordRight).r, 0.0, 1.0) - glyph, 0.0, 1.0);
+ float glyph = tex.Sample(samp, input.coord).a;
+ float outline = clamp(clamp(tex.Sample(samp, input.coordUp).a
+ + tex.Sample(samp, input.coordDown).a
+ + tex.Sample(samp, input.coordLeft).a
+ + tex.Sample(samp, input.coordRight).a, 0.0, 1.0) - glyph, 0.0, 1.0);
return outline * styleColor + glyph * colorVec;
}
diff --git a/src/qml/compiler/qqmlirbuilder.cpp b/src/qml/compiler/qqmlirbuilder.cpp
index ef8ffa8620..31b964897f 100644
--- a/src/qml/compiler/qqmlirbuilder.cpp
+++ b/src/qml/compiler/qqmlirbuilder.cpp
@@ -302,7 +302,6 @@ Document::Document(bool debugMode)
, program(0)
, indexOfRootObject(0)
, jsGenerator(&jsModule)
- , unitFlags(0)
{
}
@@ -1393,7 +1392,6 @@ QV4::CompiledData::Unit *QmlUnitGenerator::generate(Document &output, QQmlEngine
QV4::CompiledData::Unit *qmlUnit = reinterpret_cast<QV4::CompiledData::Unit *>(data);
qmlUnit->unitSize = totalSize;
- qmlUnit->flags |= output.unitFlags;
qmlUnit->flags |= QV4::CompiledData::Unit::IsQml;
qmlUnit->offsetToImports = unitSize;
qmlUnit->nImports = output.imports.count();
diff --git a/src/qml/compiler/qqmlirbuilder_p.h b/src/qml/compiler/qqmlirbuilder_p.h
index eedc262e7a..cc16dc2104 100644
--- a/src/qml/compiler/qqmlirbuilder_p.h
+++ b/src/qml/compiler/qqmlirbuilder_p.h
@@ -435,7 +435,6 @@ struct Q_QML_PRIVATE_EXPORT Document
int indexOfRootObject;
QVector<Object*> objects;
QV4::Compiler::JSUnitGenerator jsGenerator;
- quint32 unitFlags;
QQmlRefPointer<QV4::CompiledData::CompilationUnit> javaScriptCompilationUnit;
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/qv4compilationunitmapper.cpp b/src/qml/compiler/qv4compilationunitmapper.cpp
index b53b7cf784..2e1213464c 100644
--- a/src/qml/compiler/qv4compilationunitmapper.cpp
+++ b/src/qml/compiler/qv4compilationunitmapper.cpp
@@ -42,6 +42,7 @@
#include "qv4compileddata_p.h"
#include <QFileInfo>
#include <QDateTime>
+#include <QCoreApplication>
QT_BEGIN_NAMESPACE
@@ -77,7 +78,16 @@ bool CompilationUnitMapper::verifyHeader(const CompiledData::Unit *header, const
{
QFileInfo sourceCode(sourcePath);
- if (sourceCode.exists() && sourceCode.lastModified().toMSecsSinceEpoch() != header->sourceTimeStamp) {
+ QDateTime sourceTimeStamp;
+ if (sourceCode.exists())
+ sourceTimeStamp = sourceCode.lastModified();
+
+ // Files from the resource system do not have any time stamps, so fall back to the application
+ // executable.
+ if (!sourceTimeStamp.isValid())
+ sourceTimeStamp = QFileInfo(QCoreApplication::applicationFilePath()).lastModified();
+
+ if (sourceTimeStamp.isValid() && sourceTimeStamp.toMSecsSinceEpoch() != header->sourceTimeStamp) {
*errorString = QStringLiteral("QML source file has a different time stamp than cached file.");
return false;
}
diff --git a/src/qml/compiler/qv4compilationunitmapper_win.cpp b/src/qml/compiler/qv4compilationunitmapper_win.cpp
index 7e62cbfe8b..abf109484b 100644
--- a/src/qml/compiler/qv4compilationunitmapper_win.cpp
+++ b/src/qml/compiler/qv4compilationunitmapper_win.cpp
@@ -75,15 +75,12 @@ CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, co
CloseHandle(handle);
});
-#if defined(Q_OS_WINRT)
- *errorString = QStringLiteral("Compilation unit mapping not supported on WinRT yet");
- return nullptr;
-#else
+#if !defined(Q_OS_WINRT) || _MSC_VER >= 1900
CompiledData::Unit header;
DWORD bytesRead;
if (!ReadFile(handle, reinterpret_cast<char *>(&header), sizeof(header), &bytesRead, nullptr)) {
*errorString = qt_error_string(GetLastError());
- return false;
+ return nullptr;
}
if (bytesRead != sizeof(header)) {
@@ -94,31 +91,39 @@ CompiledData::Unit *CompilationUnitMapper::open(const QString &cacheFileName, co
if (!verifyHeader(&header, sourcePath, errorString))
return nullptr;
+ const uint mappingFlags = header.flags & QV4::CompiledData::Unit::ContainsMachineCode
+ ? PAGE_EXECUTE_READ : PAGE_READONLY;
+ const uint viewFlags = header.flags & QV4::CompiledData::Unit::ContainsMachineCode
+ ? (FILE_MAP_READ | FILE_MAP_EXECUTE) : FILE_MAP_READ;
+
// Data structure and qt version matched, so now we can access the rest of the file safely.
- HANDLE fileMappingHandle = CreateFileMapping(handle, 0, PAGE_EXECUTE_READ, 0, 0, 0);
+ HANDLE fileMappingHandle = CreateFileMapping(handle, 0, mappingFlags, 0, 0, 0);
if (!fileMappingHandle) {
*errorString = qt_error_string(GetLastError());
- return false;
+ return nullptr;
}
QDeferredCleanup mappingCleanup([fileMappingHandle]{
CloseHandle(fileMappingHandle);
});
- dataPtr = MapViewOfFile(fileMappingHandle, FILE_MAP_READ | FILE_MAP_EXECUTE, 0, 0, 0);
+ dataPtr = MapViewOfFile(fileMappingHandle, viewFlags, 0, 0, 0);
if (!dataPtr) {
*errorString = qt_error_string(GetLastError());
return nullptr;
}
return reinterpret_cast<CompiledData::Unit*>(dataPtr);
+#else
+ *errorString = QStringLiteral("Compilation unit mapping not supported on WinRT 8.1");
+ return nullptr;
#endif
}
void CompilationUnitMapper::close()
{
-#if !defined(Q_OS_WINRT)
+#if !defined(Q_OS_WINRT) || _MSC_VER >= 1900
if (dataPtr != nullptr)
UnmapViewOfFile(dataPtr);
#endif
diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h
index a6ca1594a4..b71c1d8185 100644
--- a/src/qml/compiler/qv4compileddata_p.h
+++ b/src/qml/compiler/qv4compileddata_p.h
@@ -71,7 +71,7 @@
QT_BEGIN_NAMESPACE
// Bump this whenever the compiler data structures change in an incompatible way.
-#define QV4_DATA_STRUCTURE_VERSION 0x02
+#define QV4_DATA_STRUCTURE_VERSION 0x03
class QIODevice;
class QQmlPropertyCache;
@@ -619,7 +619,8 @@ struct Unit
IsQml = 0x2,
StaticData = 0x4, // Unit data persistent in memory?
IsSingleton = 0x8,
- IsSharedLibrary = 0x10 // .pragma shared?
+ IsSharedLibrary = 0x10, // .pragma shared?
+ ContainsMachineCode = 0x20 // used to determine if we need to mmap with execute permissions
};
LEUInt32 flags;
LEUInt32 stringTableSize;
diff --git a/src/qml/compiler/qv4compiler.cpp b/src/qml/compiler/qv4compiler.cpp
index 50ade2c6e5..c6a872cc34 100644
--- a/src/qml/compiler/qv4compiler.cpp
+++ b/src/qml/compiler/qv4compiler.cpp
@@ -364,6 +364,7 @@ QV4::CompiledData::Unit QV4::Compiler::JSUnitGenerator::generateHeader(QV4::Comp
CompiledData::Unit unit;
memcpy(unit.magic, CompiledData::magic_str, sizeof(unit.magic));
unit.flags = QV4::CompiledData::Unit::IsJavascript;
+ unit.flags |= irModule->unitFlags;
unit.version = QV4_DATA_STRUCTURE_VERSION;
unit.qtVersion = QT_VERSION;
unit.architectureIndex = registerString(QSysInfo::buildAbi());
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/qv4jsir_p.h b/src/qml/compiler/qv4jsir_p.h
index 51b8797862..73aa6c4975 100644
--- a/src/qml/compiler/qv4jsir_p.h
+++ b/src/qml/compiler/qv4jsir_p.h
@@ -934,6 +934,7 @@ struct Q_QML_PRIVATE_EXPORT Module {
QString fileName;
qint64 sourceTimeStamp;
bool isQmlModule; // implies rootFunction is always 0
+ uint unitFlags; // flags merged into CompiledData::Unit::flags
#ifdef QT_NO_QML_DEBUGGER
static const bool debugMode = false;
#else
@@ -946,6 +947,7 @@ struct Q_QML_PRIVATE_EXPORT Module {
: rootFunction(0)
, sourceTimeStamp(0)
, isQmlModule(false)
+ , unitFlags(0)
#ifndef QT_NO_QML_DEBUGGER
, debugMode(debugMode)
{}
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/jit/qv4isel_masm.cpp b/src/qml/jit/qv4isel_masm.cpp
index c1c42f876c..9759b72794 100644
--- a/src/qml/jit/qv4isel_masm.cpp
+++ b/src/qml/jit/qv4isel_masm.cpp
@@ -265,6 +265,7 @@ InstructionSelection::InstructionSelection(QQmlEnginePrivate *qmlEngine, QV4::Ex
, qmlEngine(qmlEngine)
{
compilationUnit->codeRefs.resize(module->functions.size());
+ module->unitFlags |= QV4::CompiledData::Unit::ContainsMachineCode;
}
InstructionSelection::~InstructionSelection()
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/ftw/qdeletewatcher_p.h b/src/qml/qml/ftw/qdeletewatcher_p.h
deleted file mode 100644
index d4c0c6dfb2..0000000000
--- a/src/qml/qml/ftw/qdeletewatcher_p.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/****************************************************************************
-**
-** Copyright (C) 2016 The Qt Company Ltd.
-** 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$
-**
-****************************************************************************/
-
-#ifndef QDELETEWATCHER_P_H
-#define QDELETEWATCHER_P_H
-
-//
-// W A R N I N G
-// -------------
-//
-// This file is not part of the Qt API. It exists purely as an
-// implementation detail. This header file may change from version to
-// version without notice, or even be removed.
-//
-// We mean it.
-//
-
-#include <QtCore/qglobal.h>
-
-QT_BEGIN_NAMESPACE
-
-class QDeleteWatchable
-{
-public:
- inline QDeleteWatchable();
- inline ~QDeleteWatchable();
-private:
- friend class QDeleteWatcher;
- bool *_w;
-};
-
-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;
-};
-
-QDeleteWatchable::QDeleteWatchable()
-: _w(0)
-{
-}
-
-QDeleteWatchable::~QDeleteWatchable()
-{
- if (_w) *_w = true;
-}
-
-QDeleteWatcher::QDeleteWatcher(QDeleteWatchable *data)
-: _s(false), m_d(data)
-{
- if (!m_d->_w)
- m_d->_w = &_s;
- _w = m_d->_w;
-}
-
-QDeleteWatcher::~QDeleteWatcher()
-{
- if (false == *_w && &_s == m_d->_w)
- m_d->_w = 0;
-}
-
-bool QDeleteWatcher::wasDeleted() const
-{
- return *_w;
-}
-
-QT_END_NAMESPACE
-
-#endif // QDELETEWATCHER_P_H
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 c939af93ef..7e4fe73ba1 100644
--- a/src/qml/qml/qqmlengine.cpp
+++ b/src/qml/qml/qqmlengine.cpp
@@ -407,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 efa824dfae..ebc4d49c36 100644
--- a/src/qml/qml/qqmljavascriptexpression.cpp
+++ b/src/qml/qml/qqmljavascriptexpression.cpp
@@ -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/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 af9b8cc045..5c53e342f3 100644
--- a/src/qml/qml/qqmlpropertycache.cpp
+++ b/src/qml/qml/qqmlpropertycache.cpp
@@ -161,7 +161,6 @@ void QQmlPropertyData::lazyLoad(const QMetaProperty &p)
_flags.type = Flags::QVariantType;
} else if (type == QVariant::UserType || type == -1) {
_flags.notFullyResolved = true;
- setPropTypeName(p.typeName());
} else {
setPropType(type);
}
@@ -224,7 +223,6 @@ void QQmlPropertyData::lazyLoad(const QMetaMethod &m)
if (!returnType)
returnType = "\0";
if ((*returnType != 'v') || (qstrcmp(returnType+1, "oid") != 0)) {
- setPropTypeName(returnType);
_flags.notFullyResolved = true;
}
@@ -680,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);
@@ -691,13 +688,22 @@ void QQmlPropertyCache::append(const QMetaObject *metaObject,
void QQmlPropertyCache::resolve(QQmlPropertyData *data) const
{
Q_ASSERT(data->notFullyResolved());
-
- data->setPropType(QMetaType::type(data->propTypeName()));
data->_flags.notFullyResolved = false;
+ const QMetaObject *mo = firstCppMetaObject();
+ if (data->isFunction()) {
+ auto metaMethod = mo->method(data->coreIndex());
+ const char *retTy = metaMethod.typeName();
+ if (!retTy)
+ retTy = "\0";
+ data->setPropType(QMetaType::type(retTy));
+ } else {
+ auto metaProperty = mo->property(data->coreIndex());
+ data->setPropType(QMetaType::type(metaProperty.typeName()));
+ }
+
if (!data->isFunction()) {
if (data->propType() == QMetaType::UnknownType) {
- const QMetaObject *mo = _metaObject;
QQmlPropertyCache *p = _parent;
while (p && (!mo || _ownMetaObject)) {
mo = p->_metaObject;
diff --git a/src/qml/qml/qqmlpropertycache_p.h b/src/qml/qml/qqmlpropertycache_p.h
index 6d3c4a8a7e..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,23 +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; }
-
- const char *propTypeName() const { Q_ASSERT(!isFullyResolved()); return _propTypeName; }
- void setPropTypeName(const char *ptn) { _propTypeName = ptn; }
+ 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)
@@ -194,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)
{
@@ -202,54 +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:
- union {
- int _propType; // When !NotFullyResolved
- const char *_propTypeName; // 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:
@@ -570,7 +575,6 @@ QQmlPropertyRawData::Flags::Flags()
, isFinal(false)
, isOverridden(false)
, isDirect(false)
- , hasAccessors(false)
, type(OtherType)
, isVMEFunction(false)
, hasArguments(false)
@@ -594,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 &&
@@ -625,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/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index f7846f333b..566f5ef767 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -2929,7 +2929,7 @@ void QQmlScriptBlob::dataReceived(const Data &data)
irUnit.javaScriptCompilationUnit = unit;
irUnit.imports = collector.imports;
if (collector.hasPragmaLibrary)
- irUnit.unitFlags |= QV4::CompiledData::Unit::IsSharedLibrary;
+ irUnit.jsModule.unitFlags |= QV4::CompiledData::Unit::IsSharedLibrary;
QmlIR::QmlUnitGenerator qmlGenerator;
QV4::CompiledData::ResolvedTypeReferenceMap emptyDependencies;
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/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 59faafa023..c6b778f4df 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 dcba5c2d71..0333f6b9bd 100644
--- a/src/quick/items/qquickflickable.cpp
+++ b/src/quick/items/qquickflickable.cpp
@@ -55,6 +55,8 @@
#include <QtCore/qmath.h>
#include "qplatformdefs.h"
+#include <cmath>
+
QT_BEGIN_NAMESPACE
// FlickThreshold determines how far the "mouse" must have moved
@@ -69,6 +71,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);
}
@@ -351,7 +368,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));
@@ -455,18 +472,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;
@@ -886,7 +903,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.
@@ -1234,13 +1251,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);
@@ -1549,12 +1570,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/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 84f9b0f169..4c6b0b4167 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -98,7 +98,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,
@@ -4106,7 +4107,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 f958d1a087..a54d6daf9c 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;
@@ -2199,9 +2201,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 f74a554aa9..4909f7fce8 100644
--- a/src/quick/quick.pro
+++ b/src/quick/quick.pro
@@ -33,7 +33,7 @@ include(util/util.pri)
include(scenegraph/scenegraph.pri)
include(items/items.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/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/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