aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--dist/changes-5.6.280
-rw-r--r--src/imports/layouts/qquicklayout.cpp4
-rw-r--r--src/imports/localstorage/plugin.cpp18
-rw-r--r--src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc3
-rw-r--r--src/qml/jsruntime/qv4argumentsobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4arraydata.cpp4
-rw-r--r--src/qml/jsruntime/qv4arraydata_p.h2
-rw-r--r--src/qml/jsruntime/qv4context.cpp31
-rw-r--r--src/qml/jsruntime/qv4context_p.h69
-rw-r--r--src/qml/jsruntime/qv4engine.cpp7
-rw-r--r--src/qml/jsruntime/qv4function.cpp4
-rw-r--r--src/qml/jsruntime/qv4functionobject.cpp48
-rw-r--r--src/qml/jsruntime/qv4managed_p.h7
-rw-r--r--src/qml/jsruntime/qv4memberdata.cpp4
-rw-r--r--src/qml/jsruntime/qv4memberdata_p.h1
-rw-r--r--src/qml/jsruntime/qv4object_p.h16
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper.cpp106
-rw-r--r--src/qml/jsruntime/qv4qobjectwrapper_p.h34
-rw-r--r--src/qml/jsruntime/qv4regexp.cpp2
-rw-r--r--src/qml/jsruntime/qv4regexpobject.cpp4
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp6
-rw-r--r--src/qml/jsruntime/qv4sequenceobject.cpp9
-rw-r--r--src/qml/jsruntime/qv4string.cpp6
-rw-r--r--src/qml/jsruntime/qv4string_p.h2
-rw-r--r--src/qml/jsruntime/qv4value_p.h18
-rw-r--r--src/qml/memory/qv4heap_p.h74
-rw-r--r--src/qml/memory/qv4mm_p.h4
-rw-r--r--src/qml/qml.pro6
-rw-r--r--src/qml/qml/qqmlcomponent.cpp6
-rw-r--r--src/qml/qml/qqmlcontextwrapper.cpp3
-rw-r--r--src/qml/qml/qqmlcontextwrapper_p.h2
-rw-r--r--src/qml/qml/qqmllistwrapper.cpp2
-rw-r--r--src/qml/qml/qqmllistwrapper_p.h2
-rw-r--r--src/qml/qml/qqmltypeloader.cpp7
-rw-r--r--src/qml/qml/qqmltypewrapper.cpp2
-rw-r--r--src/qml/qml/qqmltypewrapper_p.h2
-rw-r--r--src/qml/qml/qqmlvaluetypewrapper.cpp5
-rw-r--r--src/qml/qml/qqmlvmemetaobject.cpp6
-rw-r--r--src/qml/qml/v8/qqmlbuiltinfunctions.cpp2
-rw-r--r--src/qml/types/qqmldelegatemodel.cpp20
-rw-r--r--src/quick/doc/snippets/qml/localstorage/dbtransaction.js68
-rw-r--r--src/quick/doc/src/concepts/input/focus.qdoc2
-rw-r--r--src/quick/items/qquickdrag.cpp2
-rw-r--r--src/quick/items/qquickevents.cpp4
-rw-r--r--src/quick/items/qquickitem.cpp17
-rw-r--r--src/quick/items/qquickitem_p.h1
-rw-r--r--src/quick/items/qquicktextinput.cpp7
-rw-r--r--src/quick/items/qquicktextnode.cpp8
-rw-r--r--src/quick/items/qquickwindow.cpp11
-rw-r--r--src/quick/scenegraph/util/qsgdefaultpainternode.cpp4
-rw-r--r--tests/auto/qml/qqmltypeloader/data/MyComponent.qml11
-rw-r--r--tests/auto/qml/qqmltypeloader/data/MyComponent2.qml7
-rw-r--r--tests/auto/qml/qqmltypeloader/data/MyComponent3.qml9
-rw-r--r--tests/auto/qml/qqmltypeloader/data/trim_cache2.qml13
-rw-r--r--tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp14
-rw-r--r--tests/auto/quick/qquicklayouts/data/rowlayout/Container.qml55
-rw-r--r--tests/auto/quick/qquicklayouts/data/rowlayout/ContainerUser.qml53
-rw-r--r--tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml12
-rw-r--r--tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp7
-rw-r--r--tests/auto/quick/touchmouse/tst_touchmouse.cpp4
60 files changed, 743 insertions, 198 deletions
diff --git a/dist/changes-5.6.2 b/dist/changes-5.6.2
new file mode 100644
index 0000000000..57bae85ae4
--- /dev/null
+++ b/dist/changes-5.6.2
@@ -0,0 +1,80 @@
+Qt 5.6.2 is a bug-fix release. It maintains both forward and backward
+compatibility (source and binary) with Qt 5.6.0.
+
+For more details, refer to the online documentation included in this
+distribution. The documentation is also available online:
+
+ http://doc.qt.io/qt-5/index.html
+
+The Qt version 5.6 series is binary compatible with the 5.5.x series.
+Applications compiled for 5.5 will continue to run with 5.6.
+
+Some of the changes listed in this file include issue tracking numbers
+corresponding to tasks in the Qt Bug Tracker:
+
+ https://bugreports.qt.io/
+
+Each of these identifiers can be entered in the bug tracker to obtain more
+information about a particular change.
+
+QtQml
+-----
+
+ - [QTBUG-53412] Fix mapping of null JS values to null SQL values instead
+ of empty strings.
+ - [QTBUG-53794] Fix crash when using the "with" statement with an
+ expression that throws an exception.
+ - [QTBUG-54589] Fix assertion when deleting properties of JS objects
+ - Fix crash when incubating objects asynchronously with initial properties.
+ - Fix support for QJSValue parameters in QML signal handlers.
+ - Fix crash on 64-bit big endian architectures.
+ - Fix literal string assignments to QVector2D and QQuaternion properties.
+ - Fix crashes when using Component.onDestruction handlers.
+ - [QTBUG-49232] Fix assignment of values to quint8 properties.
+ - [QTBUG-48136] Fix QQmlPropertyMap emitting valueChanged when the value had
+ not actually changed, causing side effects such as causing fake binding loops.
+ - [QTBUG-55238] Work around miscompilations with Visual Studio 2015 Update 3
+ - [QTBUG-55482] Work around a crash in release mode with GCC 6 related to dead
+ store elimination
+
+QtQuick
+-------
+
+ - Fix QtQuick scenegraph waiting up to a full vsync duration before rendering
+ the first frame.
+ - ShaderEffect: Fix a crash when a ShaderEffect and an Image both share the
+ same texture via supportsAtlasTextures.
+ - [QTBUG-53726] Flickable: Fix widthRatio and heightRatio being incorrect when
+ the content is smaller than the view.
+ - [QTBUG-42928] MultiPointTouchArea: Fix touch points remaining pressed when
+ the MultiPointTouchArea is hidden or disabled.
+ - [QTBUG-53937] AnimatedSprite: Fix a potential infinite loop when changing
+ image source.
+ - [QTBUG-53263] ListView: Fix items not always rendering when inserting many
+ items into a model.
+ - [QTBUG-52901] Fixed QQuickPaintedItem not scaling correctly for high DPI when
+ using a renderTarget of FramebufferObject
+ - [QTBUG-52534] MouseArea: Fix drag.threshold when preventStealing is in use.
+ - QQuickWidget now properly repaints text on high-DPI screen changes.
+ - [QTBUG-54238] qt.scenegraph.info logging category got renamed to
+ qt.scenegraph.general.
+
+ - QQuickItem:
+ * [QTBUG-31861] Fixed issue with mouse button events being sent even
+ when they were disabled by setAcceptedMouseButtons.
+ * [QTBUG-40145] Fix multiple items gaining activeFocus incorrectly.
+
+ - Text:
+ * [QTBUG-54075] Fix positioning of inline images when using StyledText.
+ * [QTBUG-52389] Fixed clipping of glyphs that extend beyond font's em
+ square.
+ * Fix mouse presses being eaten when textFormat was PlainText. In this
+ case, the item cannot possibly make use of a press (as there are no
+ hyperlinks), but deprives other items of the opportunity to take the press.
+
+ - PathView:
+ * [QTBUG-53464] PathView: Fix items not being correctly created in some
+ circumstances.
+ * [QTBUG-37815] PathView: Fix infinite loop when creating items in some
+ circumstances.
+
diff --git a/src/imports/layouts/qquicklayout.cpp b/src/imports/layouts/qquicklayout.cpp
index 98e2aea44f..07ada75a5f 100644
--- a/src/imports/layouts/qquicklayout.cpp
+++ b/src/imports/layouts/qquicklayout.cpp
@@ -698,6 +698,10 @@ QQuickLayout::QQuickLayout(QQuickLayoutPrivate &dd, QQuickItem *parent)
QQuickLayout::~QQuickLayout()
{
d_func()->m_isReady = false;
+
+ const auto childItems = d_func()->childItems;
+ for (QQuickItem *child : childItems)
+ QQuickItemPrivate::get(child)->removeItemChangeListener(this, QQuickItemPrivate::SiblingOrder);
}
QQuickLayoutAttached *QQuickLayout::qmlAttachedProperties(QObject *object)
diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp
index 7d96f11768..f76bca2747 100644
--- a/src/imports/localstorage/plugin.cpp
+++ b/src/imports/localstorage/plugin.cpp
@@ -585,9 +585,9 @@ import QtQuick.LocalStorage 2.0 as Sql
db = Sql.openDatabaseSync(identifier, version, description, estimated_size, callback(db))
\endcode
The above code returns the database identified by \e identifier. If the database does not already exist, it
-is created, and the function \e callback is called with the database as a parameter. \e description
-and \e estimated_size are written to the INI file (described below), but are otherwise currently
-unused.
+is created, and the function \e callback is called with the database as a parameter. \e identifier is the
+name of the physical file (with or without full path) containing the database. \e description and
+\e estimated_size are written to the INI file (described below), but are currently unused.
May throw exception with code property SQLException.DATABASE_ERR, or SQLException.VERSION_ERR.
@@ -595,7 +595,7 @@ When a database is first created, an INI file is also created specifying its cha
\table
\header \li \b {Key} \li \b {Value}
-\row \li Name \li The name of the database passed to \c openDatabase()
+\row \li Identifier \li The name of the database passed to \c openDatabase()
\row \li Version \li The version of the database passed to \c openDatabase()
\row \li Description \li The description of the database passed to \c openDatabase()
\row \li EstimatedSize \li The estimated size (in bytes) of the database passed to \c openDatabase()
@@ -615,12 +615,19 @@ you can call \e executeSql on \e tx to upgrade the database.
May throw exception with code property SQLException.DATABASE_ERR or SQLException.UNKNOWN_ERR.
+See example below.
+
+\snippet qml/localstorage/dbtransaction.js 2
+
\section3 db.transaction(callback(tx))
This method creates a read/write transaction and passed to \e callback. In this function,
you can call \e executeSql on \e tx to read and modify the database.
If the callback throws exceptions, the transaction is rolled back.
+Below you will find an example of a database transaction which catches exceptions.
+
+\snippet qml/localstorage/dbtransaction.js 0
\section3 db.readTransaction(callback(tx))
@@ -643,6 +650,9 @@ It returns a results object, with the following properties:
May throw exception with code property SQLException.DATABASE_ERR, SQLException.SYNTAX_ERR, or SQLException.UNKNOWN_ERR.
+See below for an example:
+
+\snippet qml/localstorage/dbtransaction.js 1
\section1 Method Documentation
diff --git a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
index de0515e5d0..3692605c18 100644
--- a/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
+++ b/src/qml/doc/src/qmllanguageref/syntax/objectattributes.qdoc
@@ -855,7 +855,8 @@ are otherwise unavailable to the object. In particular, they allow objects to
access properties or signals that are specifically relevant to the individual
object.
-A QML type implementation may choose to create an \e {attaching type} with
+A QML type implementation may choose to \l {Providing Attached Objects for
+Data Annotations}{create an \e {attaching type} in C++} with
particular properties and signals. Instances of this type can then be created
and \e attached to specific objects at run time, allowing those objects to
access the properties and signals of the attaching type. These are accessed by
diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp
index b55494823c..156c21ca66 100644
--- a/src/qml/jsruntime/qv4argumentsobject.cpp
+++ b/src/qml/jsruntime/qv4argumentsobject.cpp
@@ -46,9 +46,9 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(ArgumentsObject);
Heap::ArgumentsObject::ArgumentsObject(QV4::CallContext *context)
- : context(context->d())
- , fullyCreated(false)
+ : fullyCreated(false)
{
+ this->context = context->d();
Q_ASSERT(vtable() == QV4::ArgumentsObject::staticVTable());
ExecutionEngine *v4 = context->d()->engine;
diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp
index f4afe46fcb..74c83b1940 100644
--- a/src/qml/jsruntime/qv4arraydata.cpp
+++ b/src/qml/jsruntime/qv4arraydata.cpp
@@ -143,13 +143,13 @@ void ArrayData::realloc(Object *o, Type newType, uint requested, bool enforceAtt
Scoped<ArrayData> newData(scope);
if (newType < Heap::ArrayData::Sparse) {
Heap::SimpleArrayData *n = scope.engine->memoryManager->allocManaged<SimpleArrayData>(size);
- new (n) Heap::SimpleArrayData;
+ n->init();
n->offset = 0;
n->len = d ? d->d()->len : 0;
newData = n;
} else {
Heap::SparseArrayData *n = scope.engine->memoryManager->allocManaged<SparseArrayData>(size);
- new (n) Heap::SparseArrayData;
+ n->init();
newData = n;
}
newData->setAlloc(alloc);
diff --git a/src/qml/jsruntime/qv4arraydata_p.h b/src/qml/jsruntime/qv4arraydata_p.h
index 8ad4704227..d7ee4798b0 100644
--- a/src/qml/jsruntime/qv4arraydata_p.h
+++ b/src/qml/jsruntime/qv4arraydata_p.h
@@ -133,6 +133,7 @@ struct ArrayData : public Base {
}
};
+Q_STATIC_ASSERT(std::is_trivial<ArrayData>::value);
struct SimpleArrayData : public ArrayData {
uint mappedIndex(uint index) const { return (index + offset) % alloc; }
@@ -152,6 +153,7 @@ struct SimpleArrayData : public ArrayData {
return attrs ? attrs[i] : Attr_Data;
}
};
+Q_STATIC_ASSERT(std::is_trivial<SimpleArrayData>::value);
struct SparseArrayData : public ArrayData {
inline ~SparseArrayData();
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index 1abaca3dd1..390a5e7d7a 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -61,8 +61,9 @@ Heap::CallContext *ExecutionContext::newCallContext(const FunctionObject *functi
{
Q_ASSERT(function->function());
- Heap::CallContext *c = d()->engine->memoryManager->allocManaged<CallContext>(requiredMemoryForExecutionContect(function, callData->argc));
- new (c) Heap::CallContext(d()->engine, Heap::ExecutionContext::Type_CallContext);
+ Heap::CallContext *c = d()->engine->memoryManager->allocManaged<CallContext>(
+ requiredMemoryForExecutionContect(function, callData->argc));
+ c->init(d()->engine, Heap::ExecutionContext::Type_CallContext);
c->function = function->d();
@@ -160,28 +161,16 @@ void ExecutionContext::createMutableBinding(String *name, bool deletable)
activation->__defineOwnProperty__(scope.engine, name, desc, attrs);
}
-
-Heap::GlobalContext::GlobalContext(ExecutionEngine *eng)
- : Heap::ExecutionContext(eng, Heap::ExecutionContext::Type_GlobalContext)
+void Heap::GlobalContext::init(ExecutionEngine *eng)
{
+ Heap::ExecutionContext::init(eng, Heap::ExecutionContext::Type_GlobalContext);
global = eng->globalObject->d();
}
-Heap::WithContext::WithContext(ExecutionContext *outerContext, Object *with)
- : Heap::ExecutionContext(outerContext->engine, Heap::ExecutionContext::Type_WithContext)
-{
- outer = outerContext;
- callData = outer->callData;
- lookups = outer->lookups;
- constantTable = outer->constantTable;
- compilationUnit = outer->compilationUnit;
-
- withObject = with;
-}
-
-Heap::CatchContext::CatchContext(ExecutionContext *outerContext, String *exceptionVarName, const Value &exceptionValue)
- : Heap::ExecutionContext(outerContext->engine, Heap::ExecutionContext::Type_CatchContext)
+void Heap::CatchContext::init(ExecutionContext *outerContext, String *exceptionVarName,
+ const Value &exceptionValue)
{
+ Heap::ExecutionContext::init(outerContext->engine, Heap::ExecutionContext::Type_CatchContext);
outer = outerContext;
strictMode = outer->strictMode;
callData = outer->callData;
@@ -193,9 +182,9 @@ Heap::CatchContext::CatchContext(ExecutionContext *outerContext, String *excepti
this->exceptionValue = exceptionValue;
}
-Heap::QmlContext::QmlContext(QV4::ExecutionContext *outerContext, QV4::QmlContextWrapper *qml)
- : Heap::ExecutionContext(outerContext->engine(), Heap::ExecutionContext::Type_QmlContext)
+void Heap::QmlContext::init(QV4::ExecutionContext *outerContext, QV4::QmlContextWrapper *qml)
{
+ Heap::ExecutionContext::init(outerContext->engine(), Heap::ExecutionContext::Type_QmlContext);
outer = outerContext->d();
strictMode = false;
callData = outer->callData;
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index 368605ca4a..ffedf737ce 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -101,7 +101,20 @@ struct ExecutionContext : Base {
Type_CallContext = 0x6
};
- inline ExecutionContext(ExecutionEngine *engine, ContextType t);
+ void init(ExecutionEngine *engine, ContextType t)
+ {
+ Base::init();
+
+ callData = nullptr;
+ this->engine = engine;
+ outer = nullptr;
+ lookups = nullptr;
+ constantTable = nullptr;
+ compilationUnit = nullptr;
+ type = t;
+ strictMode = false;
+ lineNumber = -1;
+ }
CallData *callData;
@@ -115,24 +128,14 @@ struct ExecutionContext : Base {
bool strictMode : 8;
int lineNumber;
};
-
-inline
-ExecutionContext::ExecutionContext(ExecutionEngine *engine, ContextType t)
- : engine(engine)
- , outer(nullptr)
- , lookups(nullptr)
- , constantTable(nullptr)
- , compilationUnit(nullptr)
- , type(t)
- , strictMode(false)
- , lineNumber(-1)
-{}
-
+Q_STATIC_ASSERT(std::is_trivial<ExecutionContext>::value);
struct CallContext : ExecutionContext {
- CallContext(ExecutionEngine *engine, ContextType t = Type_SimpleCallContext)
- : ExecutionContext(engine, t)
+ static CallContext createOnStack(ExecutionEngine *v4);
+
+ void init(ExecutionEngine *engine, ContextType t = Type_SimpleCallContext)
{
+ ExecutionContext::init(engine, t);
function = 0;
locals = 0;
activation = 0;
@@ -142,27 +145,43 @@ struct CallContext : ExecutionContext {
Value *locals;
Pointer<Object> activation;
};
+Q_STATIC_ASSERT(std::is_trivial<CallContext>::value);
struct GlobalContext : ExecutionContext {
- GlobalContext(ExecutionEngine *engine);
+ void init(ExecutionEngine *engine);
Pointer<Object> global;
};
+Q_STATIC_ASSERT(std::is_trivial<GlobalContext>::value);
struct CatchContext : ExecutionContext {
- CatchContext(ExecutionContext *outerContext, String *exceptionVarName, const Value &exceptionValue);
+ void init(ExecutionContext *outerContext, String *exceptionVarName, const Value &exceptionValue);
Pointer<String> exceptionVarName;
Value exceptionValue;
};
+Q_STATIC_ASSERT(std::is_trivial<CatchContext>::value);
struct WithContext : ExecutionContext {
- WithContext(ExecutionContext *outerContext, Object *with);
+ void init(ExecutionContext *outerContext, Object *with)
+ {
+ Heap::ExecutionContext::init(outerContext->engine, Heap::ExecutionContext::Type_WithContext);
+ outer = outerContext;
+ callData = outer->callData;
+ lookups = outer->lookups;
+ constantTable = outer->constantTable;
+ compilationUnit = outer->compilationUnit;
+
+ withObject = with;
+ }
+
Pointer<Object> withObject;
};
+Q_STATIC_ASSERT(std::is_trivial<WithContext>::value);
struct QmlContextWrapper;
struct QmlContext : ExecutionContext {
- QmlContext(QV4::ExecutionContext *outerContext, QV4::QmlContextWrapper *qml);
+ void init(QV4::ExecutionContext *outerContext, QV4::QmlContextWrapper *qml);
+
Pointer<QmlContextWrapper> qml;
};
@@ -279,6 +298,16 @@ inline const WithContext *ExecutionContext::asWithContext() const
return d()->type == Heap::ExecutionContext::Type_WithContext ? static_cast<const WithContext *>(this) : 0;
}
+inline Heap::CallContext Heap::CallContext::createOnStack(ExecutionEngine *v4)
+{
+ Heap::CallContext ctxt;
+ memset(&ctxt, 0, sizeof(Heap::CallContext));
+ ctxt.mm_data = 0;
+ ctxt.setVtable(QV4::CallContext::staticVTable());
+ ctxt.init(v4);
+ return ctxt;
+}
+
/* Function *f, int argc */
#define requiredMemoryForExecutionContect(f, argc) \
((sizeof(CallContext::Data) + 7) & ~7) + sizeof(Value) * (f->varCount() + qMax((uint)argc, f->formalParameterCount())) + sizeof(CallData)
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index fe2aa1abdd..fea6bbbd70 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -488,8 +488,9 @@ void ExecutionEngine::setProfiler(Profiling::Profiler *profiler)
void ExecutionEngine::initRootContext()
{
Scope scope(this);
- Scoped<GlobalContext> r(scope, memoryManager->allocManaged<GlobalContext>(sizeof(GlobalContext::Data) + sizeof(CallData)));
- new (r->d()) GlobalContext::Data(this);
+ Scoped<GlobalContext> r(scope, memoryManager->allocManaged<GlobalContext>(
+ sizeof(GlobalContext::Data) + sizeof(CallData)));
+ r->d_unchecked()->init(this);
r->d()->callData = reinterpret_cast<CallData *>(r->d() + 1);
r->d()->callData->tag = QV4::Value::Integer_Type_Internal;
r->d()->callData->argc = 0;
@@ -572,7 +573,7 @@ Heap::ArrayObject *ExecutionEngine::newArrayObject(const Value *values, int leng
if (length) {
size_t size = sizeof(Heap::ArrayData) + (length-1)*sizeof(Value);
Heap::SimpleArrayData *d = scope.engine->memoryManager->allocManaged<SimpleArrayData>(size);
- new (d) Heap::SimpleArrayData;
+ d->init();
d->alloc = length;
d->type = Heap::ArrayData::Simple;
d->offset = 0;
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index caabee322a..300e538d3d 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -73,7 +73,7 @@ Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit,
}
// duplicate arguments, need some trick to store them
MemoryManager *mm = engine->memoryManager;
- arg = mm->alloc<String>(mm, arg->d(), engine->newString(QString(0xfffe)));
+ arg = mm->alloc<String>(mm, arg->d(), engine->newString(QString(0xfffe)), true);
}
}
nFormals = compiledFunction->nFormals;
@@ -105,7 +105,7 @@ void Function::updateInternalClass(ExecutionEngine *engine, const QList<QByteArr
break;
}
// duplicate arguments, need some trick to store them
- arg = engine->memoryManager->alloc<String>(engine->memoryManager, arg->d(), engine->newString(QString(0xfffe)));
+ arg = engine->memoryManager->alloc<String>(engine->memoryManager, arg->d(), engine->newString(QString(0xfffe)), true);
}
}
nFormals = parameters.size();
diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp
index b08ad24fbe..e160dd8a36 100644
--- a/src/qml/jsruntime/qv4functionobject.cpp
+++ b/src/qml/jsruntime/qv4functionobject.cpp
@@ -69,18 +69,18 @@ using namespace QV4;
DEFINE_OBJECT_VTABLE(FunctionObject);
Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, QV4::String *name, bool createProto)
- : scope(scope->d())
- , function(Q_NULLPTR)
+ : function(Q_NULLPTR)
{
+ this->scope = scope->d();
Scope s(scope->engine());
ScopedFunctionObject f(s, this);
f->init(name, createProto);
}
Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, Function *function, bool createProto)
- : scope(scope->d())
- , function(Q_NULLPTR)
+ : function(Q_NULLPTR)
{
+ this->scope = scope->d();
Scope s(scope->engine());
ScopedString name(s, function->name());
ScopedFunctionObject f(s, this);
@@ -88,9 +88,9 @@ Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, Function *fun
}
Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, const QString &name, bool createProto)
- : scope(scope->d())
- , function(Q_NULLPTR)
+ : function(Q_NULLPTR)
{
+ this->scope = scope->d();
Scope s(scope->engine());
ScopedFunctionObject f(s, this);
ScopedString n(s, s.engine->newString(name));
@@ -98,9 +98,9 @@ Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, const QString
}
Heap::FunctionObject::FunctionObject(ExecutionContext *scope, const QString &name, bool createProto)
- : scope(scope)
- , function(Q_NULLPTR)
+ : function(Q_NULLPTR)
{
+ this->scope = scope;
Scope s(scope->engine);
ScopedFunctionObject f(s, this);
ScopedString n(s, s.engine->newString(name));
@@ -108,9 +108,9 @@ Heap::FunctionObject::FunctionObject(ExecutionContext *scope, const QString &nam
}
Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, const ReturnedValue name)
- : scope(scope->d())
- , function(Q_NULLPTR)
+ : function(Q_NULLPTR)
{
+ this->scope = scope->d();
Scope s(scope);
ScopedFunctionObject f(s, this);
ScopedString n(s, name);
@@ -118,9 +118,9 @@ Heap::FunctionObject::FunctionObject(QV4::ExecutionContext *scope, const Returne
}
Heap::FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValue name)
- : scope(scope)
- , function(Q_NULLPTR)
+ : function(Q_NULLPTR)
{
+ this->scope = scope;
Scope s(scope->engine);
ScopedFunctionObject f(s, this);
ScopedString n(s, name);
@@ -128,9 +128,9 @@ Heap::FunctionObject::FunctionObject(ExecutionContext *scope, const ReturnedValu
}
Heap::FunctionObject::FunctionObject()
- : scope(internalClass->engine->rootContext()->d())
- , function(Q_NULLPTR)
+ : function(Q_NULLPTR)
{
+ this->scope = internalClass->engine->rootContext()->d();
Q_ASSERT(internalClass && internalClass->find(internalClass->engine->id_prototype()) == Index_Prototype);
*propertyData(Index_Prototype) = Encode::undefined();
}
@@ -527,9 +527,7 @@ void SimpleScriptFunction::construct(const Managed *that, Scope &scope, CallData
ScopedObject proto(scope, f->protoForConstructor());
callData->thisObject = v4->newObject(ic, proto);
- CallContext::Data ctx(v4);
- ctx.mm_data = 0;
- ctx.setVtable(CallContext::staticVTable());
+ CallContext::Data ctx = CallContext::Data::createOnStack(v4);
ctx.strictMode = f->strictMode();
ctx.callData = callData;
ctx.function = f->d();
@@ -568,9 +566,7 @@ void SimpleScriptFunction::call(const Managed *that, Scope &scope, CallData *cal
Scoped<SimpleScriptFunction> f(scope, static_cast<const SimpleScriptFunction *>(that));
- CallContext::Data ctx(v4);
- ctx.mm_data = 0;
- ctx.setVtable(CallContext::staticVTable());
+ CallContext::Data ctx = CallContext::Data::createOnStack(v4);
ctx.strictMode = f->strictMode();
ctx.callData = callData;
ctx.function = f->d();
@@ -626,9 +622,7 @@ void BuiltinFunction::call(const Managed *that, Scope &scope, CallData *callData
ExecutionContextSaver ctxSaver(scope);
- CallContext::Data ctx(v4);
- ctx.mm_data = 0;
- ctx.setVtable(CallContext::staticVTable());
+ CallContext::Data ctx = CallContext::Data::createOnStack(v4);
ctx.strictMode = f->scope()->strictMode; // ### needed? scope or parent context?
ctx.callData = callData;
v4->pushContext(&ctx);
@@ -649,9 +643,7 @@ void IndexedBuiltinFunction::call(const Managed *that, Scope &scope, CallData *c
ExecutionContextSaver ctxSaver(scope);
- CallContext::Data ctx(v4);
- ctx.mm_data = 0;
- ctx.setVtable(CallContext::staticVTable());
+ CallContext::Data ctx = CallContext::Data::createOnStack(v4);
ctx.strictMode = f->scope()->strictMode; // ### needed? scope or parent context?
ctx.callData = callData;
v4->pushContext(&ctx);
@@ -667,9 +659,9 @@ DEFINE_OBJECT_VTABLE(BoundFunction);
Heap::BoundFunction::BoundFunction(QV4::ExecutionContext *scope, QV4::FunctionObject *target,
const Value &boundThis, QV4::MemberData *boundArgs)
: Heap::FunctionObject(scope, QStringLiteral("__bound function__"))
- , target(target->d())
- , boundArgs(boundArgs ? boundArgs->d() : 0)
{
+ this->target = target->d();
+ this->boundArgs = boundArgs ? boundArgs->d() : 0;
this->boundThis = boundThis;
Scope s(scope);
diff --git a/src/qml/jsruntime/qv4managed_p.h b/src/qml/jsruntime/qv4managed_p.h
index 1109760fc0..764a8e7f3f 100644
--- a/src/qml/jsruntime/qv4managed_p.h
+++ b/src/qml/jsruntime/qv4managed_p.h
@@ -85,7 +85,12 @@ inline void qYouForgotTheQ_MANAGED_Macro(T1, T2) {}
static const QV4::VTable static_vtbl; \
static inline const QV4::VTable *staticVTable() { return &static_vtbl; } \
V4_MANAGED_SIZE_TEST \
- QV4::Heap::DataClass *d() const { return static_cast<QV4::Heap::DataClass *>(m()); }
+ QV4::Heap::DataClass *d_unchecked() const { return static_cast<QV4::Heap::DataClass *>(m()); } \
+ QV4::Heap::DataClass *d() const { \
+ QV4::Heap::DataClass *dptr = d_unchecked(); \
+ if (std::is_trivial<QV4::Heap::DataClass>::value) dptr->_checkIsInitialized(); \
+ return dptr; \
+ }
#define V4_MANAGED(DataClass, superClass) \
private: \
diff --git a/src/qml/jsruntime/qv4memberdata.cpp b/src/qml/jsruntime/qv4memberdata.cpp
index 62e4f0a14d..5646a44891 100644
--- a/src/qml/jsruntime/qv4memberdata.cpp
+++ b/src/qml/jsruntime/qv4memberdata.cpp
@@ -58,9 +58,9 @@ static Heap::MemberData *reallocateHelper(ExecutionEngine *e, Heap::MemberData *
Scope scope(e);
Scoped<MemberData> newMemberData(scope, e->memoryManager->allocManaged<MemberData>(alloc));
if (old)
- memcpy(newMemberData->d(), old, sizeof(Heap::MemberData) + old->size * sizeof(Value));
+ memcpy(newMemberData->d_unchecked(), old, sizeof(Heap::MemberData) + old->size * sizeof(Value));
else
- new (newMemberData->d()) Heap::MemberData;
+ newMemberData->d_unchecked()->init();
newMemberData->d()->size = n;
return newMemberData->d();
}
diff --git a/src/qml/jsruntime/qv4memberdata_p.h b/src/qml/jsruntime/qv4memberdata_p.h
index 2742e0b212..41da730428 100644
--- a/src/qml/jsruntime/qv4memberdata_p.h
+++ b/src/qml/jsruntime/qv4memberdata_p.h
@@ -66,6 +66,7 @@ struct MemberData : Base {
};
Value data[1];
};
+Q_STATIC_ASSERT(std::is_trivial<MemberData>::value);
}
diff --git a/src/qml/jsruntime/qv4object_p.h b/src/qml/jsruntime/qv4object_p.h
index eda7774f90..54ce2ea60d 100644
--- a/src/qml/jsruntime/qv4object_p.h
+++ b/src/qml/jsruntime/qv4object_p.h
@@ -68,7 +68,7 @@ namespace QV4 {
namespace Heap {
struct Object : Base {
- inline Object() {}
+ inline Object() { Base::init(); }
const Value *propertyData(uint index) const { if (index < inlineMemberSize) return reinterpret_cast<const Value *>(this) + inlineMemberOffset + index; return memberData->data + index - inlineMemberSize; }
Value *propertyData(uint index) { if (index < inlineMemberSize) return reinterpret_cast<Value *>(this) + inlineMemberOffset + index; return memberData->data + index - inlineMemberSize; }
@@ -90,7 +90,12 @@ struct Object : Base {
static const QV4::ObjectVTable static_vtbl; \
static inline const QV4::VTable *staticVTable() { return &static_vtbl.vTable; } \
V4_MANAGED_SIZE_TEST \
- Data *d() const { return static_cast<Data *>(m()); }
+ Data *d_unchecked() const { return static_cast<Data *>(m()); } \
+ Data *d() const { \
+ Data *dptr = d_unchecked(); \
+ if (std::is_trivial<Data>::value) dptr->_checkIsInitialized(); \
+ return dptr; \
+ }
#define V4_OBJECT2(DataClass, superClass) \
private: \
@@ -103,7 +108,12 @@ struct Object : Base {
static const QV4::ObjectVTable static_vtbl; \
static inline const QV4::VTable *staticVTable() { return &static_vtbl.vTable; } \
V4_MANAGED_SIZE_TEST \
- QV4::Heap::DataClass *d() const { return static_cast<QV4::Heap::DataClass *>(m()); }
+ QV4::Heap::DataClass *d_unchecked() const { return static_cast<QV4::Heap::DataClass *>(m()); } \
+ QV4::Heap::DataClass *d() const { \
+ QV4::Heap::DataClass *dptr = d_unchecked(); \
+ if (std::is_trivial<QV4::Heap::DataClass>::value) dptr->_checkIsInitialized(); \
+ return dptr; \
+ }
#define V4_INTERNALCLASS(c) \
static QV4::InternalClass *defaultInternalClass(QV4::ExecutionEngine *e) \
diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp
index 7707f3ba24..b901d9be85 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper.cpp
+++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp
@@ -196,8 +196,8 @@ static QV4::ReturnedValue loadProperty(QV4::ExecutionEngine *v4, QObject *object
}
Heap::QObjectWrapper::QObjectWrapper(QObject *object)
- : object(object)
{
+ qObj.init(object);
}
void QObjectWrapper::initializeBindings(ExecutionEngine *engine)
@@ -210,21 +210,21 @@ QQmlPropertyData *QObjectWrapper::findProperty(ExecutionEngine *engine, QQmlCont
{
Q_UNUSED(revisionMode);
- QQmlData *ddata = QQmlData::get(d()->object, false);
+ QQmlData *ddata = QQmlData::get(d()->object(), false);
if (!ddata)
return 0;
QQmlPropertyData *result = 0;
if (ddata && ddata->propertyCache)
- result = ddata->propertyCache->property(name, d()->object, qmlContext);
+ result = ddata->propertyCache->property(name, d()->object(), qmlContext);
else
- result = QQmlPropertyCache::property(engine->jsEngine(), d()->object, name, qmlContext, *local);
+ result = QQmlPropertyCache::property(engine->jsEngine(), d()->object(), name, qmlContext, *local);
return result;
}
ReturnedValue QObjectWrapper::getQmlProperty(QQmlContextData *qmlContext, String *name, QObjectWrapper::RevisionMode revisionMode,
bool *hasProperty, bool includeImports) const
{
- if (QQmlData::wasDeleted(d()->object)) {
+ if (QQmlData::wasDeleted(d()->object())) {
if (hasProperty)
*hasProperty = false;
return QV4::Encode::undefined();
@@ -237,7 +237,7 @@ ReturnedValue QObjectWrapper::getQmlProperty(QQmlContextData *qmlContext, String
if (hasProperty)
*hasProperty = true;
ExecutionContext *global = v4->rootContext();
- return QV4::QObjectMethod::create(global, d()->object, index);
+ return QV4::QObjectMethod::create(global, d()->object(), index);
}
QQmlPropertyData local;
@@ -256,10 +256,10 @@ ReturnedValue QObjectWrapper::getQmlProperty(QQmlContextData *qmlContext, String
if (r.scriptIndex != -1) {
return QV4::Encode::undefined();
} else if (r.type) {
- return QmlTypeWrapper::create(v4, d()->object,
+ return QmlTypeWrapper::create(v4, d()->object(),
r.type, Heap::QmlTypeWrapper::ExcludeEnums);
} else if (r.importNamespace) {
- return QmlTypeWrapper::create(v4, d()->object,
+ return QmlTypeWrapper::create(v4, d()->object(),
qmlContext->imports, r.importNamespace, Heap::QmlTypeWrapper::ExcludeEnums);
}
Q_ASSERT(!"Unreachable");
@@ -269,7 +269,7 @@ ReturnedValue QObjectWrapper::getQmlProperty(QQmlContextData *qmlContext, String
return QV4::Object::get(this, name, hasProperty);
}
- QQmlData *ddata = QQmlData::get(d()->object, false);
+ QQmlData *ddata = QQmlData::get(d()->object(), false);
if (revisionMode == QV4::QObjectWrapper::CheckRevision && result->hasRevision()) {
if (ddata && ddata->propertyCache && !ddata->propertyCache->isAllowedInRevision(result)) {
@@ -282,7 +282,7 @@ ReturnedValue QObjectWrapper::getQmlProperty(QQmlContextData *qmlContext, String
if (hasProperty)
*hasProperty = true;
- return getProperty(v4, d()->object, result);
+ return getProperty(v4, d()->object(), result);
}
ReturnedValue QObjectWrapper::getProperty(ExecutionEngine *engine, QObject *object, QQmlPropertyData *property, bool captureRequired)
@@ -577,7 +577,7 @@ ReturnedValue QObjectWrapper::getProperty(ExecutionEngine *engine, QObject *obje
void QObjectWrapper::setProperty(ExecutionEngine *engine, int propertyIndex, const Value &value)
{
- setProperty(engine, d()->object, propertyIndex, value);
+ setProperty(engine, d()->object(), propertyIndex, value);
}
void QObjectWrapper::setProperty(ExecutionEngine *engine, QObject *object, int propertyIndex, const Value &value)
@@ -630,12 +630,12 @@ void QObjectWrapper::put(Managed *m, String *name, const Value &value)
QObjectWrapper *that = static_cast<QObjectWrapper*>(m);
ExecutionEngine *v4 = that->engine();
- if (v4->hasException || QQmlData::wasDeleted(that->d()->object))
+ if (v4->hasException || QQmlData::wasDeleted(that->d()->object()))
return;
QQmlContextData *qmlContext = v4->callingQmlContext();
- if (!setQmlProperty(v4, qmlContext, that->d()->object, name, QV4::QObjectWrapper::IgnoreRevision, value)) {
- QQmlData *ddata = QQmlData::get(that->d()->object);
+ if (!setQmlProperty(v4, qmlContext, that->d()->object(), name, QV4::QObjectWrapper::IgnoreRevision, value)) {
+ QQmlData *ddata = QQmlData::get(that->d()->object());
// Types created by QML are not extensible at run-time, but for other QObjects we can store them
// as regular JavaScript properties, like on JavaScript objects.
if (ddata && ddata->context) {
@@ -673,8 +673,8 @@ void QObjectWrapper::advanceIterator(Managed *m, ObjectIterator *it, Value *name
QObjectWrapper *that = static_cast<QObjectWrapper*>(m);
- if (that->d()->object) {
- const QMetaObject *mo = that->d()->object->metaObject();
+ if (that->d()->object()) {
+ const QMetaObject *mo = that->d()->object()->metaObject();
// These indices don't apply to gadgets, so don't block them.
const bool preventDestruction = mo->superClass() || mo == &QObject::staticMetaObject;
const int propertyCount = mo->propertyCount();
@@ -944,7 +944,7 @@ void QObjectWrapper::markObjects(Heap::Base *that, QV4::ExecutionEngine *e)
{
QObjectWrapper::Data *This = static_cast<QObjectWrapper::Data *>(that);
- if (QObject *o = This->object.data()) {
+ if (QObject *o = This->object()) {
QQmlVMEMetaObject *vme = QQmlVMEMetaObject::get(o);
if (vme)
vme->mark(e);
@@ -966,18 +966,18 @@ void QObjectWrapper::destroyObject(bool lastCall)
if (!h->internalClass)
return; // destroyObject already got called
- if (h->object) {
- QQmlData *ddata = QQmlData::get(h->object, false);
+ if (h->object()) {
+ QQmlData *ddata = QQmlData::get(h->object(), false);
if (ddata) {
- if (!h->object->parent() && !ddata->indestructible) {
+ if (!h->object()->parent() && !ddata->indestructible) {
if (ddata && ddata->ownContext && ddata->context)
ddata->context->emitDestruction();
// This object is notionally destroyed now
ddata->isQueuedForDeletion = true;
if (lastCall)
- delete h->object;
+ delete h->object();
else
- h->object->deleteLater();
+ h->object()->deleteLater();
}
}
}
@@ -1675,7 +1675,7 @@ ReturnedValue QObjectMethod::create(ExecutionContext *scope, QObject *object, in
{
Scope valueScope(scope);
Scoped<QObjectMethod> method(valueScope, scope->d()->engine->memoryManager->allocObject<QObjectMethod>(scope));
- method->d()->object = object;
+ method->d()->setObject(object);
if (QQmlData *ddata = QQmlData::get(object))
method->d()->propertyCache = ddata->propertyCache;
@@ -1703,7 +1703,7 @@ const QMetaObject *Heap::QObjectMethod::metaObject()
{
if (propertyCache)
return propertyCache->createMetaObject();
- return object->metaObject();
+ return object()->metaObject();
}
QV4::ReturnedValue QObjectMethod::method_toString(QV4::ExecutionContext *ctx) const
@@ -1712,10 +1712,10 @@ QV4::ReturnedValue QObjectMethod::method_toString(QV4::ExecutionContext *ctx) co
if (const QMetaObject *metaObject = d()->metaObject()) {
result += QString::fromUtf8(metaObject->className()) +
- QLatin1String("(0x") + QString::number((quintptr)d()->object.data(),16);
+ QLatin1String("(0x") + QString::number((quintptr)d()->object(),16);
- if (d()->object) {
- QString objectName = d()->object->objectName();
+ if (d()->object()) {
+ QString objectName = d()->object()->objectName();
if (!objectName.isEmpty())
result += QLatin1String(", \"") + objectName + QLatin1Char('\"');
}
@@ -1730,9 +1730,9 @@ QV4::ReturnedValue QObjectMethod::method_toString(QV4::ExecutionContext *ctx) co
QV4::ReturnedValue QObjectMethod::method_destroy(QV4::ExecutionContext *ctx, const Value *args, int argc) const
{
- if (!d()->object)
+ if (!d()->object())
return Encode::undefined();
- if (QQmlData::keepAliveDuringGarbageCollection(d()->object))
+ if (QQmlData::keepAliveDuringGarbageCollection(d()->object()))
return ctx->engine()->throwError(QStringLiteral("Invalid attempt to destroy() an indestructible object"));
int delay = 0;
@@ -1740,9 +1740,9 @@ QV4::ReturnedValue QObjectMethod::method_destroy(QV4::ExecutionContext *ctx, con
delay = args[0].toUInt32();
if (delay > 0)
- QTimer::singleShot(delay, d()->object, SLOT(deleteLater()));
+ QTimer::singleShot(delay, d()->object(), SLOT(deleteLater()));
else
- d()->object->deleteLater();
+ d()->object()->deleteLater();
return Encode::undefined();
}
@@ -1767,8 +1767,8 @@ void QObjectMethod::callInternal(CallData *callData, Scope &scope) const
return;
}
- QQmlObjectOrGadget object(d()->object.data());
- if (!d()->object) {
+ QQmlObjectOrGadget object(d()->object());
+ if (!d()->object()) {
if (!d()->valueTypeWrapper) {
scope.result = Encode::undefined();
return;
@@ -1787,7 +1787,7 @@ void QObjectMethod::callInternal(CallData *callData, Scope &scope) const
}
method = *data;
} else {
- const QMetaObject *mo = d()->object->metaObject();
+ const QMetaObject *mo = d()->object()->metaObject();
const QMetaMethod moMethod = mo->method(d()->index);
method.load(moMethod);
@@ -1840,23 +1840,33 @@ DEFINE_OBJECT_VTABLE(QObjectMethod);
Heap::QMetaObjectWrapper::QMetaObjectWrapper(const QMetaObject *metaObject)
- : metaObject(metaObject) {
+ : metaObject(metaObject)
+ , constructors(nullptr)
+ , constructorCount(0)
+{}
+Heap::QMetaObjectWrapper::~QMetaObjectWrapper()
+{
+ delete[] constructors;
}
void Heap::QMetaObjectWrapper::ensureConstructorsCache() {
const int count = metaObject->constructorCount();
- if (constructors.size() != count) {
- constructors.clear();
- constructors.reserve(count);
+ if (constructorCount != count) {
+ delete[] constructors;
+ constructorCount = count;
+ if (count == 0) {
+ constructors = nullptr;
+ return;
+ }
+ constructors = new QQmlPropertyData[count];
for (int i = 0; i < count; ++i) {
QMetaMethod method = metaObject->constructor(i);
- QQmlPropertyData d;
+ QQmlPropertyData &d = constructors[i];
d.load(method);
d.setCoreIndex(i);
- constructors << d;
}
}
}
@@ -1895,7 +1905,7 @@ ReturnedValue QMetaObjectWrapper::constructInternal(CallData * callData) const {
ExecutionEngine *v4 = engine();
const QMetaObject* mo = d()->metaObject;
- if (d()->constructors.isEmpty()) {
+ if (d()->constructorCount == 0) {
return v4->throwTypeError(QLatin1String(mo->className())
+ QLatin1String(" has no invokable constructor"));
}
@@ -1903,8 +1913,8 @@ ReturnedValue QMetaObjectWrapper::constructInternal(CallData * callData) const {
Scope scope(v4);
Scoped<QObjectWrapper> object(scope);
- if (d()->constructors.size() == 1) {
- object = callConstructor(d()->constructors.first(), v4, callData);
+ if (d()->constructorCount == 1) {
+ object = callConstructor(d()->constructors[0], v4, callData);
}
else {
object = callOverloadedConstructor(v4, callData);
@@ -1925,7 +1935,7 @@ ReturnedValue QMetaObjectWrapper::callConstructor(const QQmlPropertyData &data,
ReturnedValue QMetaObjectWrapper::callOverloadedConstructor(QV4::ExecutionEngine *engine, QV4::CallData *callArgs) const {
- const int numberOfConstructors = d()->constructors.size();
+ const int numberOfConstructors = d()->constructorCount;
const int argumentCount = callArgs->argc;
const QQmlStaticMetaObject object(d()->metaObject);
@@ -1937,7 +1947,7 @@ ReturnedValue QMetaObjectWrapper::callOverloadedConstructor(QV4::ExecutionEngine
QV4::ScopedValue v(scope);
for (int i = 0; i < numberOfConstructors; i++) {
- const QQmlPropertyData & attempt = d()->constructors.at(i);
+ const QQmlPropertyData & attempt = d()->constructors[i];
int methodArgumentCount = 0;
int *methodArgTypes = 0;
if (attempt.hasArguments()) {
@@ -1976,7 +1986,7 @@ ReturnedValue QMetaObjectWrapper::callOverloadedConstructor(QV4::ExecutionEngine
} else {
QString error = QLatin1String("Unable to determine callable overload. Candidates are:");
for (int i = 0; i < numberOfConstructors; i++) {
- const QQmlPropertyData & candidate = d()->constructors.at(i);
+ const QQmlPropertyData & candidate = d()->constructors[i];
error += QLatin1String("\n ") +
QString::fromUtf8(d()->metaObject->constructor(candidate.coreIndex())
.methodSignature());
@@ -2002,9 +2012,9 @@ DEFINE_OBJECT_VTABLE(QMetaObjectWrapper);
Heap::QmlSignalHandler::QmlSignalHandler(QObject *object, int signalIndex)
- : object(object)
- , signalIndex(signalIndex)
+ : signalIndex(signalIndex)
{
+ setObject(object);
}
DEFINE_OBJECT_VTABLE(QmlSignalHandler);
diff --git a/src/qml/jsruntime/qv4qobjectwrapper_p.h b/src/qml/jsruntime/qv4qobjectwrapper_p.h
index 8ab5c96c3a..076f304fea 100644
--- a/src/qml/jsruntime/qv4qobjectwrapper_p.h
+++ b/src/qml/jsruntime/qv4qobjectwrapper_p.h
@@ -79,32 +79,50 @@ struct QQmlValueTypeWrapper;
struct QObjectWrapper : Object {
QObjectWrapper(QObject *object);
- QPointer<QObject> object;
+ ~QObjectWrapper() { qObj.destroy(); }
+
+ QObject *object() const { return qObj.data(); }
+
+private:
+ QQmlQPointer<QObject> qObj;
};
struct QObjectMethod : FunctionObject {
QObjectMethod(QV4::ExecutionContext *scope);
- QPointer<QObject> object;
+ ~QObjectMethod() { qObj.destroy(); }
QQmlRefPointer<QQmlPropertyCache> propertyCache;
int index;
Pointer<QQmlValueTypeWrapper> valueTypeWrapper;
const QMetaObject *metaObject();
+ QObject *object() const { return qObj.data(); }
+ void setObject(QObject *o) { qObj = o; }
+
+private:
+ QQmlQPointer<QObject> qObj;
};
struct QMetaObjectWrapper : FunctionObject {
- QMetaObjectWrapper(const QMetaObject* metaObject);
const QMetaObject* metaObject;
- QVector<QQmlPropertyData> constructors;
+ QQmlPropertyData *constructors;
+ int constructorCount;
+ QMetaObjectWrapper(const QMetaObject* metaObject);
+ ~QMetaObjectWrapper();
void ensureConstructorsCache();
};
struct QmlSignalHandler : Object {
QmlSignalHandler(QObject *object, int signalIndex);
- QPointer<QObject> object;
+ ~QmlSignalHandler() { qObj.destroy(); }
int signalIndex;
+
+ QObject *object() const { return qObj.data(); }
+ void setObject(QObject *o) { qObj = o; }
+
+private:
+ QQmlQPointer<QObject> qObj;
};
}
@@ -117,7 +135,7 @@ struct Q_QML_EXPORT QObjectWrapper : public Object
static void initializeBindings(ExecutionEngine *engine);
- QObject *object() const { return d()->object.data(); }
+ QObject *object() const { return d()->object(); }
ReturnedValue getQmlProperty(QQmlContextData *qmlContext, String *name, RevisionMode revisionMode, bool *hasProperty = 0, bool includeImports = false) const;
static ReturnedValue getQmlProperty(ExecutionEngine *engine, QQmlContextData *qmlContext, QObject *object, String *name, RevisionMode revisionMode, bool *hasProperty = 0);
@@ -187,7 +205,7 @@ struct Q_QML_EXPORT QObjectMethod : public QV4::FunctionObject
static ReturnedValue create(QV4::ExecutionContext *scope, const QQmlValueTypeWrapper *valueType, int index);
int methodIndex() const { return d()->index; }
- QObject *object() const { return d()->object.data(); }
+ QObject *object() const { return d()->object(); }
QV4::ReturnedValue method_toString(QV4::ExecutionContext *ctx) const;
QV4::ReturnedValue method_destroy(QV4::ExecutionContext *ctx, const Value *args, int argc) const;
@@ -228,7 +246,7 @@ struct Q_QML_EXPORT QmlSignalHandler : public QV4::Object
V4_NEEDS_DESTROY
int signalIndex() const { return d()->signalIndex; }
- QObject *object() const { return d()->object.data(); }
+ QObject *object() const { return d()->object(); }
static void initProto(ExecutionEngine *v4);
};
diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp
index af5355c964..6d6d446ca2 100644
--- a/src/qml/jsruntime/qv4regexp.cpp
+++ b/src/qml/jsruntime/qv4regexp.cpp
@@ -95,6 +95,8 @@ Heap::RegExp::RegExp(ExecutionEngine* engine, const QString &pattern, bool ignor
, ignoreCase(ignoreCase)
, multiLine(multiline)
{
+ Base::init();
+
const char* error = 0;
JSC::Yarr::YarrPattern yarrPattern(WTF::String(pattern), ignoreCase, multiline, &error);
if (error)
diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp
index ab00859b3b..203def0bcf 100644
--- a/src/qml/jsruntime/qv4regexpobject.cpp
+++ b/src/qml/jsruntime/qv4regexpobject.cpp
@@ -79,9 +79,9 @@ Heap::RegExpObject::RegExpObject()
}
Heap::RegExpObject::RegExpObject(QV4::RegExp *value, bool global)
- : value(value->d())
- , global(global)
+ : global(global)
{
+ this->value = value->d();
Scope scope(internalClass->engine);
Scoped<QV4::RegExpObject> o(scope, this);
o->initProperties();
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index e82e7eb804..5460304e7b 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -555,7 +555,7 @@ QV4::ReturnedValue RuntimeHelpers::addHelper(ExecutionEngine *engine, const Valu
if (!pright->stringValue()->d()->length())
return pleft->asReturnedValue();
MemoryManager *mm = engine->memoryManager;
- return (mm->alloc<String>(mm, pleft->stringValue()->d(), pright->stringValue()->d()))->asReturnedValue();
+ return (mm->alloc<String>(mm, pleft->stringValue()->d(), pright->stringValue()->d(), true))->asReturnedValue();
}
double x = RuntimeHelpers::toNumber(pleft);
double y = RuntimeHelpers::toNumber(pright);
@@ -572,7 +572,7 @@ QV4::ReturnedValue Runtime::method_addString(ExecutionEngine *engine, const Valu
if (!right.stringValue()->d()->length())
return left.asReturnedValue();
MemoryManager *mm = engine->memoryManager;
- return (mm->alloc<String>(mm, left.stringValue()->d(), right.stringValue()->d()))->asReturnedValue();
+ return (mm->alloc<String>(mm, left.stringValue()->d(), right.stringValue()->d(), true))->asReturnedValue();
}
Scope scope(engine);
@@ -590,7 +590,7 @@ QV4::ReturnedValue Runtime::method_addString(ExecutionEngine *engine, const Valu
if (!pright->stringValue()->d()->length())
return pleft->asReturnedValue();
MemoryManager *mm = engine->memoryManager;
- return (mm->alloc<String>(mm, pleft->stringValue()->d(), pright->stringValue()->d()))->asReturnedValue();
+ return (mm->alloc<String>(mm, pleft->stringValue()->d(), pright->stringValue()->d(), true))->asReturnedValue();
}
void Runtime::method_setProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value)
diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp
index b15ac7eb5e..59086c245c 100644
--- a/src/qml/jsruntime/qv4sequenceobject.cpp
+++ b/src/qml/jsruntime/qv4sequenceobject.cpp
@@ -218,9 +218,10 @@ template <typename Container>
struct QQmlSequence : Object {
QQmlSequence(const Container &container);
QQmlSequence(QObject *object, int propertyIndex);
+ ~QQmlSequence() { object.destroy(); }
mutable Container container;
- QPointer<QObject> object;
+ QQmlQPointer<QObject> object;
int propertyIndex;
bool isReference;
};
@@ -558,6 +559,8 @@ Heap::QQmlSequence<Container>::QQmlSequence(const Container &container)
, propertyIndex(-1)
, isReference(false)
{
+ object.init();
+
QV4::Scope scope(internalClass->engine);
QV4::Scoped<QV4::QQmlSequence<Container> > o(scope, this);
o->setArrayType(Heap::ArrayData::Custom);
@@ -566,10 +569,10 @@ Heap::QQmlSequence<Container>::QQmlSequence(const Container &container)
template <typename Container>
Heap::QQmlSequence<Container>::QQmlSequence(QObject *object, int propertyIndex)
- : object(object)
- , propertyIndex(propertyIndex)
+ : propertyIndex(propertyIndex)
, isReference(true)
{
+ this->object.init(object);
QV4::Scope scope(internalClass->engine);
QV4::Scoped<QV4::QQmlSequence<Container> > o(scope, this);
o->setArrayType(Heap::ArrayData::Custom);
diff --git a/src/qml/jsruntime/qv4string.cpp b/src/qml/jsruntime/qv4string.cpp
index 3901514326..8bc867e2cd 100644
--- a/src/qml/jsruntime/qv4string.cpp
+++ b/src/qml/jsruntime/qv4string.cpp
@@ -77,6 +77,8 @@ bool String::isEqualTo(Managed *t, Managed *o)
Heap::String::String(MemoryManager *mm, const QString &t)
: mm(mm)
{
+ Base::init();
+
subtype = String::StringType_Unknown;
text = const_cast<QString &>(t).data_ptr();
@@ -87,9 +89,11 @@ Heap::String::String(MemoryManager *mm, const QString &t)
len = text->size;
}
-Heap::String::String(MemoryManager *mm, String *l, String *r)
+Heap::String::String(MemoryManager *mm, String *l, String *r, bool) // TODO: remove the dummy bool when String is trivial
: mm(mm)
{
+ Base::init();
+
subtype = String::StringType_Unknown;
left = l;
diff --git a/src/qml/jsruntime/qv4string_p.h b/src/qml/jsruntime/qv4string_p.h
index ff42ab6471..f347ea8897 100644
--- a/src/qml/jsruntime/qv4string_p.h
+++ b/src/qml/jsruntime/qv4string_p.h
@@ -72,7 +72,7 @@ struct Q_QML_PRIVATE_EXPORT String : Base {
#ifndef V4_BOOTSTRAP
String(MemoryManager *mm, const QString &text);
- String(MemoryManager *mm, String *l, String *n);
+ String(MemoryManager *mm, String *l, String *n, bool dummy);
~String() {
if (!largestSubLength && !text->ref.deref())
QStringData::deallocate(text);
diff --git a/src/qml/jsruntime/qv4value_p.h b/src/qml/jsruntime/qv4value_p.h
index dae4d11767..78cd4de9fb 100644
--- a/src/qml/jsruntime/qv4value_p.h
+++ b/src/qml/jsruntime/qv4value_p.h
@@ -102,19 +102,16 @@ public:
Q_ALWAYS_INLINE quint64 rawValue() const { return _val; }
Q_ALWAYS_INLINE void setRawValue(quint64 raw) { _val = raw; }
-#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN || defined(QV4_USE_64_BIT_VALUE_ENCODING)
+#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
static inline int valueOffset() { return 0; }
static inline int tagOffset() { return 4; }
- Q_ALWAYS_INLINE void setTagValue(quint32 tag, quint32 value) { _val = quint64(tag) << 32 | value; }
- Q_ALWAYS_INLINE quint32 value() const { return _val & quint64(~quint32(0)); }
- Q_ALWAYS_INLINE quint32 tag() const { return _val >> 32; }
-#else // !Q_LITTLE_ENDIAN && !defined(QV4_USE_64_BIT_VALUE_ENCODING)
+#else // !Q_LITTLE_ENDIAN
static inline int valueOffset() { return 4; }
static inline int tagOffset() { return 0; }
- Q_ALWAYS_INLINE void setTagValue(quint32 tag, quint32 value) { _val = quint64(value) << 32 | tag; }
- Q_ALWAYS_INLINE quint32 tag() const { return _val & quint64(~quint32(0)); }
- Q_ALWAYS_INLINE quint32 value() const { return _val >> 32; }
#endif
+ Q_ALWAYS_INLINE void setTagValue(quint32 tag, quint32 value) { _val = quint64(tag) << 32 | value; }
+ Q_ALWAYS_INLINE quint32 value() const { return _val & quint64(~quint32(0)); }
+ Q_ALWAYS_INLINE quint32 tag() const { return _val >> 32; }
#if defined(V4_BOOTSTRAP)
Q_ALWAYS_INLINE Heap::Base *m() const { Q_UNREACHABLE(); return Q_NULLPTR; }
@@ -430,11 +427,8 @@ public:
template<typename T>
Value &operator=(const Scoped<T> &t);
- Value &operator=(const Value &v) {
- _val = v._val;
- return *this;
- }
};
+Q_STATIC_ASSERT(std::is_trivial<Value>::value);
inline bool Value::isString() const
{
diff --git a/src/qml/memory/qv4heap_p.h b/src/qml/memory/qv4heap_p.h
index ed7a531766..d15d14e463 100644
--- a/src/qml/memory/qv4heap_p.h
+++ b/src/qml/memory/qv4heap_p.h
@@ -52,6 +52,11 @@
#include <QtCore/QString>
#include <private/qv4global_p.h>
+#include <QSharedPointer>
+
+// To check if Heap::Base::init is called (meaning, all subclasses did their init and called their
+// parent's init all up the inheritance chain), define QML_CHECK_INIT_DESTROY_CALLS below.
+#undef QML_CHECK_INIT_DESTROY_CALLS
QT_BEGIN_NAMESPACE
@@ -119,13 +124,20 @@ struct Q_QML_EXPORT Base {
void *operator new(size_t, Managed *m) { return m; }
void *operator new(size_t, Heap::Base *m) { return m; }
void operator delete(void *, Heap::Base *) {}
+
+ void init() { setInitialized(); }
+#ifdef QML_CHECK_INIT_DESTROY_CALLS
+ bool _isInitialized;
+ void _checkIsInitialized() { Q_ASSERT(_isInitialized); }
+ void setInitialized() { Q_ASSERT(!_isInitialized); _isInitialized = true; }
+#else
+ Q_ALWAYS_INLINE void _checkIsInitialized() {}
+ Q_ALWAYS_INLINE void setInitialized() {}
+#endif
};
template <typename T>
struct Pointer {
- Pointer() {}
- Pointer(T *t) : ptr(t) {}
-
T *operator->() const { return ptr; }
operator T *() const { return ptr; }
@@ -136,9 +148,65 @@ struct Pointer {
T *ptr;
};
+Q_STATIC_ASSERT(std::is_trivial<Pointer<void>>::value);
}
+#ifdef QT_NO_QOBJECT
+template <class T>
+struct QQmlQPointer {
+};
+#else
+template <class T>
+struct QQmlQPointer {
+ void init()
+ {
+ d = nullptr;
+ qObject = nullptr;
+ }
+
+ void init(T *o)
+ {
+ Q_ASSERT(d == nullptr);
+ Q_ASSERT(qObject == nullptr);
+ if (o) {
+ d = QtSharedPointer::ExternalRefCountData::getAndRef(o);
+ qObject = o;
+ }
+ }
+
+ void destroy()
+ {
+ if (d && !d->weakref.deref())
+ delete d;
+ d = nullptr;
+ qObject = nullptr;
+ }
+
+ T *data() const {
+ return d == nullptr || d->strongref.load() == 0 ? nullptr : qObject;
+ }
+ operator T*() const { return data(); }
+ inline T* operator->() const { return data(); }
+ QQmlQPointer &operator=(T *o)
+ {
+ if (d)
+ destroy();
+ init(o);
+ return *this;
+ }
+ bool isNull() const Q_DECL_NOTHROW
+ {
+ return d == nullptr || qObject == nullptr || d->strongref.load() == 0;
+ }
+
+private:
+ QtSharedPointer::ExternalRefCountData *d;
+ QObject *qObject;
+};
+Q_STATIC_ASSERT(std::is_trivial<QQmlQPointer<QObject>>::value);
+#endif
+
}
QT_END_NAMESPACE
diff --git a/src/qml/memory/qv4mm_p.h b/src/qml/memory/qv4mm_p.h
index 026cbd8c6b..6db5b54760 100644
--- a/src/qml/memory/qv4mm_p.h
+++ b/src/qml/memory/qv4mm_p.h
@@ -276,7 +276,7 @@ public:
{
Scope scope(engine);
Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data)));
- (void)new (t->d()) typename ManagedType::Data(arg1, arg2);
+ t->d_unchecked()->init(arg1, arg2);
return t->d();
}
@@ -285,7 +285,7 @@ public:
{
Scope scope(engine);
Scoped<ManagedType> t(scope, allocManaged<ManagedType>(sizeof(typename ManagedType::Data)));
- (void)new (t->d()) typename ManagedType::Data(arg1, arg2, arg3);
+ t->d_unchecked()->init(arg1, arg2, arg3);
return t->d();
}
diff --git a/src/qml/qml.pro b/src/qml/qml.pro
index cc5023f12a..13e00d8812 100644
--- a/src/qml/qml.pro
+++ b/src/qml/qml.pro
@@ -24,9 +24,13 @@ exists("qqml_enable_gcov") {
gcc:!intel_icc:greaterThan(QT_GCC_MAJOR_VERSION, 5) {
# Our code is bad. Temporary workaround.
- QMAKE_CXXFLAGS += -fno-delete-null-pointer-checks
+ QMAKE_CXXFLAGS += -fno-delete-null-pointer-checks -fno-lifetime-dse
}
+# QTBUG-55238, disable new optimizer for MSVC 2015/Update 3.
+release:win32-msvc*:equals(QT_CL_MAJOR_VERSION, 19):equals(QT_CL_MINOR_VERSION, 00): \
+ greaterThan(QT_CL_PATCH_VERSION, 24212):QMAKE_CXXFLAGS += -d2SSAOptimizer-
+
QMAKE_DOCS = $$PWD/doc/qtqml.qdocconf
# 2415: variable "xx" of static storage duration was declared but never referenced
diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp
index 41f804f0ae..6eda23c4c3 100644
--- a/src/qml/qml/qqmlcomponent.cpp
+++ b/src/qml/qml/qqmlcomponent.cpp
@@ -1059,8 +1059,9 @@ namespace Heap {
struct QmlIncubatorObject : Object {
QmlIncubatorObject(QQmlIncubator::IncubationMode = QQmlIncubator::Asynchronous);
+ ~QmlIncubatorObject() { parent.destroy(); }
QScopedPointer<QQmlComponentIncubator> incubator;
- QPointer<QObject> parent;
+ QQmlQPointer<QObject> parent;
QV4::Value valuemap;
QV4::Value statusChanged;
Pointer<Heap::QmlContext> qmlContext;
@@ -1486,8 +1487,9 @@ QQmlComponentExtension::~QQmlComponentExtension()
QV4::Heap::QmlIncubatorObject::QmlIncubatorObject(QQmlIncubator::IncubationMode m)
: valuemap(QV4::Primitive::undefinedValue())
, statusChanged(QV4::Primitive::undefinedValue())
- , qmlContext(0)
{
+ parent.init();
+ qmlContext = nullptr;
incubator.reset(new QQmlComponentIncubator(this, m));
}
diff --git a/src/qml/qml/qqmlcontextwrapper.cpp b/src/qml/qml/qqmlcontextwrapper.cpp
index 2d0ebad764..13d708bc17 100644
--- a/src/qml/qml/qqmlcontextwrapper.cpp
+++ b/src/qml/qml/qqmlcontextwrapper.cpp
@@ -66,14 +66,15 @@ Heap::QmlContextWrapper::QmlContextWrapper(QQmlContextData *context, QObject *sc
, ownsContext(ownsContext)
, isNullWrapper(false)
, context(context)
- , scopeObject(scopeObject)
{
+ this->scopeObject.init(scopeObject);
}
Heap::QmlContextWrapper::~QmlContextWrapper()
{
if (context && ownsContext)
context->destroy();
+ scopeObject.destroy();
}
ReturnedValue QmlContextWrapper::qmlScope(ExecutionEngine *v4, QQmlContextData *ctxt, QObject *scope)
diff --git a/src/qml/qml/qqmlcontextwrapper_p.h b/src/qml/qml/qqmlcontextwrapper_p.h
index ca7fcf1d75..2b8c16f274 100644
--- a/src/qml/qml/qqmlcontextwrapper_p.h
+++ b/src/qml/qml/qqmlcontextwrapper_p.h
@@ -71,7 +71,7 @@ struct QmlContextWrapper : Object {
bool isNullWrapper;
QQmlGuardedContextData context;
- QPointer<QObject> scopeObject;
+ QQmlQPointer<QObject> scopeObject;
};
}
diff --git a/src/qml/qml/qqmllistwrapper.cpp b/src/qml/qml/qqmllistwrapper.cpp
index 5c35866274..425a720867 100644
--- a/src/qml/qml/qqmllistwrapper.cpp
+++ b/src/qml/qml/qqmllistwrapper.cpp
@@ -54,6 +54,7 @@ DEFINE_OBJECT_VTABLE(QmlListWrapper);
Heap::QmlListWrapper::QmlListWrapper()
{
+ object.init();
QV4::Scope scope(internalClass->engine);
QV4::ScopedObject o(scope, this);
o->setArrayType(Heap::ArrayData::Custom);
@@ -61,6 +62,7 @@ Heap::QmlListWrapper::QmlListWrapper()
Heap::QmlListWrapper::~QmlListWrapper()
{
+ object.destroy();
}
ReturnedValue QmlListWrapper::create(ExecutionEngine *engine, QObject *object, int propId, int propType)
diff --git a/src/qml/qml/qqmllistwrapper_p.h b/src/qml/qml/qqmllistwrapper_p.h
index 26e1e5faaf..1107b957c9 100644
--- a/src/qml/qml/qqmllistwrapper_p.h
+++ b/src/qml/qml/qqmllistwrapper_p.h
@@ -68,7 +68,7 @@ namespace Heap {
struct QmlListWrapper : Object {
QmlListWrapper();
~QmlListWrapper();
- QPointer<QObject> object;
+ QQmlQPointer<QObject> object;
QQmlListProperty<QObject> property;
int propertyType;
};
diff --git a/src/qml/qml/qqmltypeloader.cpp b/src/qml/qml/qqmltypeloader.cpp
index d4dc668bdc..7730233a93 100644
--- a/src/qml/qml/qqmltypeloader.cpp
+++ b/src/qml/qml/qqmltypeloader.cpp
@@ -1967,10 +1967,13 @@ void QQmlTypeLoader::trimCache()
QList<TypeCache::Iterator> unneededTypes;
for (TypeCache::Iterator iter = m_typeCache.begin(), end = m_typeCache.end(); iter != end; ++iter) {
QQmlTypeData *typeData = iter.value();
+
+ const bool hasError = !typeData->m_compiledData && !typeData->m_errors.isEmpty();
+ const bool isNotReferenced = typeData->isComplete() && typeData->m_compiledData
+ && typeData->m_compiledData->count() == 1;
// typeData->m_compiledData may be set early on in the proccess of loading a file, so it's important
// to check the general loading status of the typeData before making any other decisions.
- if (typeData->isComplete() && typeData->m_compiledData && typeData->count() == 1
- && typeData->m_compiledData->count() == 1) {
+ if (typeData->count() == 1 && (hasError || isNotReferenced)) {
// There are no live objects of this type
unneededTypes.append(iter);
}
diff --git a/src/qml/qml/qqmltypewrapper.cpp b/src/qml/qml/qqmltypewrapper.cpp
index 7892555f08..28c2588117 100644
--- a/src/qml/qml/qqmltypewrapper.cpp
+++ b/src/qml/qml/qqmltypewrapper.cpp
@@ -58,12 +58,14 @@ DEFINE_OBJECT_VTABLE(QmlTypeWrapper);
Heap::QmlTypeWrapper::QmlTypeWrapper()
: mode(IncludeEnums)
{
+ object.init();
}
Heap::QmlTypeWrapper::~QmlTypeWrapper()
{
if (typeNamespace)
typeNamespace->release();
+ object.destroy();
}
bool QmlTypeWrapper::isSingleton() const
diff --git a/src/qml/qml/qqmltypewrapper_p.h b/src/qml/qml/qqmltypewrapper_p.h
index 8216526cb5..7c5105b184 100644
--- a/src/qml/qml/qqmltypewrapper_p.h
+++ b/src/qml/qml/qqmltypewrapper_p.h
@@ -74,7 +74,7 @@ struct QmlTypeWrapper : Object {
QmlTypeWrapper();
~QmlTypeWrapper();
TypeNameMode mode;
- QPointer<QObject> object;
+ QQmlQPointer<QObject> object;
QQmlType *type;
QQmlTypeNameCache *typeNamespace;
diff --git a/src/qml/qml/qqmlvaluetypewrapper.cpp b/src/qml/qml/qqmlvaluetypewrapper.cpp
index 2566ab06b5..6b308374e6 100644
--- a/src/qml/qml/qqmlvaluetypewrapper.cpp
+++ b/src/qml/qml/qqmlvaluetypewrapper.cpp
@@ -63,8 +63,9 @@ namespace Heap {
struct QQmlValueTypeReference : QQmlValueTypeWrapper
{
- QQmlValueTypeReference() {}
- QPointer<QObject> object;
+ QQmlValueTypeReference() { object.init(); }
+ ~QQmlValueTypeReference() { object.destroy(); }
+ QQmlQPointer<QObject> object;
int property;
};
diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp
index c8281f02c0..4f13b44fc0 100644
--- a/src/qml/qml/qqmlvmemetaobject.cpp
+++ b/src/qml/qml/qqmlvmemetaobject.cpp
@@ -608,6 +608,9 @@ QRectF QQmlVMEMetaObject::readPropertyAsRectF(int id)
return v->d()->data.value<QRectF>();
}
+#if defined(Q_OS_WINRT) && defined(_M_ARM)
+#pragma optimize("", off)
+#endif
int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void **a)
{
Q_ASSERT(o == object);
@@ -969,6 +972,9 @@ int QQmlVMEMetaObject::metaCall(QObject *o, QMetaObject::Call c, int _id, void *
else
return object->qt_metacall(c, _id, a);
}
+#if defined(Q_OS_WINRT) && defined(_M_ARM)
+#pragma optimize("", on)
+#endif
QV4::ReturnedValue QQmlVMEMetaObject::method(int index)
{
diff --git a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
index 5d70b17ece..222b61ae49 100644
--- a/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
+++ b/src/qml/qml/v8/qqmlbuiltinfunctions.cpp
@@ -1304,8 +1304,8 @@ ReturnedValue QtObject::method_locale(CallContext *ctx)
Heap::QQmlBindingFunction::QQmlBindingFunction(const QV4::FunctionObject *originalFunction)
: QV4::Heap::FunctionObject(originalFunction->scope(), originalFunction->name())
- , originalFunction(originalFunction->d())
{
+ this->originalFunction = originalFunction->d();
}
void QQmlBindingFunction::initBindingLocation()
diff --git a/src/qml/types/qqmldelegatemodel.cpp b/src/qml/types/qqmldelegatemodel.cpp
index d6d4553946..1ca51ea360 100644
--- a/src/qml/types/qqmldelegatemodel.cpp
+++ b/src/qml/types/qqmldelegatemodel.cpp
@@ -1313,9 +1313,23 @@ void QQmlDelegateModelPrivate::itemsRemoved(
}
} else {
if (QQDMIncubationTask *incubationTask = cacheItem->incubationTask) {
- for (int i = 1; i < m_groupCount; ++i) {
- if (remove.inGroup(i))
- incubationTask->index[i] = remove.index[i];
+ if (!cacheItem->isObjectReferenced()) {
+ releaseIncubator(cacheItem->incubationTask);
+ cacheItem->incubationTask = 0;
+ if (cacheItem->object) {
+ QObject *object = cacheItem->object;
+ cacheItem->destroyObject();
+ if (QQuickPackage *package = qmlobject_cast<QQuickPackage *>(object))
+ emitDestroyingPackage(package);
+ else
+ emitDestroyingItem(object);
+ }
+ cacheItem->scriptRef -= 1;
+ } else {
+ for (int i = 1; i < m_groupCount; ++i) {
+ if (remove.inGroup(i))
+ incubationTask->index[i] = remove.index[i];
+ }
}
}
if (QQmlDelegateModelAttached *attached = cacheItem->attached) {
diff --git a/src/quick/doc/snippets/qml/localstorage/dbtransaction.js b/src/quick/doc/snippets/qml/localstorage/dbtransaction.js
new file mode 100644
index 0000000000..07d8a5618b
--- /dev/null
+++ b/src/quick/doc/snippets/qml/localstorage/dbtransaction.js
@@ -0,0 +1,68 @@
+ /****************************************************************************
+**
+** Copyright (C) 2015 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//![0]
+db.transaction(
+ try {
+ function(tx) {
+ tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+ }
+ } catch (err) {
+ console.log("Error inserting into table Greeting");
+ }
+)
+//![0]
+
+//![1]
+db.transaction(
+ function(tx) {
+ var results = tx.executeSql('SELECT salutation FROM Greeting WHERE salutee=?;', 'world');
+ }
+ console.log("We greeted in this most respectful way: " + results.rows.item(0).value);
+)
+//![1]
+//![2]
+var db = LocalStorage.openDatabaseSync("QQmlExampleDB", "", "The Example QML SQL!", 1000000);
+if (db.version == '0.1') {
+ db.changeVersion('0.1', '0.2', function(tx) {
+ tx.executeSql('INSERT INTO Greeting VALUES(?, ?)', [ 'hello', 'world' ]);
+ }
+});
+//![2]
diff --git a/src/quick/doc/src/concepts/input/focus.qdoc b/src/quick/doc/src/concepts/input/focus.qdoc
index db84961d20..ec4e4ca2d9 100644
--- a/src/quick/doc/src/concepts/input/focus.qdoc
+++ b/src/quick/doc/src/concepts/input/focus.qdoc
@@ -117,7 +117,7 @@ the focus, but it cannot control the focus when it is imported or reused.
Likewise, the \c window component does not have the ability to know if its
imported components are requesting the focus.
-To solve this problem, the QML introduces a concept known as a \e {focus scope}.
+To solve this problem, QML introduces a concept known as a \e {focus scope}.
For existing Qt users, a focus scope is like an automatic focus proxy.
A focus scope is created by declaring the \l FocusScope type.
diff --git a/src/quick/items/qquickdrag.cpp b/src/quick/items/qquickdrag.cpp
index 8a0af6c263..b943c28661 100644
--- a/src/quick/items/qquickdrag.cpp
+++ b/src/quick/items/qquickdrag.cpp
@@ -761,7 +761,7 @@ Qt::DropAction QQuickDragAttachedPrivate::startDrag(Qt::DropActions supportedAct
{
Q_Q(QQuickDragAttached);
- QDrag *drag = new QDrag(q);
+ QDrag *drag = new QDrag(source ? source : q);
QMimeData *mimeData = new QMimeData();
for (auto it = externalMimeData.cbegin(), end = externalMimeData.cend(); it != end; ++it)
diff --git a/src/quick/items/qquickevents.cpp b/src/quick/items/qquickevents.cpp
index c6b778f4df..dee3794521 100644
--- a/src/quick/items/qquickevents.cpp
+++ b/src/quick/items/qquickevents.cpp
@@ -894,6 +894,10 @@ QTouchEvent *QQuickPointerTouchEvent::asTouchEvent() const
Q_QUICK_PRIVATE_EXPORT QDebug operator<<(QDebug dbg, const QQuickPointerDevice *dev) {
QDebugStateSaver saver(dbg);
dbg.nospace();
+ if (!dev) {
+ dbg << "QQuickPointerDevice(0)";
+ return dbg;
+ }
dbg << "QQuickPointerDevice("<< dev->name() << ' ';
QtDebugUtils::formatQEnum(dbg, dev->type());
dbg << ' ';
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp
index 72edb5aeb8..2851d1a9e7 100644
--- a/src/quick/items/qquickitem.cpp
+++ b/src/quick/items/qquickitem.cpp
@@ -2703,8 +2703,6 @@ void QQuickItem::setParentItem(QQuickItem *parentItem)
d->itemChange(ItemParentHasChanged, d->parentItem);
- d->parentNotifier.notify();
-
emit parentChanged(d->parentItem);
if (isVisible() && d->parentItem)
emit d->parentItem->visibleChildrenChanged();
@@ -7124,6 +7122,11 @@ void QQuickItem::unsetCursor()
Grabs the mouse input.
This item will receive all mouse events until ungrabMouse() is called.
+ Usually this function should not be called, since accepting for example
+ a mouse press event makes sure that the following events are delivered
+ to the item.
+ If an item wants to take over mouse events from the current receiver,
+ it needs to call this function.
\warning This function should be used with caution.
*/
@@ -7138,6 +7141,12 @@ void QQuickItem::grabMouse()
/*!
Releases the mouse grab following a call to grabMouse().
+
+ Note that this function should only be called when the item wants
+ to stop handling further events. There is no need to call this function
+ after a release or cancel event since no future events will be received
+ in any case. No move or release events will be delivered after this
+ function was called.
*/
void QQuickItem::ungrabMouse()
{
@@ -7204,6 +7213,10 @@ void QQuickItem::grabTouchPoints(const QVector<int> &ids)
/*!
Ungrabs the touch points owned by this item.
+ \note there is hardly any reason to call this function. It should only be
+ called when an item does not want to receive any further events, so no
+ move or release events will be delivered after calling this function.
+
\sa grabTouchPoints()
*/
void QQuickItem::ungrabTouchPoints()
diff --git a/src/quick/items/qquickitem_p.h b/src/quick/items/qquickitem_p.h
index 7a39b7c4c7..c892ec9144 100644
--- a/src/quick/items/qquickitem_p.h
+++ b/src/quick/items/qquickitem_p.h
@@ -474,7 +474,6 @@ public:
inline QSGRenderContext *sceneGraphRenderContext() const;
QQuickItem *parentItem;
- QQmlNotifier parentNotifier;
QList<QQuickItem *> childItems;
mutable QList<QQuickItem *> *sortedChildItems;
diff --git a/src/quick/items/qquicktextinput.cpp b/src/quick/items/qquicktextinput.cpp
index fd158207c6..6543a64624 100644
--- a/src/quick/items/qquicktextinput.cpp
+++ b/src/quick/items/qquicktextinput.cpp
@@ -4356,8 +4356,13 @@ void QQuickTextInputPrivate::processKeyEvent(QKeyEvent* event)
if (!(q->inputMethodHints() & Qt::ImhMultiLine))
inputMethod->hide();
+ if (activeFocus) {
+ // If we lost focus after hiding the virtual keyboard, we've already emitted
+ // editingFinished from handleFocusEvent. Otherwise we emit it now.
+ emit q->editingFinished();
+ }
+
emit q->accepted();
- emit q->editingFinished();
}
event->ignore();
return;
diff --git a/src/quick/items/qquicktextnode.cpp b/src/quick/items/qquicktextnode.cpp
index 0e9d1e3951..8716f98bff 100644
--- a/src/quick/items/qquicktextnode.cpp
+++ b/src/quick/items/qquicktextnode.cpp
@@ -160,10 +160,18 @@ void QQuickTextNode::addImage(const QRectF &rect, const QImage &image)
QSGRenderContext *sg = QQuickItemPrivate::get(m_ownerElement)->sceneGraphRenderContext();
QSGInternalImageNode *node = sg->sceneGraphContext()->createInternalImageNode();
QSGTexture *texture = sg->createTexture(image);
+ if (m_ownerElement->smooth()) {
+ texture->setFiltering(QSGTexture::Linear);
+ texture->setMipmapFiltering(QSGTexture::Linear);
+ }
m_textures.append(texture);
node->setTargetRect(rect);
node->setInnerTargetRect(rect);
node->setTexture(texture);
+ if (m_ownerElement->smooth()) {
+ node->setFiltering(QSGTexture::Linear);
+ node->setMipmapFiltering(QSGTexture::Linear);
+ }
appendChildNode(node);
node->update();
}
diff --git a/src/quick/items/qquickwindow.cpp b/src/quick/items/qquickwindow.cpp
index 0db19fa51f..45341643be 100644
--- a/src/quick/items/qquickwindow.cpp
+++ b/src/quick/items/qquickwindow.cpp
@@ -630,6 +630,8 @@ bool QQuickWindowPrivate::deliverTouchAsMouse(QQuickItem *item, QQuickPointerEve
// FIXME: make this work for mouse events too and get rid of the asTouchEvent in here.
Q_ASSERT(pointerEvent->asPointerTouchEvent());
QTouchEvent *event = pointerEvent->asPointerTouchEvent()->touchEventForItem(item);
+ if (!event)
+ return false;
// For each point, check if it is accepted, if not, try the next point.
// Any of the fingers can become the mouse one.
@@ -1509,6 +1511,15 @@ bool QQuickWindow::event(QEvent *e)
// return in order to avoid the QWindow::event below
return d->deliverTouchCancelEvent(static_cast<QTouchEvent*>(e));
break;
+ case QEvent::Enter: {
+ QEnterEvent *enter = static_cast<QEnterEvent*>(e);
+ bool accepted = enter->isAccepted();
+ bool delivered = d->deliverHoverEvent(d->contentItem, enter->windowPos(), d->lastMousePosition,
+ QGuiApplication::keyboardModifiers(), 0L, accepted);
+ enter->setAccepted(accepted);
+ return delivered;
+ }
+ break;
case QEvent::Leave:
d->clearHover();
d->lastMousePosition = QPointF();
diff --git a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp
index 561eccdb0c..e1aea290a3 100644
--- a/src/quick/scenegraph/util/qsgdefaultpainternode.cpp
+++ b/src/quick/scenegraph/util/qsgdefaultpainternode.cpp
@@ -225,7 +225,7 @@ void QSGDefaultPainterNode::updateGeometry()
if (m_actualRenderTarget == QQuickPaintedItem::Image)
source = QRectF(0, 0, 1, 1);
else
- source = QRectF(0, 0, qreal(m_size.width()) / m_fboSize.width(), qreal(m_size.height()) / m_fboSize.height());
+ source = QRectF(0, 0, qreal(m_textureSize.width()) / m_fboSize.width(), qreal(m_textureSize.height()) / m_fboSize.height());
QRectF dest(0, 0, m_size.width(), m_size.height());
if (m_actualRenderTarget == QQuickPaintedItem::InvertedYFramebufferObject)
dest = QRectF(QPointF(0, m_size.height()), QPointF(m_size.width(), 0));
@@ -307,7 +307,7 @@ void QSGDefaultPainterNode::updateRenderTarget()
QSGPainterTexture *texture = new QSGPainterTexture;
if (m_actualRenderTarget == QQuickPaintedItem::Image) {
texture->setOwnsTexture(true);
- texture->setTextureSize(m_size);
+ texture->setTextureSize(m_textureSize);
} else {
texture->setTextureId(m_fbo->texture());
texture->setOwnsTexture(false);
diff --git a/tests/auto/qml/qqmltypeloader/data/MyComponent.qml b/tests/auto/qml/qqmltypeloader/data/MyComponent.qml
new file mode 100644
index 0000000000..a642518199
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/MyComponent.qml
@@ -0,0 +1,11 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 100
+ height: 62
+
+ MyComponent3 {}
+
+ MyComponent2 {}
+}
+
diff --git a/tests/auto/qml/qqmltypeloader/data/MyComponent2.qml b/tests/auto/qml/qqmltypeloader/data/MyComponent2.qml
new file mode 100644
index 0000000000..02cf5cb5dd
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/MyComponent2.qml
@@ -0,0 +1,7 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 100
+ height: 62
+}
+
diff --git a/tests/auto/qml/qqmltypeloader/data/MyComponent3.qml b/tests/auto/qml/qqmltypeloader/data/MyComponent3.qml
new file mode 100644
index 0000000000..ad5d569197
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/MyComponent3.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.0
+
+Rectangle {
+ width: 100
+ height: 62
+
+ MyComponent4 {}
+}
+
diff --git a/tests/auto/qml/qqmltypeloader/data/trim_cache2.qml b/tests/auto/qml/qqmltypeloader/data/trim_cache2.qml
new file mode 100644
index 0000000000..326a720a87
--- /dev/null
+++ b/tests/auto/qml/qqmltypeloader/data/trim_cache2.qml
@@ -0,0 +1,13 @@
+import QtQuick 2.0
+
+Item {
+ width: 400
+ height: 400
+
+ Component.onCompleted: {
+ var component = Qt.createComponent("MyComponent.qml")
+ if (component.status == Component.Error)
+ console.log(component.errorString())
+ }
+}
+
diff --git a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
index 74f3929783..3d3a7ff725 100644
--- a/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
+++ b/tests/auto/qml/qqmltypeloader/tst_qqmltypeloader.cpp
@@ -42,6 +42,7 @@ private slots:
void testLoadComplete();
void loadComponentSynchronously();
void trimCache();
+ void trimCache2();
};
void tst_QQMLTypeLoader::testLoadComplete()
@@ -106,6 +107,19 @@ void tst_QQMLTypeLoader::trimCache()
}
}
+void tst_QQMLTypeLoader::trimCache2()
+{
+ QQuickView *window = new QQuickView();
+ window->setSource(testFileUrl("trim_cache2.qml"));
+ QQmlTypeLoader &loader = QQmlEnginePrivate::get(window->engine())->typeLoader;
+ // in theory if gc has already run this could be false
+ // QCOMPARE(loader.isTypeLoaded(testFileUrl("MyComponent2.qml")), true);
+ window->engine()->collectGarbage();
+ QTest::qWait(1); // force event loop
+ window->engine()->trimComponentCache();
+ QCOMPARE(loader.isTypeLoaded(testFileUrl("MyComponent2.qml")), false);
+}
+
QTEST_MAIN(tst_QQMLTypeLoader)
#include "tst_qqmltypeloader.moc"
diff --git a/tests/auto/quick/qquicklayouts/data/rowlayout/Container.qml b/tests/auto/quick/qquicklayouts/data/rowlayout/Container.qml
new file mode 100644
index 0000000000..22205c18f0
--- /dev/null
+++ b/tests/auto/quick/qquicklayouts/data/rowlayout/Container.qml
@@ -0,0 +1,55 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.7
+import QtQuick.Layouts 1.3
+
+Item {
+ objectName: "qtbug51927-window"
+ visible: true
+
+ default property alias _contents: customContent.data
+
+ RowLayout {
+ id: customContent
+ objectName: "qtbug51927-columnLayout"
+ anchors.fill: parent
+ }
+}
diff --git a/tests/auto/quick/qquicklayouts/data/rowlayout/ContainerUser.qml b/tests/auto/quick/qquicklayouts/data/rowlayout/ContainerUser.qml
new file mode 100644
index 0000000000..ff7ce6221b
--- /dev/null
+++ b/tests/auto/quick/qquicklayouts/data/rowlayout/ContainerUser.qml
@@ -0,0 +1,53 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** Contact: http://www.qt.io/licensing/
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:BSD$
+** You may use this file under the terms of the BSD license as follows:
+**
+** "Redistribution and use in source and binary forms, with or without
+** modification, are permitted provided that the following conditions are
+** met:
+** * Redistributions of source code must retain the above copyright
+** notice, this list of conditions and the following disclaimer.
+** * Redistributions in binary form must reproduce the above copyright
+** notice, this list of conditions and the following disclaimer in
+** the documentation and/or other materials provided with the
+** distribution.
+** * Neither the name of The Qt Company Ltd nor the names of its
+** contributors may be used to endorse or promote products derived
+** from this software without specific prior written permission.
+**
+**
+** THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+** "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+** LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+** A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+** OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+** SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+** LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+** DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+** THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+** (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+** OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE."
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+import QtQuick 2.6
+import QtQuick.Window 2.2
+
+Container {
+ visible: true
+
+ Text {
+ objectName: "qtbug51927-text"
+ text: qsTr("Hello World")
+ anchors.centerIn: parent
+ renderType: Text.QtRendering
+ }
+}
diff --git a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
index 33b8fd0e4e..2d4e227a9e 100644
--- a/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
+++ b/tests/auto/quick/qquicklayouts/data/tst_rowlayout.qml
@@ -926,5 +926,17 @@ Item {
waitForRendering(layout)
layout.destroy()
}
+
+
+ function test_defaultPropertyAliasCrash() {
+ var containerUserComponent = Qt.createComponent("rowlayout/ContainerUser.qml");
+ compare(containerUserComponent.status, Component.Ready);
+
+ var containerUser = containerUserComponent.createObject(testCase);
+ verify(containerUser);
+
+ // Shouldn't crash.
+ containerUser.destroy();
+ }
}
}
diff --git a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
index 17c09805aa..cabfb97914 100644
--- a/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
+++ b/tests/auto/quick/qquickvisualdatamodel/tst_qquickvisualdatamodel.cpp
@@ -4094,9 +4094,10 @@ void tst_qquickvisualdatamodel::asynchronousRemove()
controller.incubateFor(50);
} while (timer.elapsed() < 1000 && controller.incubatingObjectCount() > 0);
- QVERIFY(requester.itemInitialized);
- QCOMPARE(requester.itemCreated, requester.itemInitialized);
- QCOMPARE(requester.itemDestroyed, requester.itemInitialized);
+ // The item was removed before incubation started. We should not have any item created.
+ QVERIFY(!requester.itemInitialized);
+ QVERIFY(!requester.itemCreated);
+ QVERIFY(!requester.itemDestroyed);
} else {
item = qobject_cast<QQuickItem*>(visualModel->object(completeIndex, false));
QVERIFY(item);
diff --git a/tests/auto/quick/touchmouse/tst_touchmouse.cpp b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
index baa4bcb21c..1594da46bd 100644
--- a/tests/auto/quick/touchmouse/tst_touchmouse.cpp
+++ b/tests/auto/quick/touchmouse/tst_touchmouse.cpp
@@ -1336,8 +1336,12 @@ void tst_TouchMouse::hoverEnabled()
// device->setType(QTouchDevice::TouchScreen);
// QWindowSystemInterface::registerTouchDevice(device);
+ // Ensure the cursor is away from the window
+ QCursor::setPos(0, 0);
+
QQuickView *window = createView();
window->setSource(testFileUrl("hoverMouseAreas.qml"));
+ window->setPosition(10, 10);
window->show();
window->requestActivate();