diff options
Diffstat (limited to 'src')
43 files changed, 400 insertions, 731 deletions
diff --git a/src/imports/testlib/TestCase.qml b/src/imports/testlib/TestCase.qml index 9f527b66f1..039ee63f07 100644 --- a/src/imports/testlib/TestCase.qml +++ b/src/imports/testlib/TestCase.qml @@ -1271,6 +1271,9 @@ Item { qtest_results.finishTestData() qtest_runInternal("cleanup") qtest_results.finishTestDataCleanup() + // wait(0) will call processEvents() so objects marked for deletion + // in the test function will be deleted. + wait(0) } } @@ -1302,6 +1305,9 @@ Item { // Run the cleanup function. qtest_runInternal("cleanup") qtest_results.finishTestDataCleanup() + // wait(0) will call processEvents() so objects marked for deletion + // in the test function will be deleted. + wait(0) } while (!qtest_results.measurementAccepted()) qtest_results.endDataRun() } while (qtest_results.needsMoreMeasurements()) @@ -1418,9 +1424,6 @@ Item { } else { qtest_runFunction(prop, null, isBenchmark) } - // wait(0) will call processEvents() so objects marked for deletion - // in the test function will be deleted. - wait(0) qtest_results.finishTestFunction() qtest_results.skipped = false } diff --git a/src/particles/qquickimageparticle.cpp b/src/particles/qquickimageparticle.cpp index 0f6cd29a87..c0e1b4e422 100644 --- a/src/particles/qquickimageparticle.cpp +++ b/src/particles/qquickimageparticle.cpp @@ -148,8 +148,8 @@ public: program()->setUniformValue(m_timestamp_id, (float) d->timestamp); program()->setUniformValue(m_entry_id, (float) d->entry); - program()->setUniformValueArray(m_sizetable_id, (float*) d->sizeTable, UNIFORM_ARRAY_SIZE, 1); - program()->setUniformValueArray(m_opacitytable_id, (float*) d->opacityTable, UNIFORM_ARRAY_SIZE, 1); + program()->setUniformValueArray(m_sizetable_id, (const float*) d->sizeTable, UNIFORM_ARRAY_SIZE, 1); + program()->setUniformValueArray(m_opacitytable_id, (const float*) d->opacityTable, UNIFORM_ARRAY_SIZE, 1); } int m_entry_id; @@ -295,8 +295,8 @@ public: program()->setUniformValue(m_timestamp_id, (float) d->timestamp); program()->setUniformValue(m_entry_id, (float) d->entry); - program()->setUniformValueArray(m_sizetable_id, (float*) d->sizeTable, 64, 1); - program()->setUniformValueArray(m_opacitytable_id, (float*) d->opacityTable, UNIFORM_ARRAY_SIZE, 1); + program()->setUniformValueArray(m_sizetable_id, (const float*) d->sizeTable, 64, 1); + program()->setUniformValueArray(m_opacitytable_id, (const float*) d->opacityTable, UNIFORM_ARRAY_SIZE, 1); } int m_timestamp_id; @@ -1281,7 +1281,7 @@ void QQuickImageParticle::finishBuildParticleNodes(QSGNode** node) #ifdef Q_OS_LINUX // Nouveau drivers can potentially freeze a machine entirely when taking the point-sprite path. - if (perfLevel < Deformable && strstr((char *) glGetString(GL_VENDOR), "nouveau")) + if (perfLevel < Deformable && strstr((const char *) glGetString(GL_VENDOR), "nouveau")) perfLevel = Deformable; #endif diff --git a/src/qml/compiler/qv4codegen.cpp b/src/qml/compiler/qv4codegen.cpp index 27aecdd3ed..02274ca793 100644 --- a/src/qml/compiler/qv4codegen.cpp +++ b/src/qml/compiler/qv4codegen.cpp @@ -2448,7 +2448,8 @@ bool Codegen::visit(SwitchStatement *ast) IR::BasicBlock *switchend = _function->newBasicBlock(exceptionHandler()); if (ast->block) { - Result lhs = expression(ast->expression); + int lhs = _block->newTemp(); + move(_block->TEMP(lhs), *expression(ast->expression)); IR::BasicBlock *switchcond = _function->newBasicBlock(exceptionHandler()); _block->JUMP(switchcond); IR::BasicBlock *previousBlock = 0; @@ -2510,7 +2511,7 @@ bool Codegen::visit(SwitchStatement *ast) Result rhs = expression(clause->expression); IR::BasicBlock *iftrue = blockMap[clause]; IR::BasicBlock *iffalse = _function->newBasicBlock(exceptionHandler()); - setLocation(cjump(binop(IR::OpStrictEqual, *lhs, *rhs), iftrue, iffalse), clause->caseToken); + setLocation(cjump(binop(IR::OpStrictEqual, _block->TEMP(lhs), *rhs), iftrue, iffalse), clause->caseToken); _block = iffalse; } @@ -2519,7 +2520,7 @@ bool Codegen::visit(SwitchStatement *ast) Result rhs = expression(clause->expression); IR::BasicBlock *iftrue = blockMap[clause]; IR::BasicBlock *iffalse = _function->newBasicBlock(exceptionHandler()); - setLocation(cjump(binop(IR::OpStrictEqual, *lhs, *rhs), iftrue, iffalse), clause->caseToken); + setLocation(cjump(binop(IR::OpStrictEqual, _block->TEMP(lhs), *rhs), iftrue, iffalse), clause->caseToken); _block = iffalse; } diff --git a/src/qml/compiler/qv4compileddata_p.h b/src/qml/compiler/qv4compileddata_p.h index d6d43418f7..7b40fa849a 100644 --- a/src/qml/compiler/qv4compileddata_p.h +++ b/src/qml/compiler/qv4compileddata_p.h @@ -42,7 +42,7 @@ #include <private/qv4value_p.h> #include <private/qv4executableallocator_p.h> #include <private/qqmlrefcount_p.h> -#include <private/qqmlnullablevalue_p_p.h> +#include <private/qqmlnullablevalue_p.h> QT_BEGIN_NAMESPACE diff --git a/src/qml/doc/src/whatsnew.qdoc b/src/qml/doc/src/whatsnew.qdoc deleted file mode 100644 index 6abfe8c579..0000000000 --- a/src/qml/doc/src/whatsnew.qdoc +++ /dev/null @@ -1,130 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\title Qt QML Release Notes -\page qtqml-releasenotes.html - -\section1 Qt QML in Qt 5.1 - -Qt 5.1 introduces several bug fixes and new functionalities to Qt QML. This is -a summary of the new changes: -\list -\li New QQmlApplicationEngine convenience class for QML applications. -\li New Instantiatior type for generic, dynamic object creation. -\li New properties for \l {Qt::application}{Qt.application}: arguments, name, and version. -\li The 'with' statement has been deprecated and is slated for removal in a - future version of the language. -\li New \l {Qt::platform}{Qt.platform} object with an \c os property -\li New \l qmlClearTypeRegistrations() function drops all data from qmlRegisterType() calls -\li New \l qmlRegisterType() function for registering composite types. -\endlist - -\section2 New Submodule - -The \l{Qt QML Models QML Types}{Qt QML Models} is a new submodule in Qt 5.1 and -provides several QML types for handling data with models and lists. These types -replace types such as \l VisualItemModel, \l VisualDataModel, and \l VisualDataGroup. - -\list -\li \l{Qt QML Models QML Types}{Models} -\endlist - -The \l{What's New in Qt 5.1} has more information about the Qt 5.1 release. - -\section1 Qt QML in Qt 5.0 - -The \l{Qt QML} module is new in Qt 5.0. It provides the QML engine and -implements the QML language supporting infrastructure. - -(Prior to Qt 5, this functionality was provided by the \l {Qt Quick 1}{QtDeclarative} module, which -has now been replaced by the new \l {Qt QML} and \l {Qt Quick} modules. See the -\l {Porting QML Applications to Qt 5} page for more information.) - -\section2 QML Engine - -\list -\li JavaScript engine has changed to V8. -\li Various parser and compiler optimizations have been implemented, as well as a new bindings optimizer. -\li New QQmlEngine::trimComponentCache() method safely discards unused data in the engine's component cache to free memory. -\endlist - -\section2 Component and Object Creation - -\list -\li QML objects can now be created asynchronously to improve application performance. - \list - \li New QQmlIncubator and QQmlIncubationController C++ classes can be used to create objects asynchronously. - \li From QML code, this behavior can enabled by: - \list - \li Calling the new Component \l{Component::incubateObject} method - \li Passing the \c Component.Asynchronous parameter to \c Qt.createComponent() - \li Loading a \l Loader object asynchronously using the \l{Loader::}{asynchronous} property - \endlist - \endlist -\li The component returned by \c Qt.createComponent() is no longer parented to the engine. Be sure to hold a reference, or provide a parent. -\endlist - -\section2 Type System - -\list -\li New \l var property type. This is a general-purpose property type which obsoletes the \l variant type. - Properties of the \l var type may hold JavaScript references. -\li QML properties of type \l var and \l variant can now hold pixmaps. -\li Value type improvements: - \list - \li QML now supports defining properties of value type basic types within QML documents. Supported types include - QSizeF, QPointF and QRectF as \c size, \c point and \c rect respectively. - \li QColor is now a value type provided by the \c QtQuick module. The red, green, blue and alpha channels - of a \l color property can be accessed via \c r, \c g, \c b and \c a properties. - \li Factory functions for various value types have been added to the \c Qt object exposed to QML. - Some of those functions require the \c QtQuick module to be imported in order to return valid values. - See the \l {Qt Quick Release Notes} for more information about these functions. - \endlist -\li Support for sequence types QList<int>, QList<qreal>, QList<bool>, QList<QUrl>, - QList<QString> and QStringList has been improved. QObjects can define Q_PROPERTYs of - these types which can be accessed transparently from JavaScript. -\endlist - -\section2 Modules and Imports - -\list -\li Arbitrary functionality may be provided in a namespace through a singleton type. See qmlRegisterSingletonType() for more information. -\li JavaScript (.js) files may now import QML modules and other JavaScript files using the ".import" syntax. -\li Plugins may now use QQmlExtensionPlugin::baseUrl to get the directory from which the plugin is loaded. - This will be useful if the plugin needs to load QML or other assets from the same directory. -\endlist - -\section2 Other - -\list -\li QQmlExpression can now be constructed directly (and more efficiently) from a QQmlScriptString. -\li The \l {QtQml::Qt}{Qt} global object now provides an \l{QtQml::Qt::inputMethod}{inputMethod} property to access the active - text input method for an application. -\endlist - -*/ diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index a3c48fb378..0ace88b01f 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -582,6 +582,16 @@ Heap::ArrayObject *ExecutionEngine::newArrayObject(InternalClass *ic, Object *pr return object->d(); } +Heap::ArrayBuffer *ExecutionEngine::newArrayBuffer(const QByteArray &array) +{ + Scope scope(this); + Scoped<ArrayBuffer> object(scope, memoryManager->alloc<ArrayBuffer>(this, array.size())); + if (!hasException) { + memcpy(object->d()->data->data(), array.data(), array.size()); + } + return object->d(); +} + Heap::DateObject *ExecutionEngine::newDateObject(const Value &value) { diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 098510e91a..bcb74ab694 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -268,6 +268,8 @@ public: Heap::ArrayObject *newArrayObject(const QStringList &list); Heap::ArrayObject *newArrayObject(InternalClass *ic, Object *prototype); + Heap::ArrayBuffer *newArrayBuffer(const QByteArray &array); + Heap::DateObject *newDateObject(const Value &value); Heap::DateObject *newDateObject(const QDateTime &dt); diff --git a/src/qml/jsruntime/qv4global_p.h b/src/qml/jsruntime/qv4global_p.h index 9769940a77..a79f71ff64 100644 --- a/src/qml/jsruntime/qv4global_p.h +++ b/src/qml/jsruntime/qv4global_p.h @@ -34,10 +34,19 @@ #ifndef QV4GLOBAL_H #define QV4GLOBAL_H +#if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) +#define V4_BOOTSTRAP +#endif + #include <QtCore/qglobal.h> #include <QString> + +#ifdef V4_BOOTSTRAP +#include <private/qtqmldevtoolsglobal_p.h> +#else #include <qtqmlglobal.h> #include <private/qtqmlglobal_p.h> +#endif #if defined(Q_CC_MSVC) #include <float.h> @@ -59,10 +68,6 @@ inline double trunc(double d) { return d > 0 ? floor(d) : ceil(d); } #define qOffsetOf(s, m) ((size_t)((((char *)&(((s *)64)->m)) - 64))) -#if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) -#define V4_BOOTSTRAP -#endif - // Decide whether to enable or disable the JIT // White list architectures diff --git a/src/qml/jsruntime/qv4numberobject.cpp b/src/qml/jsruntime/qv4numberobject.cpp index d8c9d89369..89ff110b20 100644 --- a/src/qml/jsruntime/qv4numberobject.cpp +++ b/src/qml/jsruntime/qv4numberobject.cpp @@ -204,9 +204,15 @@ ReturnedValue NumberPrototype::method_toFixed(CallContext *ctx) str = QString::fromLatin1("NaN"); else if (qIsInf(v)) str = QString::fromLatin1(v < 0 ? "-Infinity" : "Infinity"); - else if (v < 1.e21) - str = QString::number(v, 'f', int (fdigits)); - else + else if (v < 1.e21) { + char buf[100]; + double_conversion::StringBuilder builder(buf, sizeof(buf)); + double_conversion::DoubleToStringConverter::EcmaScriptConverter().ToFixed(v, fdigits, &builder); + str = QString::fromLatin1(builder.Finalize()); + // At some point, the 3rd party double-conversion code should be moved to qtcore. + // When that's done, we can use: +// str = QString::number(v, 'f', int (fdigits)); + } else return RuntimeHelpers::stringFromNumber(ctx->engine(), v)->asReturnedValue(); return scope.engine->newString(str)->asReturnedValue(); } diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 7853b5fac6..a7e3b22cd2 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -527,6 +527,8 @@ Heap::QQmlSequence<Container>::QQmlSequence(QV4::ExecutionEngine *engine, QObjec } +namespace QV4 { + typedef QQmlSequence<QStringList> QQmlQStringList; template<> DEFINE_OBJECT_VTABLE(QQmlQStringList); @@ -546,6 +548,8 @@ typedef QQmlSequence<QList<qreal> > QQmlRealList; template<> DEFINE_OBJECT_VTABLE(QQmlRealList); +} + #define REGISTER_QML_SEQUENCE_METATYPE(unused, unused2, SequenceType, unused3) qRegisterMetaType<SequenceType>(#SequenceType); void SequencePrototype::init() { diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h index ea98adc0c8..8ed6c1459c 100644 --- a/src/qml/jsruntime/qv4value_p.h +++ b/src/qml/jsruntime/qv4value_p.h @@ -370,6 +370,9 @@ struct Q_QML_PRIVATE_EXPORT Primitive : public Value static inline Primitive fromDouble(double d); static inline Primitive fromUInt32(uint i); + using Value::toInt32; + using Value::toUInt32; + static double toInteger(double fromNumber); static int toInt32(double value); static unsigned int toUInt32(double value); diff --git a/src/qml/memory/memory.pri b/src/qml/memory/memory.pri index 194df06e85..04b7566ccc 100644 --- a/src/qml/memory/memory.pri +++ b/src/qml/memory/memory.pri @@ -6,7 +6,9 @@ SOURCES += \ $$PWD/qv4mm.cpp \ HEADERS += \ - $$PWD/qv4heap_p.h \ - $$PWD/qv4mm_p.h \ + $$PWD/qv4mm_p.h } + +HEADERS += \ + $$PWD/qv4heap_p.h diff --git a/src/qml/qml/ftw/ftw.pri b/src/qml/qml/ftw/ftw.pri index 74a922dc5e..4b109107f9 100644 --- a/src/qml/qml/ftw/ftw.pri +++ b/src/qml/qml/ftw/ftw.pri @@ -15,6 +15,7 @@ HEADERS += \ $$PWD/qflagpointer_p.h \ $$PWD/qpointervaluepair_p.h \ $$PWD/qlazilyallocated_p.h \ + $$PWD/qqmlnullablevalue_p.h \ SOURCES += \ $$PWD/qintrusivelist.cpp \ diff --git a/src/qml/qml/qqmlnullablevalue_p_p.h b/src/qml/qml/ftw/qqmlnullablevalue_p.h index 202c2b79d7..202c2b79d7 100644 --- a/src/qml/qml/qqmlnullablevalue_p_p.h +++ b/src/qml/qml/ftw/qqmlnullablevalue_p.h diff --git a/src/qml/qml/ftw/qqmlpool_p.h b/src/qml/qml/ftw/qqmlpool_p.h index 31d7082cf3..4956cd81d8 100644 --- a/src/qml/qml/ftw/qqmlpool_p.h +++ b/src/qml/qml/ftw/qqmlpool_p.h @@ -45,7 +45,7 @@ // We mean it. // -#include <private/qtqmlglobal_p.h> +#include <private/qv4global_p.h> #include <QtCore/qstring.h> #include <QtCore/qurl.h> diff --git a/src/qml/qml/ftw/qqmlrefcount_p.h b/src/qml/qml/ftw/qqmlrefcount_p.h index 8a268807d7..59ed77b580 100644 --- a/src/qml/qml/ftw/qqmlrefcount_p.h +++ b/src/qml/qml/ftw/qqmlrefcount_p.h @@ -47,7 +47,7 @@ #include <QtCore/qglobal.h> #include <QtCore/qatomic.h> -#include <private/qtqmlglobal_p.h> +#include <private/qv4global_p.h> QT_BEGIN_NAMESPACE diff --git a/src/qml/qml/qml.pri b/src/qml/qml/qml.pri index cad839ba9d..e733bcec05 100644 --- a/src/qml/qml/qml.pri +++ b/src/qml/qml/qml.pri @@ -1,12 +1,4 @@ SOURCES += \ - $$PWD/qqmldirparser.cpp \ - -HEADERS += \ - $$PWD/qqmldirparser_p.h \ - -!qmldevtools_build { - -SOURCES += \ $$PWD/qqmlopenmetaobject.cpp \ $$PWD/qqmlvmemetaobject.cpp \ $$PWD/qqmlengine.cpp \ @@ -59,7 +51,8 @@ SOURCES += \ $$PWD/qqmlvaluetypewrapper.cpp \ $$PWD/qqmltypewrapper.cpp \ $$PWD/qqmlfileselector.cpp \ - $$PWD/qqmlobjectcreator.cpp + $$PWD/qqmlobjectcreator.cpp \ + $$PWD/qqmldirparser.cpp HEADERS += \ $$PWD/qqmlglobal_p.h \ @@ -111,7 +104,6 @@ HEADERS += \ $$PWD/qqmlextensioninterface.h \ $$PWD/qqmlimport_p.h \ $$PWD/qqmlextensionplugin.h \ - $$PWD/qqmlnullablevalue_p_p.h \ $$PWD/qqmlscriptstring_p.h \ $$PWD/qqmllocale_p.h \ $$PWD/qqmlcomponentattached_p.h \ @@ -133,9 +125,8 @@ HEADERS += \ $$PWD/qqmltypewrapper_p.h \ $$PWD/qqmlfileselector_p.h \ $$PWD/qqmlfileselector.h \ - $$PWD/qqmlobjectcreator_p.h + $$PWD/qqmlobjectcreator_p.h \ + $$PWD/qqmldirparser_p.h include(ftw/ftw.pri) include(v8/v8.pri) - -} diff --git a/src/qml/qml/qqmldirparser.cpp b/src/qml/qml/qqmldirparser.cpp index 2c126a996d..7f6310d58e 100644 --- a/src/qml/qml/qqmldirparser.cpp +++ b/src/qml/qml/qqmldirparser.cpp @@ -294,17 +294,6 @@ bool QQmlDirParser::hasError() const return false; } -#if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) -QList<QQmlJS::DiagnosticMessage> QQmlDirParser::errors(const QString &uri) const -{ - QList<QQmlJS::DiagnosticMessage> errors = _errors; - for (int i = 0; i < errors.size(); ++i) { - QQmlJS::DiagnosticMessage &msg = errors[i]; - msg.message.replace(QLatin1String("$$URI$$"), uri); - } - return errors; -} -#else void QQmlDirParser::setError(const QQmlError &e) { _errors.clear(); @@ -328,7 +317,6 @@ QList<QQmlError> QQmlDirParser::errors(const QString &uri) const } return errors; } -#endif QString QQmlDirParser::typeNamespace() const { diff --git a/src/qml/qml/qqmldirparser_p.h b/src/qml/qml/qqmldirparser_p.h index 0486187a5c..c2f47f49b6 100644 --- a/src/qml/qml/qqmldirparser_p.h +++ b/src/qml/qml/qqmldirparser_p.h @@ -49,7 +49,7 @@ #include <QtCore/QHash> #include <QtCore/QDebug> #include <private/qqmljsengine_p.h> -#include <private/qtqmlglobal_p.h> +#include <private/qv4global_p.h> QT_BEGIN_NAMESPACE @@ -66,12 +66,8 @@ public: bool parse(const QString &source); bool hasError() const; -#if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) - QList<QQmlJS::DiagnosticMessage> errors(const QString &uri) const; -#else void setError(const QQmlError &); QList<QQmlError> errors(const QString &uri) const; -#endif QString typeNamespace() const; void setTypeNamespace(const QString &s); diff --git a/src/qml/qml/qqmlvaluetype.cpp b/src/qml/qml/qqmlvaluetype.cpp index d3142af75e..2b3f78b676 100644 --- a/src/qml/qml/qqmlvaluetype.cpp +++ b/src/qml/qml/qqmlvaluetype.cpp @@ -58,30 +58,6 @@ struct QQmlValueTypeFactoryImpl QMutex mutex; }; - -namespace { -// This should be removed once the QPersistentModelIndex as built-in type is merged in qtbase -#if QT_VERSION >= QT_VERSION_CHECK(5, 7, 0) -#error Please, someone remove this. QPersistentModelIndex should be a built-in meta-type by now. -#else -template <typename T, bool builtin = QMetaTypeId2<T>::IsBuiltIn> -struct QPMIConvertersRegistrer { - void registerConverters() - { - } -}; - -template <typename T> struct QPMIConvertersRegistrer<T, false> { - void registerConverters() - { - qRegisterMetaType<QPersistentModelIndex>(); - QMetaType::registerConverter<QModelIndex, QPersistentModelIndex>(&QQmlModelIndexValueType::toPersistentModelIndex); - QMetaType::registerConverter<QPersistentModelIndex, QModelIndex>(&QQmlPersistentModelIndexValueType::toModelIndex); - } -}; -#endif -} - QQmlValueTypeFactoryImpl::QQmlValueTypeFactoryImpl() { for (unsigned int ii = 0; ii < QVariant::UserType; ++ii) @@ -91,9 +67,6 @@ QQmlValueTypeFactoryImpl::QQmlValueTypeFactoryImpl() qRegisterMetaType<QModelIndexList>(); qRegisterMetaType<QItemSelectionRange>(); qRegisterMetaType<QItemSelection>(); - - QPMIConvertersRegistrer<QPersistentModelIndex> conv; - conv.registerConverters(); } QQmlValueTypeFactoryImpl::~QQmlValueTypeFactoryImpl() @@ -136,15 +109,15 @@ const QMetaObject *QQmlValueTypeFactoryImpl::metaObjectForMetaType(int t) return &QQmlEasingValueType::staticMetaObject; case QVariant::ModelIndex: return &QQmlModelIndexValueType::staticMetaObject; + case QVariant::PersistentModelIndex: + return &QQmlPersistentModelIndexValueType::staticMetaObject; default: if (const QMetaObject *mo = QQml_valueTypeProvider()->metaObjectForMetaType(t)) return mo; break; } - if (t == qMetaTypeId<QPersistentModelIndex>()) - return &QQmlPersistentModelIndexValueType::staticMetaObject; - else if (t == qMetaTypeId<QModelIndexList>()) + if (t == qMetaTypeId<QModelIndexList>()) return &QQmlModelIndexListValueType::staticMetaObject; else if (t == qMetaTypeId<QItemSelectionRange>()) return &QQmlItemSelectionRangeValueType::staticMetaObject; diff --git a/src/qml/qml/qqmlvaluetype_p.h b/src/qml/qml/qqmlvaluetype_p.h index 0d896364e1..f534fedf5d 100644 --- a/src/qml/qml/qqmlvaluetype_p.h +++ b/src/qml/qml/qqmlvaluetype_p.h @@ -48,7 +48,7 @@ #include "qqml.h" #include "qqmlproperty.h" #include "qqmlproperty_p.h" -#include "qqmlnullablevalue_p_p.h" +#include <private/qqmlnullablevalue_p.h> #include <QtCore/qobject.h> #include <QtCore/qrect.h> diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index afa79ee6b1..a2c5f09061 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -59,6 +59,7 @@ #include <private/qv4objectproto_p.h> #include <private/qv4scopedvalue_p.h> +#include <private/qv4arraybuffer_p.h> using namespace QV4; @@ -1022,6 +1023,9 @@ public: QString responseBody(); const QByteArray & rawResponseBody() const; bool receivedXml() const; + + const QString & responseType() const; + void setResponseType(const QString &); private slots: void readyRead(); void error(QNetworkReply::NetworkError); @@ -1070,12 +1074,15 @@ private: QNetworkAccessManager *m_nam; QNetworkAccessManager *networkAccessManager() { return m_nam; } + + QString m_responseType; }; QQmlXMLHttpRequest::QQmlXMLHttpRequest(ExecutionEngine *engine, QNetworkAccessManager *manager) : v4(engine) , m_state(Unsent), m_errorFlag(false), m_sendFlag(false) , m_redirectCount(0), m_gotXml(false), m_textCodec(0), m_network(0), m_nam(manager) + , m_responseType() { } @@ -1461,6 +1468,16 @@ bool QQmlXMLHttpRequest::receivedXml() const return m_gotXml; } +const QString & QQmlXMLHttpRequest::responseType() const +{ + return m_responseType; +} + +void QQmlXMLHttpRequest::setResponseType(const QString &responseType) +{ + m_responseType = responseType; +} + #ifndef QT_NO_TEXTCODEC QTextCodec* QQmlXMLHttpRequest::findTextCodec() const @@ -1640,6 +1657,9 @@ struct QQmlXMLHttpRequestCtor : public FunctionObject static ReturnedValue method_get_statusText(CallContext *ctx); static ReturnedValue method_get_responseText(CallContext *ctx); static ReturnedValue method_get_responseXML(CallContext *ctx); + static ReturnedValue method_get_response(CallContext *ctx); + static ReturnedValue method_get_responseType(CallContext *ctx); + static ReturnedValue method_set_responseType(CallContext *ctx); }; } @@ -1686,6 +1706,10 @@ void QQmlXMLHttpRequestCtor::setupProto() p->defineAccessorProperty(QStringLiteral("statusText"),method_get_statusText, 0); p->defineAccessorProperty(QStringLiteral("responseText"),method_get_responseText, 0); p->defineAccessorProperty(QStringLiteral("responseXML"),method_get_responseXML, 0); + p->defineAccessorProperty(QStringLiteral("response"),method_get_response, 0); + + // Read-write properties + p->defineAccessorProperty(QStringLiteral("responseType"), method_get_responseType, method_set_responseType); // State values p->defineReadonlyProperty(QStringLiteral("UNSENT"), Primitive::fromInt32(0)); @@ -1945,6 +1969,58 @@ ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseXML(CallContext *ctx) } } +ReturnedValue QQmlXMLHttpRequestCtor::method_get_response(CallContext *ctx) +{ + Scope scope(ctx); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); + if (!w) + V4THROW_REFERENCE("Not an XMLHttpRequest object"); + QQmlXMLHttpRequest *r = w->d()->request; + + if (r->readyState() != QQmlXMLHttpRequest::Loading && + r->readyState() != QQmlXMLHttpRequest::Done) + return QV4::Encode(scope.engine->newString(QString())); + + const QString& responseType = r->responseType(); + if (responseType.compare(QLatin1String("text"), Qt::CaseInsensitive) == 0) { + return QV4::Encode(scope.engine->newString(r->responseBody())); + } else if (responseType.compare(QLatin1String("arraybuffer"), Qt::CaseInsensitive) == 0) { + return QV4::Encode(scope.engine->newArrayBuffer(r->rawResponseBody())); + } else { + return QV4::Encode(scope.engine->newString(QString())); + } + + return Encode::undefined(); +} + + +ReturnedValue QQmlXMLHttpRequestCtor::method_get_responseType(CallContext *ctx) +{ + Scope scope(ctx); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); + if (!w) + V4THROW_REFERENCE("Not an XMLHttpRequest object"); + QQmlXMLHttpRequest *r = w->d()->request; + return QV4::Encode(scope.engine->newString(r->responseType())); +} + +ReturnedValue QQmlXMLHttpRequestCtor::method_set_responseType(CallContext *ctx) +{ + Scope scope(ctx); + Scoped<QQmlXMLHttpRequestWrapper> w(scope, ctx->thisObject().as<QQmlXMLHttpRequestWrapper>()); + if (!w) + V4THROW_REFERENCE("Not an XMLHttpRequest object"); + QQmlXMLHttpRequest *r = w->d()->request; + + if (ctx->argc() < 1) + V4THROW_DOM(DOMEXCEPTION_SYNTAX_ERR, "Incorrect argument count"); + + // Argument 0 - response type + r->setResponseType(ctx->args()[0].toQStringNoThrow()); + + return Encode::undefined(); +} + void qt_rem_qmlxmlhttprequest(ExecutionEngine * /* engine */, void *d) { QQmlXMLHttpRequestData *data = (QQmlXMLHttpRequestData *)d; diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp index 8e5cbb8e96..0522e4c0ed 100644 --- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp +++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp @@ -1483,7 +1483,7 @@ QV4::ReturnedValue ConsoleObject::method_time(CallContext *ctx) QV4::ReturnedValue ConsoleObject::method_timeEnd(CallContext *ctx) { if (ctx->argc() != 1) - V4THROW_ERROR("console.time(): Invalid arguments"); + V4THROW_ERROR("console.timeEnd(): Invalid arguments"); QV8Engine *v8engine = ctx->d()->engine->v8Engine; diff --git a/src/qml/types/qqmlbind.cpp b/src/qml/types/qqmlbind.cpp index 8e28439804..7814fa6d56 100644 --- a/src/qml/types/qqmlbind.cpp +++ b/src/qml/types/qqmlbind.cpp @@ -33,7 +33,7 @@ #include "qqmlbind_p.h" -#include <private/qqmlnullablevalue_p_p.h> +#include <private/qqmlnullablevalue_p.h> #include <private/qqmlproperty_p.h> #include <private/qqmlbinding_p.h> diff --git a/src/qmldevtools/qmldevtools.pro b/src/qmldevtools/qmldevtools.pro index 5af5443df7..85f21ce6f6 100644 --- a/src/qmldevtools/qmldevtools.pro +++ b/src/qmldevtools/qmldevtools.pro @@ -1,14 +1,11 @@ option(host_build) TARGET = QtQmlDevTools QT = core -CONFIG += static no_module_headers internal_module qmldevtools_build +CONFIG += static internal_module qmldevtools_build -MODULE_INCLUDES = \ - \$\$QT_MODULE_INCLUDE_BASE \ - \$\$QT_MODULE_INCLUDE_BASE/QtQml -MODULE_PRIVATE_INCLUDES = \ - \$\$QT_MODULE_INCLUDE_BASE/QtQml/$$QT.qml.VERSION \ - \$\$QT_MODULE_INCLUDE_BASE/QtQml/$$QT.qml.VERSION/QtQml +# Don't use pch because the auto-generated header refers to QtBootstrap, +# which doesn't exist +CONFIG -= precompile_header # 2415: variable "xx" of static storage duration was declared but never referenced # unused variable 'xx' [-Werror,-Wunused-const-variable] @@ -22,4 +19,4 @@ include(../3rdparty/masm/masm-defs.pri) include(../qml/parser/parser.pri) include(../qml/jsruntime/jsruntime.pri) include(../qml/compiler/compiler.pri) -include(../qml/qml/qml.pri) +include(../qml/memory/memory.pri) diff --git a/src/qmldevtools/qtqmldevtoolsglobal_p.h b/src/qmldevtools/qtqmldevtoolsglobal_p.h new file mode 100644 index 0000000000..fa8731deb6 --- /dev/null +++ b/src/qmldevtools/qtqmldevtoolsglobal_p.h @@ -0,0 +1,69 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL21$ +** 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 http://www.qt.io/terms-conditions. For further +** information use the contact form at http://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 2.1 or version 3 as published by the Free +** Software Foundation and appearing in the file LICENSE.LGPLv21 and +** LICENSE.LGPLv3 included in the packaging of this file. Please review the +** following information to ensure the GNU Lesser General Public License +** requirements will be met: https://www.gnu.org/licenses/lgpl.html and +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** As a special exception, The Qt Company gives you certain additional +** rights. These rights are described in The Qt Company LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QTQMLGLOBAL_P_H +#define QTQMLGLOBAL_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 + +#ifndef QT_STATIC +# if defined(QT_BUILD_QML_LIB) +# define Q_QML_EXPORT Q_DECL_EXPORT +# else +# define Q_QML_EXPORT Q_DECL_IMPORT +# endif +#else +# define Q_QML_EXPORT +#endif + +#if defined(QT_BUILD_QMLDEVTOOLS_LIB) || defined(QT_QMLDEVTOOLS_LIB) +# define Q_QML_PRIVATE_EXPORT +#else +# define Q_QML_PRIVATE_EXPORT Q_QML_EXPORT +#endif + +QT_END_NAMESPACE +#endif // QTQMLGLOBAL_P_H diff --git a/src/quick/doc/src/qtquick.qdoc b/src/quick/doc/src/qtquick.qdoc index 8d5680a1e3..98a77a48d8 100644 --- a/src/quick/doc/src/qtquick.qdoc +++ b/src/quick/doc/src/qtquick.qdoc @@ -42,9 +42,8 @@ The Qt Quick module provides both a \l{Qt Quick QML Types}{QML API} which suppli QML types for creating user interfaces with the QML language, and a \l{Qt Quick C++ Classes}{C++ API} for extending QML applications with C++ code. -\note From Qt 5.1, a set of Qt Quick based UI controls is available to -create user interfaces. Please see \l{Qt Quick Controls} -for more information. +\note A set of Qt Quick-based UI controls is also available to create user +interfaces. See \l{Qt Quick Controls} for more information. For those new to QML and Qt Quick, please see \l{QML Applications} @@ -108,7 +107,6 @@ Additional Qt Quick information: interacting with system dialogs \li \l{Qt Quick Test QML Types}{Tests} - contains types for writing unit test for a QML application \endlist -\li \l{Qt Quick Release Notes} - list of changes and additions in the Qt Quick \li \l{Qt Quick Examples and Tutorials} \endlist diff --git a/src/quick/doc/src/whatsnew.qdoc b/src/quick/doc/src/whatsnew.qdoc deleted file mode 100644 index b0a39e1dd3..0000000000 --- a/src/quick/doc/src/whatsnew.qdoc +++ /dev/null @@ -1,452 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2015 The Qt Company Ltd. -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the documentation of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:FDL$ -** 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 http://www.qt.io/terms-conditions. For further -** information use the contact form at http://www.qt.io/contact-us. -** -** GNU Free Documentation License Usage -** Alternatively, this file may be used under the terms of the GNU Free -** Documentation License version 1.3 as published by the Free Software -** Foundation and appearing in the file included in the packaging of -** this file. Please review the following information to ensure -** the GNU Free Documentation License version 1.3 requirements -** will be met: http://www.gnu.org/copyleft/fdl.html. -** $QT_END_LICENSE$ -** -****************************************************************************/ - -/*! -\title Qt Quick Release Notes -\page qtquick-releasenotes.html - -\section1 Qt Quick in Qt 5.1 - -\l{Qt Quick} 2.1 is new in Qt 5.1. This is a summary of improvements and new -features introduced by the new import and new classes in Qt 5.1: -\list -\li New threaded render loop for Mac, Linux, and Embedded. -\li New render loop for windows for smoother animations. -\li New \l Window properties: activeFocusItem, minimumWidth, minimumHeight, - maximumWidth, maximumHeight, visibility, contentOrientation, and opacity. -\li New \l Screen attached properties: name, desktopAvailableWidth, - desktopAvailableHeight, logicalPixelDensity -\li New \l Grid properties: horizontalAlignment, verticalAlignment, and - effectiveHorizontalAlignment. -\li New \l TextEdit properties: selectByKeyboard and textDocument -\li A \l Window declared inside another Window or \l Item will automatically be - transient for (centered upon) the outer window. -\li These types are now part of \l{Qt QML}: - \list - \li \l {VisualItemModel} - \li \l {VisualDataModel} - Encapsulates a model and a delegate - \li \l {VisualDataGroup} - \endlist - These types are kept due to compatibility reasons and are replaced by the - \l{Qt QML Models QML Types}{Qt QML Models} types. -\endlist - -\section2 New Submodules - -In Qt 5.1, there are several new modules which extend Qt Quick functionalities. -\list -\li \l{Qt Quick Dialogs} - contains types for creating and interacting with system dialogs -\li \l{Qt Quick Controls} - provides a set of reusable UI components -\li \l{Qt Quick Layouts} - contains types that are used to arrange items in the user interface -\endlist - -The \l{What's New in Qt 5.1} has more information about the Qt 5.1 release. - -\section1 Qt Quick in Qt 5.0 - -The \l {Qt Quick} module is new in Qt 5. It provides the visual canvas and scenegraph back-end -as well as the \c QtQuick QML module for QML application development. - -As of Qt 5, the \l {Qt Quick} module is based on an OpenGL scenegraph. Many of the classes in -the \l {Qt Quick} module have been ported from the \l {Qt Quick 1}{QtDeclarative} module from Qt 4.8 to use -the scenegraph architecture; these classes have been renamed to use a \c QQuick* prefix. -(See the \l {Porting QML Applications to Qt 5} for porting information.) - -The following classes provide the basic functionality for interacting with the QML visual -canvas from C++: - -\list -\li QQuickItem - the base visual QML type (replaces \c QDeclarativeItem) -\li QQuickView - a convenience window for rendering a QML scene from a QML file (replaces \c QDeclarativeView) -\li QQuickWindow - a base window for displaying a QML scene -\li QQuickPaintedItem - convenience for using the QPainter API with the scenegraph -\li QQuickImageProvider - fetches custom images for use in QML applications (replaces \c - QDeclarativeImageProvider) -\li QQuickTextureFactory - use with QQuickImageProvider::requestTexture() -\endlist - -Custom rendering can be performed on the scenegraph using the following new classes: - -\list -\li QSGNode -\li QSGMaterial -\li QSGBasicGeometryNode -\li QSGGeometryNode -\li QSGClipNode -\li QSGTransformNode -\li QSGOpacityNode -\li QSGFlatColorMaterial -\li QSGSimpleRectNode -\li QSGSimpleTextureNode -\li QSGTexture -\li QSGDynamicTexture -\li QSGOpaqueTextureMaterial -\li QSGTextureMaterial -\li QSGTextureProvider -\li QSGVertexColorMaterial -\endlist - - -\section1 Qt 5.0 - QtQuick QML Module - -The \c {QtQuick 2.0} QML module is a major update. - -Below are the additions in \c {QtQuick 2.0}. For a list of behavioral changes which may affect -applications ported from \c {QtQuick 1.x}, see the \l {Porting QML Applications to Qt 5}. - -\section2 Visual types, Graphical Effects and Sprites - -\list -\li New \l Canvas type for drawing. This provides an API similar to that of the HTML5 Canvas API, - along with some additional features. - \list - \li Supports two render targets: \c Canvas.Image and \c Canvas.FramebufferObject. - \li Supports background thread rendering. - \li Supports tiled canvas rendering. - \li Supports most of the HTML5 context2d APIs. - \endlist -\li \l Item: - \list - \li New \l{Item::}{layer.enabled} property enables an item to be rendered into an offscreen - cache for optimization. - \li New \l{Item::}{contains()} method returns whether an item contains a specified point. - \li New \l{Item::}{anchors.alignWhenCentered} property can force centered anchors to align on a - whole pixel. - \li New \l{Item::}{enabled} property is available, which stops input event delivery and removes active focus. - \endlist -\li \l Image: - \list - \li New \l{Image::}{horizontalAlignment} and \l{Image::}{verticalAlignment} properties to set - the image alignment. - \li New \c Image.Pad enumeration value for \l{Image::}{fillMode} that does not transform the image, - unlike other \l{Image::}{fillMode} enumeration values. - \endlist -\li New ShaderEffect and ShaderEffectSource types enable GLSL shader programs to be integrated - directly into QML code and applied to QML items and images. (This obsoletes the experimental - Qt.labs.shaders module.) -\li New SpriteSequence type renders animated sprites and can transition between animations. Each - animation in a sequence is represented by the new \l Sprite type. -\li New AnimatedSprite type for drawing single sprite animations. -\endlist - - -\section2 Animations and Transitions -\list -\li New AnimationController type enables an animation to be manually driven by a - \l{AnimationController::}{progress} value. -\li New PathAnimation type animates an item along a \l Path. -\li New PathInterpolator type provides updated attribute values for an item animating along a path. - It can be used as an low-level alternative to PathAnimation. -\li \l Transition: - \list - \li New \l{Transition::}{running} property holds whether a transition is currently running. - \li New \l{Transition::}{enabled} property controls whether a transition is enabled. - \endlist -\endlist - - -\section2 Paths -\list -\li New PathArc type creates an arc-type path. -\li New PathCurve type creates a catmull-rom curve path. -\li New PathSvg type creates a path from a SVG string. -\li Changes common to PathLine, PathQuad and PathCubic: - \list - \li New \c relativeX and \c relativeY properties define the start and end points of a path -relative to its start. - \endlist -\li PathCubic only: - \list - \li New \l{PathCubic::}{relativeControl1X}, \l{PathCubic::}{relativeControl1Y}, - \l{PathCubic::}{relativeControl2X} and \l{PathCubic::}{relativeControl2Y} properties define the - positions of the control points relative to the start of the curve. - \endlist -\li PathQuad only: - \list - \li New \l{PathQuad::}{relativeControlX} and \l{PathQuad::}{relativeControlY} - define the positions of the control points relative to the start of the curve. - \endlist -\endlist - - -\section2 Text Rendering and Input - -\list -\li Changes common to \l Text, TextEdit and TextInput: - \list - \li New \c contentWidth and \c contentHeight properties provide the dimensions of the textual - content. - \li New \c effectiveHorizontalAlignment property provides the read-only actual horizontal - alignment. - \endlist -\li Changes common to both TextEdit and TextInput: - \list - \li New \c canUndo and \c canRedo properties specify whether undo and redo operations are - available. - \li New \c getText() method returns the text located between specified start and end indexes. - Additionally TextEdit has a \l{TextEdit::}{getFormattedText()} method that returns the formatted - text. - \endlist -\li \l Text only: - \list - \li \c Text.RightElide is now supported where text spans multiple lines. - \li New \l{Text::}{linkColor} property controls the color of linked text. - \li New \l{Text::}{lineLaidOut} signal is emitted for every line during the layout process to - give the option of positioning and/or resizing lines as they are laid out. - \li New \l{Text::}{doLayout()} method will trigger the text layout from Javascript. - \li New \l{Text::}{fontSizeMode} property allows text to be fitted to the item size. - \li New \l{Text::}{minimumPixelSize} and \l {Text::}{minimumPointSize} properties can be used to - specify a lower bound when auto-fitting. - \endlist -\li TextEdit only: - \list - \li New \l{TextEdit::}{baseUrl} property specified the base URL used to resolve relative URLs - within the text. - \endlist -\li TextInput only: - \list - \li New \l{TextInput::}{wrapMode} property sets the text wrapping mode. - \li New \l{TextInput::}{horizontalAlignment} and \l{TextInput::}{verticalAlignment} properties. - \li New \l{TextInput::}{length} property provides the total number of text characters. - \li New \l{TextInput::}{persistentSelection} property enables the text selection to persist when -the window loses focus. - \li \l{TextInput::}{positionAt()} method now takes a y parameter. - \endlist -\endlist - -\section2 User Input - -\list -\li New MultiPointTouchArea type processes multi-point touches and provides information on touch - points including position, pressure and velocity. Touch point data is provided by the new \l - TouchPoint type. -\li New DropArea type provides more advanced drag and drop functionality. -\li MouseArea: - \list - \li Wheel events are now supported; events are provided through the new WheelEvent type. - \li New \l{MouseArea::}{propagateComposedEvents} property sets whether composed events are - propagated to other mouse areas. If this property is true and the handlers of the - \l{MouseArea::}{clicked}, \l{MouseArea::}{doubleClicked} or \l{MouseArea::}{pressAndHold} - signals reject a mouse event, the event will be propagated to overlapping MouseArea items - in the same area that are lower in the stacking order. - \li New \l{MouseArea::}{cursorShape} property controls the cursor shape. - \endlist -\endlist - -\section2 Specialized Containers - -\list -\li Flickable: - \list - \li New \l{Flickable::}{rebound} property specifies the transition to be applied when a - flickable snaps back to its bounds. - \li New \l{Flickable::}{topMargin}, \l{Flickable::}{bottomMargin}, \l{Flickable::}{leftMargin}, - \l{Flickable::}{rightMargin} allow extra margin space to be specified for a flickable. This can be - used, for example, to implement pull-to-refresh functionality for a list. - \li New \l{Flickable::}{originX} and \l{Flickable::}{originY} properties provide the top left - position of the content item. - \li New \l{Flickable::}{dragging}, \l{Flickable::}{draggingHorizontally} and - \l{Flickable::}{draggingVertically} properties provide information on whether a flickable is - currently being dragged. - \li New \l{Flickable::}{flick()} method flicks the view with a specific velocity. - \li New \l{Flickable::}{cancelFlick()} method stops any current flicking movement. - \endlist -\endlist - -\section2 Positioners (Row, Column, Grid, Flow types): - -\list -\li Changes common to \l Row, \l Column, \l Grid and \l Flow: - \list - \li The \c add and \c move transitions can access a new ViewTransition attached property (see - the ViewTransition documentation for examples) and can now animate arbitrary item properties - (instead of being restricted to animating an item's position). - \li New \c effectiveLayoutDirection property provides the read-only actual layout direction of a - positioner. - \li New \l Positioner type provides \c index, \c isFirstItem and \c isLastItem attached - properties for items within positioners. - \li All \c spacing properties on positioners now use real numbers instead of integers. - \endlist -\li Grid only: - \list - \li New \l{Grid::}{rowSpacing} and \l{Grid::}{columnSpacing} properties. - \endlist -\endlist - -\section2 Models and Views - -\list -\li Any delegate of a view that uses a QAbstractItemModel-derived model type can use the syntax - \c {model.<role> = <newDataValue>} to modify the data for a particular role. (Previously, - the \c {model.<role>} syntax was only available for reading, not writing to, a role value.) -\li ListModel: - \list - \li By default, roles can no longer change type during a model's lifetime. The new - \l{ListModel::}{dynamicRoles} property can be set to restore the original (less performant) - behavior. - \endlist -\li VisualDataModel: - \list - \li Now has features to filter the items to be displayed in a view. This is supported by the new - \l {DelegateModel::}{groups}, \l {DelegateModel::}{filterOnGroup}, \l {DelegateModel::}{items} - and \l {DelegateModel::}{persistedItems} properties. - \endlist -\li Changes common to both ListView and GridView: - \list - \li New transition support for animating the adding, removing and moving of items in a ListView - or GridView. See the ViewTransition documentation for details. - \li New \c verticalLayoutDirection property enables items to be laid out from bottom-to-top - using the new \c BottomToTop enumeration value. - \li New \c headerItem and \c footerItem properties provide access to the instantiated header and - footer items. - \li The \c cacheBuffer property now has a non-zero default. - \li Delegates in the cache buffer are now created asynchronously. - \li Setting a \c RightToLeft layout now also reverses the \c preferredHighlightBegin and \c - preferredHighlightEnd. - \li If the model is changed after the component is completed, currentIndex is reset to 0. - \endlist -\li ListView only: - \list - \li New \l{ListView::}{section.labelPositioning} property can fix the current section label to - the start of the view, and the next section label to the end of the view, to prevent labels from - scrolling while section items are still in view. - \li \c highlightMoveSpeed and \c highlightResizeSpeed have been renamed to - \l{ListView::}{highlightMoveVelocity} and \l{ListView::}{highlightResizeVelocity}. - \endlist -\li GridView only: - \list - \li \l{GridView::}{cellWidth} and \l{GridView::}{cellHeight} now use real numbers instead of - integers. - \endlist -\li PathView: - \list - \li New \l{PathView::}{currentItem} property holds the current item in the view. - \li New \l{PathView::}{maximumFlickVelocity} property controls the maximum flick velocity of the - view. - \li New \l{PathView::}{snapMode} property controls the snap model when flicking between items - \li If the model is changed after the component is completed, the offset and currentIndex are - reset to 0. - \li New \l{PathView::}{positionViewAtIndex()} function allows the view to be moved to display - the specified index. - \li New \l{PathView::}{indexAt()} and \l{PathView::}{itemAt()} functions return the index or - item at a specified point in the view. - \endlist -\endlist - -\section2 Utility types - -\list -\li New \l Accessible attached property for implementing accessibility features in QML applications. -\li \l Loader: - \list - \li New \l{Loader::}{asynchronous} property allows components to be instantiated with lower - chance of blocking. If source is used with \e {asynchronous: true} the component will be compiled in - a background thread. - \li New \l{Loader::}{active} property can delay instantiation of a \l Loader object's - \l{Loader::}{item}. - \li New \l{Loader::}{setSource()} method loads an object with specific initial property values, - similar to \l Component::createObject(). - \endlist -\li \l Binding: - \list - \li This type can now be used as a value source, and will also restore any previously set - binding when its \l{Binding::}{when} clause becomes false. - \endlist -\endlist - -\section2 Property types - -Support for various math and geometry-related value types, including QVector2D, QVector3D, QVector4D, -QMatrix4x4 and QQuaternion, as well as QColor and QFont, are now provided by \l {Qt Quick}. Properties of -these types can be declared in QML documents via the property syntax where the type name is \c vector2d, -\c vector3d, \c vector4d, \c matrix4x4, \c quaternion, \c color and \c font respectively. - -\l {Qt Quick} also provides implementation for the various value type factory or utility functions of the -\c Qt object which return or operate on values of the above types. The functions are: -\table - \header - \li Value type - \li Functions - - \row - \li color - \li Qt.rgba(), Qt.hsla(), Qt.tint(), Qt.lighter(), Qt.darker(), Qt.colorEqual() - - \row - \li font - \li Qt.font(), Qt.fontFamilies() - - \row - \li vector2d - \li Qt.vector2d() - - \row - \li vector3d - \li Qt.vector3d() - - \row - \li vector4d - \li Qt.vector4d() - - \row - \li matrix4x4 - \li Qt.matrix4x4() - - \row - \li quaternion - \li Qt.quaternion() -\endtable - -The \c Qt.rgba(), \c Qt.hsla(), \c Qt.tint(), \c Qt.lighter(), \c Qt.darker() -and \c Qt.fontFamilies() functions already existed in \l {Qt Quick 1}{QtDeclarative} prior -to \l {Qt Quick}{Qt Quick 2}; the other functions are all new in \l {Qt Quick}{Qt Quick 2}. - -\section1 Qt 5.0 - Additional QML Modules - -\section2 QtQuick.Particles - -This new module provides particle system support for creating a variety of 2D particle systems. See -the \l QtQuick.Particles documentation for comprehensive details. - -This obsoletes the experimental \c Qt.labs.particles module. - -\section2 QtQuick.Window - -This new module contains the \l Window type for creating a basic window and the \l Screen type for -accessing a screen's resolution and other details. See the \l QtQuick.Window -documentation for comprehensive details. - -\section2 QtQuick.XmlListModel - -This new module contains XmlListModel and associated types, which were previously in the \c QtQuick -module. See the \l QtQuick.XmlListModel documentation for details. - -\section2 QtQuick.LocalStorage - -This new module provides access to the SQL Local Storage API that was previously accessible from the -\l {QML Global Object}. See the \l QtQuick.LocalStorage documentation for details. -*/ diff --git a/src/quick/items/qquickanimatedimage.cpp b/src/quick/items/qquickanimatedimage.cpp index a989e81176..49fef12467 100644 --- a/src/quick/items/qquickanimatedimage.cpp +++ b/src/quick/items/qquickanimatedimage.cpp @@ -104,7 +104,13 @@ QQuickPixmap* QQuickAnimatedImagePrivate::infoForCurrentFrame(QQmlEngine *engine about its state, such as the current frame and total number of frames. The result is an animated image with a simple progress indicator underneath it. - \b Note: Unlike images, animated images are not cached or shared internally. + \b Note: When animated images are cached, every frame of the animation will be cached. + + Set cache to false if you are playing a long or large animation and you + want to conserve memory. + + If the image data comes from a sequential device (e.g. a socket), + AnimatedImage can only loop if cache is set to true. \clearfloat \snippet qml/animatedimage.qml document @@ -126,6 +132,7 @@ QQuickPixmap* QQuickAnimatedImagePrivate::infoForCurrentFrame(QQmlEngine *engine QQuickAnimatedImage::QQuickAnimatedImage(QQuickItem *parent) : QQuickImage(*(new QQuickAnimatedImagePrivate), parent) { + QObject::connect(this, &QQuickImageBase::cacheChanged, this, &QQuickAnimatedImage::onCacheChanged); } QQuickAnimatedImage::~QQuickAnimatedImage() @@ -372,7 +379,8 @@ void QQuickAnimatedImage::movieRequestFinished() this, SLOT(playingStatusChanged())); connect(d->_movie, SIGNAL(frameChanged(int)), this, SLOT(movieUpdate())); - d->_movie->setCacheMode(QMovie::CacheAll); + if (d->cache) + d->_movie->setCacheMode(QMovie::CacheAll); d->status = Ready; emit statusChanged(d->status); @@ -406,6 +414,11 @@ void QQuickAnimatedImage::movieUpdate() { Q_D(QQuickAnimatedImage); + if (!d->cache) { + qDeleteAll(d->frameMap); + d->frameMap.clear(); + } + if (d->_movie) { d->setPixmap(*d->infoForCurrentFrame(qmlEngine(this))); emit frameChanged(); @@ -426,6 +439,22 @@ void QQuickAnimatedImage::playingStatusChanged() } } +void QQuickAnimatedImage::onCacheChanged() +{ + Q_D(QQuickAnimatedImage); + if (!cache()) { + qDeleteAll(d->frameMap); + d->frameMap.clear(); + if (d->_movie) { + d->_movie->setCacheMode(QMovie::CacheNone); + } + } else { + if (d->_movie) { + d->_movie->setCacheMode(QMovie::CacheAll); + } + } +} + QSize QQuickAnimatedImage::sourceSize() { Q_D(QQuickAnimatedImage); diff --git a/src/quick/items/qquickanimatedimage_p.h b/src/quick/items/qquickanimatedimage_p.h index de37cd8209..409933817f 100644 --- a/src/quick/items/qquickanimatedimage_p.h +++ b/src/quick/items/qquickanimatedimage_p.h @@ -84,6 +84,7 @@ private Q_SLOTS: void movieUpdate(); void movieRequestFinished(); void playingStatusChanged(); + void onCacheChanged(); protected: void load() Q_DECL_OVERRIDE; diff --git a/src/quick/items/qquickflickable.cpp b/src/quick/items/qquickflickable.cpp index 9c03a6db28..a9396051ab 100644 --- a/src/quick/items/qquickflickable.cpp +++ b/src/quick/items/qquickflickable.cpp @@ -1041,7 +1041,7 @@ void QQuickFlickablePrivate::drag(qint64 currentTimestamp, QEvent::Type eventTyp } if (fuzzyLessThanOrEqualTo(minY, newY)) { newY = minY; - rejectY = vData.pressPos == minY && vData.move.value() == minY && dy > 0; + rejectY |= vData.pressPos == minY && vData.move.value() == minY && dy > 0; } } else { qreal vel = velocity.y() / QML_FLICK_OVERSHOOTFRICTION; @@ -1101,7 +1101,7 @@ void QQuickFlickablePrivate::drag(qint64 currentTimestamp, QEvent::Type eventTyp } if (fuzzyLessThanOrEqualTo(minX, newX)) { newX = minX; - rejectX = hData.pressPos == minX && hData.move.value() == minX && dx > 0; + rejectX |= hData.pressPos == minX && hData.move.value() == minX && dx > 0; } } else { qreal vel = velocity.x() / QML_FLICK_OVERSHOOTFRICTION; @@ -1527,13 +1527,13 @@ qreal QQuickFlickable::minXExtent() const qreal QQuickFlickable::maxXExtent() const { Q_D(const QQuickFlickable); - return width() - vWidth() - d->hData.endMargin; + return qMin<qreal>(0, width() - vWidth() - d->hData.endMargin); } /* returns -ve */ qreal QQuickFlickable::maxYExtent() const { Q_D(const QQuickFlickable); - return height() - vHeight() - d->vData.endMargin; + return qMin<qreal>(0, height() - vHeight() - d->vData.endMargin); } void QQuickFlickable::componentComplete() diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h index f2ad487a0b..64d8bd0ede 100644 --- a/src/quick/items/qquickitem_p.h +++ b/src/quick/items/qquickitem_p.h @@ -58,7 +58,7 @@ #include <private/qpodvector_p.h> #include <QtQuick/private/qquickstate_p.h> -#include <private/qqmlnullablevalue_p_p.h> +#include <private/qqmlnullablevalue_p.h> #include <private/qqmlnotifier_p.h> #include <private/qqmlglobal_p.h> #include <private/qlazilyallocated_p.h> diff --git a/src/quick/items/qquickpathview.cpp b/src/quick/items/qquickpathview.cpp index 352a939e1b..58605f79dd 100644 --- a/src/quick/items/qquickpathview.cpp +++ b/src/quick/items/qquickpathview.cpp @@ -35,6 +35,7 @@ #include "qquickpathview_p_p.h" #include "qquickwindow.h" #include "qquickflickablebehavior_p.h" //Contains flicking behavior defines +#include "qquicktext_p.h" #include <QtQuick/private/qquickstate_p.h> #include <private/qqmlglobal_p.h> @@ -52,6 +53,8 @@ QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(lcItemViewDelegateLifecycle) + const qreal MinimumFlickVelocity = 75.0; inline qreal qmlMod(qreal x, qreal y) @@ -194,6 +197,7 @@ void QQuickPathViewPrivate::releaseItem(QQuickItem *item) { if (!item || !model) return; + qCDebug(lcItemViewDelegateLifecycle) << "release" << item; QQuickItemPrivate *itemPrivate = QQuickItemPrivate::get(item); itemPrivate->removeItemChangeListener(this, QQuickItemPrivate::Geometry); QQmlInstanceModel::ReleaseFlags flags = model->release(item); @@ -824,9 +828,11 @@ void QQuickPathViewPrivate::setOffset(qreal o) Q_Q(QQuickPathView); if (offset != o) { if (isValid() && q->isComponentComplete()) { + qreal oldOffset = offset; offset = qmlMod(o, qreal(modelCount)); if (offset < 0) offset += qreal(modelCount); + qCDebug(lcItemViewDelegateLifecycle) << o << "was" << oldOffset << "now" << offset; q->refill(); } else { offset = o; @@ -1891,10 +1897,18 @@ void QQuickPathView::refill() // first move existing items and remove items off path int idx = d->firstIndex; + qCDebug(lcItemViewDelegateLifecycle) << "firstIndex" << idx << "currentIndex" << d->currentIndex << "offset" << d->offset; QList<QQuickItem*>::iterator it = d->items.begin(); while (it != d->items.end()) { qreal pos = d->positionOfIndex(idx); QQuickItem *item = *it; + if (lcItemViewDelegateLifecycle().isDebugEnabled()) { + QQuickText *text = qmlobject_cast<QQuickText*>(item); + if (text) + qCDebug(lcItemViewDelegateLifecycle) << "idx" << idx << "@" << pos << ": QQuickText" << text->objectName() << text->text().left(40); + else + qCDebug(lcItemViewDelegateLifecycle) << "idx" << idx << "@" << pos << ":" << item; + } if (pos < 1.0) { d->updateItem(item, pos); if (idx == d->currentIndex) { @@ -1907,7 +1921,7 @@ void QQuickPathView::refill() if (QQuickPathViewAttached *att = d->attached(item)) att->setOnPath(pos < 1.0); if (!d->isInBound(pos, d->mappedRange - d->mappedCache, 1.0 + d->mappedCache)) { -// qDebug() << "release"; + qCDebug(lcItemViewDelegateLifecycle) << "release" << idx << "@" << pos << ", !isInBound: lower" << (d->mappedRange - d->mappedCache) << "upper" << (1.0 + d->mappedCache); d->releaseItem(item); if (it == d->items.begin()) { if (++d->firstIndex >= d->modelCount) { @@ -1942,7 +1956,7 @@ void QQuickPathView::refill() } qreal pos = d->positionOfIndex(idx); while ((d->isInBound(pos, startPos, 1.0 + d->mappedCache) || !d->items.count()) && d->items.count() < count+d->cacheSize) { -// qDebug() << "append" << idx; + qCDebug(lcItemViewDelegateLifecycle) << "append" << idx << "@" << pos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count(); QQuickItem *item = d->getItem(idx, idx+1, pos >= 1.0); if (!item) { waiting = true; @@ -1967,7 +1981,7 @@ void QQuickPathView::refill() idx = d->modelCount - 1; pos = d->positionOfIndex(idx); while (!waiting && d->isInBound(pos, d->mappedRange - d->mappedCache, startPos) && d->items.count() < count+d->cacheSize) { -// qDebug() << "prepend" << idx; + qCDebug(lcItemViewDelegateLifecycle) << "prepend" << idx << "@" << pos << (d->currentIndex == idx ? "current" : "") << "items count was" << d->items.count(); QQuickItem *item = d->getItem(idx, idx+1, pos >= 1.0); if (!item) { waiting = true; diff --git a/src/quick/items/qquicktextnodeengine.cpp b/src/quick/items/qquicktextnodeengine.cpp index 369570f657..14d305ad50 100644 --- a/src/quick/items/qquicktextnodeengine.cpp +++ b/src/quick/items/qquicktextnodeengine.cpp @@ -670,61 +670,86 @@ void QQuickTextNodeEngine::addFrameDecorations(QTextDocument *document, QTextFra } } -void QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode *parentNode, - QQuickText::TextStyle style, - const QColor &styleColor) +uint qHash(const QQuickTextNodeEngine::BinaryTreeNodeKey &key) { - if (m_currentLine.isValid()) - processCurrentLine(); + // Just use the default hash for pairs + return qHash(qMakePair(key.fontEngine, qMakePair(key.clipNode, + qMakePair(key.color, key.selectionState)))); +} + +void QQuickTextNodeEngine::mergeProcessedNodes(QList<BinaryTreeNode *> *regularNodes, + QList<BinaryTreeNode *> *imageNodes) +{ + QMultiHash<BinaryTreeNodeKey, BinaryTreeNode *> map; - // Then, go through all the nodes for all lines and combine all QGlyphRuns with a common - // font, selection state and clip node. - typedef QPair<QFontEngine *, QPair<QQuickDefaultClipNode *, QPair<QRgb, int> > > KeyType; - QHash<KeyType, BinaryTreeNode *> map; - QList<BinaryTreeNode *> nodes; - QList<BinaryTreeNode *> imageNodes; for (int i = 0; i < m_processedNodes.size(); ++i) { BinaryTreeNode *node = m_processedNodes.data() + i; if (node->image.isNull()) { - QGlyphRun glyphRun = node->glyphRun; - QRawFont rawFont = glyphRun.rawFont(); + QRawFont rawFont = node->glyphRun.rawFont(); QRawFontPrivate *rawFontD = QRawFontPrivate::get(rawFont); - QFontEngine *fontEngine = rawFontD->fontEngine; - KeyType key(qMakePair(fontEngine, - qMakePair(node->clipNode, - qMakePair(node->color.rgba(), int(node->selectionState))))); - - BinaryTreeNode *otherNode = map.value(key, 0); - if (otherNode != 0) { - QGlyphRun &otherGlyphRun = otherNode->glyphRun; + BinaryTreeNodeKey key(fontEngine, + node->clipNode, + node->color.rgba(), + int(node->selectionState)); + map.insertMulti(key, node); + } else { + imageNodes->append(node); + } + } - QVector<quint32> otherGlyphIndexes = otherGlyphRun.glyphIndexes(); - QVector<QPointF> otherGlyphPositions = otherGlyphRun.positions(); + QMultiHash<BinaryTreeNodeKey, BinaryTreeNode *>::const_iterator it = map.constBegin(); + while (it != map.constEnd()) { + BinaryTreeNode *primaryNode = it.value(); + regularNodes->append(primaryNode); - otherGlyphIndexes += glyphRun.glyphIndexes(); + int count = 0; + QMultiHash<BinaryTreeNodeKey, BinaryTreeNode *>::const_iterator jt; + for (jt = it; jt != map.constEnd() && jt.key() == it.key(); ++jt) + count += jt.value()->glyphRun.glyphIndexes().size(); - QVector<QPointF> glyphPositions = glyphRun.positions(); - otherGlyphPositions.reserve(otherGlyphPositions.size() + glyphPositions.size()); - for (int j = 0; j < glyphPositions.size(); ++j) { - otherGlyphPositions += glyphPositions.at(j) + (node->position - otherNode->position); - } + if (count != primaryNode->glyphRun.glyphIndexes().size()) { + QGlyphRun &glyphRun = primaryNode->glyphRun; + QVector<quint32> glyphIndexes = glyphRun.glyphIndexes(); + glyphIndexes.reserve(count); - otherGlyphRun.setGlyphIndexes(otherGlyphIndexes); - otherGlyphRun.setPositions(otherGlyphPositions); + QVector<QPointF> glyphPositions = glyphRun.positions(); + glyphPositions.reserve(count); - otherNode->ranges += node->ranges; + for (jt = it + 1; jt != map.constEnd() && jt.key() == it.key(); ++jt) { + BinaryTreeNode *otherNode = jt.value(); + glyphIndexes += otherNode->glyphRun.glyphIndexes(); + primaryNode->ranges += otherNode->ranges; - } else { - map.insert(key, node); - nodes.append(node); + QVector<QPointF> otherPositions = otherNode->glyphRun.positions(); + for (int j = 0; j < otherPositions.size(); ++j) + glyphPositions += otherPositions.at(j) + (otherNode->position - primaryNode->position); } + it = jt; + + Q_ASSERT(glyphPositions.size() == count); + Q_ASSERT(glyphIndexes.size() == count); + + glyphRun.setGlyphIndexes(glyphIndexes); + glyphRun.setPositions(glyphPositions); } else { - imageNodes.append(node); + ++it; } } +} + +void QQuickTextNodeEngine::addToSceneGraph(QQuickTextNode *parentNode, + QQuickText::TextStyle style, + const QColor &styleColor) +{ + if (m_currentLine.isValid()) + processCurrentLine(); + + QList<BinaryTreeNode *> nodes; + QList<BinaryTreeNode *> imageNodes; + mergeProcessedNodes(&nodes, &imageNodes); for (int i = 0; i < m_backgrounds.size(); ++i) { const QRectF &rect = m_backgrounds.at(i).first; diff --git a/src/quick/items/qquicktextnodeengine_p.h b/src/quick/items/qquicktextnodeengine_p.h index 3441a5a973..178454b19e 100644 --- a/src/quick/items/qquicktextnodeengine_p.h +++ b/src/quick/items/qquicktextnodeengine_p.h @@ -102,6 +102,33 @@ public: static void inOrder(const QVarLengthArray<BinaryTreeNode, 16> &binaryTree, QVarLengthArray<int> *sortedIndexes, int currentIndex = 0); }; + struct BinaryTreeNodeKey + { + BinaryTreeNodeKey(QFontEngine *fe, + QQuickDefaultClipNode *cn, + QRgb col, + int selState) + : fontEngine(fe) + , clipNode(cn) + , color(col) + , selectionState(selState) + { + } + + bool operator==(const BinaryTreeNodeKey &otherKey) const + { + return fontEngine == otherKey.fontEngine + && clipNode == otherKey.clipNode + && color == otherKey.color + && selectionState == otherKey.selectionState; + } + + QFontEngine *fontEngine; + QQuickDefaultClipNode *clipNode; + QRgb color; + int selectionState; + }; + QQuickTextNodeEngine() : m_hasSelection(false), m_hasContents(false) {} bool hasContents() const { return m_hasContents; } @@ -141,6 +168,8 @@ public: int start, int end, int selectionStart, int selectionEnd); + void mergeProcessedNodes(QList<BinaryTreeNode *> *regularNodes, + QList<BinaryTreeNode *> *imageNodes); void addToSceneGraph(QQuickTextNode *parent, QQuickText::TextStyle style = QQuickText::Normal, const QColor &styleColor = QColor()); diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp index aabeefb317..35f4a84980 100644 --- a/src/quick/items/qquickwindow.cpp +++ b/src/quick/items/qquickwindow.cpp @@ -1403,6 +1403,9 @@ bool QQuickWindow::event(QEvent *e) break; } + if (e->type() == QEvent::Type(QQuickWindowPrivate::FullUpdateRequest)) + update(); + return QWindow::event(e); } diff --git a/src/quick/items/qquickwindow_p.h b/src/quick/items/qquickwindow_p.h index c3ae6c054c..a61c0b0346 100644 --- a/src/quick/items/qquickwindow_p.h +++ b/src/quick/items/qquickwindow_p.h @@ -101,6 +101,10 @@ class Q_QUICK_PRIVATE_EXPORT QQuickWindowPrivate : public QWindowPrivate public: Q_DECLARE_PUBLIC(QQuickWindow) + enum CustomEvents { + FullUpdateRequest = QEvent::User + 1 + }; + static inline QQuickWindowPrivate *get(QQuickWindow *c) { return c->d_func(); } QQuickWindowPrivate(); diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp index 8f94a86026..886e614620 100644 --- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp +++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp @@ -2899,7 +2899,7 @@ void Renderer::visualizeChangesPrepare(Node *n, uint parentChanges) void Renderer::visualizeChanges(Node *n) { - if (n->type() == QSGNode::GeometryNodeType && m_visualizeChanceSet.contains(n)) { + if (n->type() == QSGNode::GeometryNodeType && n->element()->batch && m_visualizeChanceSet.contains(n)) { uint dirty = m_visualizeChanceSet.value(n); bool tinted = (dirty & QSGNODE_DIRTY_PARENT) != 0; @@ -2934,7 +2934,7 @@ void Renderer::visualizeChanges(Node *n) void Renderer::visualizeOverdraw_helper(Node *node) { - if (node->type() == QSGNode::GeometryNodeType) { + if (node->type() == QSGNode::GeometryNodeType && node->element()->batch) { VisualizeShader *shader = static_cast<VisualizeShader *>(m_shaderManager->visualizeProgram); QSGGeometryNode *gn = static_cast<QSGGeometryNode *>(node->sgNode); diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp index 460f92edd7..e1a54810b7 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp +++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp @@ -490,6 +490,14 @@ void QSGRenderThread::sync(bool inExpose) bool current = false; if (windowSize.width() > 0 && windowSize.height() > 0) current = gl->makeCurrent(window); + // Check for context loss. + if (!current && !gl->isValid()) { + QQuickWindowPrivate::get(window)->cleanupNodesOnShutdown(); + sgrc->invalidate(); + current = gl->create() && gl->makeCurrent(window); + if (current) + sgrc->initialize(gl); + } if (current) { QQuickWindowPrivate *d = QQuickWindowPrivate::get(window); bool hadRenderer = d->renderer != 0; @@ -571,6 +579,12 @@ void QSGRenderThread::syncAndRender() bool current = false; if (d->renderer && windowSize.width() > 0 && windowSize.height() > 0) current = gl->makeCurrent(window); + // Check for context loss. + if (!current && !gl->isValid()) { + // Cannot do anything here because gui is not locked. Request a new + // sync+render round on the gui thread and let the sync handle it. + QCoreApplication::postEvent(window, new QEvent(QEvent::Type(QQuickWindowPrivate::FullUpdateRequest))); + } if (current) { d->renderSceneGraph(windowSize); if (profileFrames) @@ -694,6 +708,11 @@ QSGThreadedRenderLoop::QSGThreadedRenderLoop() m_animation_driver->install(); } +QSGThreadedRenderLoop::~QSGThreadedRenderLoop() +{ + delete sg; +} + QSGRenderContext *QSGThreadedRenderLoop::createRenderContext(QSGContext *sg) const { return sg->createRenderContext(); diff --git a/src/quick/scenegraph/qsgthreadedrenderloop_p.h b/src/quick/scenegraph/qsgthreadedrenderloop_p.h index f371efc1a1..d5ffbf10a3 100644 --- a/src/quick/scenegraph/qsgthreadedrenderloop_p.h +++ b/src/quick/scenegraph/qsgthreadedrenderloop_p.h @@ -49,6 +49,7 @@ class QSGThreadedRenderLoop : public QSGRenderLoop Q_OBJECT public: QSGThreadedRenderLoop(); + ~QSGThreadedRenderLoop(); void show(QQuickWindow *) {} void hide(QQuickWindow *); diff --git a/src/quick/util/qquickanimation_p_p.h b/src/quick/util/qquickanimation_p_p.h index 5e6679d901..4224c6d9ed 100644 --- a/src/quick/util/qquickanimation_p_p.h +++ b/src/quick/util/qquickanimation_p_p.h @@ -47,7 +47,7 @@ #include "qquickanimation_p.h" -#include <private/qqmlnullablevalue_p_p.h> +#include <private/qqmlnullablevalue_p.h> #include <qqml.h> #include <qqmlcontext.h> diff --git a/src/quick/util/qquickpath_p.h b/src/quick/util/qquickpath_p.h index f5bb01260e..eea313eeb1 100644 --- a/src/quick/util/qquickpath_p.h +++ b/src/quick/util/qquickpath_p.h @@ -36,7 +36,7 @@ #include <qqml.h> -#include <private/qqmlnullablevalue_p_p.h> +#include <private/qqmlnullablevalue_p.h> #include <private/qbezier_p.h> #include <QtCore/QObject> diff --git a/src/quickwidgets/qquickwidget.cpp b/src/quickwidgets/qquickwidget.cpp index 298d7e2c37..269928e531 100644 --- a/src/quickwidgets/qquickwidget.cpp +++ b/src/quickwidgets/qquickwidget.cpp @@ -210,12 +210,13 @@ void QQuickWidgetPrivate::render(bool needsSync) } renderControl->render(); - context->functions()->glFlush(); if (resolvedFbo) { QRect rect(QPoint(0, 0), fbo->size()); QOpenGLFramebufferObject::blitFramebuffer(resolvedFbo, rect, fbo, rect); } + + context->functions()->glFlush(); } void QQuickWidgetPrivate::renderSceneGraph() |