aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/types
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@digia.com>2014-06-03 15:28:51 +0200
committerSimon Hausmann <simon.hausmann@digia.com>2014-06-04 17:02:55 +0200
commit11a11d1280b1634628b9c4a92a0fc420ee8a3a81 (patch)
treeb48d9608ef3f08123cdeea605068342131b32b44 /src/qml/types
parent52e07d564b65ed6ce26955a676c7692ad67686c1 (diff)
parentfea26bb2941c3f24c4a5f3ad5efc1b85e0123ff3 (diff)
Merge remote-tracking branch 'origin/stable' into dev
The merge conflict is about the removal of "d1" from the register set on ARM, but that was already done in dev in commit ddb33ee9ba9e1344caa9be5dbf4b534c3ede692e The change in src/quick/scenegraph/coreapi/qsgrenderer.cpp with commit 2414f1675eab163b22dcc4e8ded80ed04d06369b was reverted to what it was before, per Laszlo's advice. Conflicts: src/qml/jit/qv4isel_masm.cpp Change-Id: I7bce546c5cdee01e37853a476d82279d4e72948b
Diffstat (limited to 'src/qml/types')
-rw-r--r--src/qml/types/qqmllistmodel.cpp44
-rw-r--r--src/qml/types/qqmllistmodel_p.h3
-rw-r--r--src/qml/types/qquickworkerscript.cpp54
3 files changed, 74 insertions, 27 deletions
diff --git a/src/qml/types/qqmllistmodel.cpp b/src/qml/types/qqmllistmodel.cpp
index 1b074efd56..a0148715ce 100644
--- a/src/qml/types/qqmllistmodel.cpp
+++ b/src/qml/types/qqmllistmodel.cpp
@@ -1694,13 +1694,20 @@ void QQmlListModel::emitItemsChanged(int index, int count, const QVector<int> &r
}
}
+void QQmlListModel::emitItemsAboutToBeRemoved(int index, int count)
+{
+ if (count <= 0 || !m_mainThread)
+ return;
+
+ beginRemoveRows(QModelIndex(), index, index + count - 1);
+}
+
void QQmlListModel::emitItemsRemoved(int index, int count)
{
if (count <= 0)
return;
if (m_mainThread) {
- beginRemoveRows(QModelIndex(), index, index + count - 1);
endRemoveRows();
emit countChanged();
} else {
@@ -1711,13 +1718,20 @@ void QQmlListModel::emitItemsRemoved(int index, int count)
}
}
+void QQmlListModel::emitItemsAboutToBeInserted(int index, int count)
+{
+ if (count <= 0 || !m_mainThread)
+ return;
+
+ beginInsertRows(QModelIndex(), index, index + count - 1);
+}
+
void QQmlListModel::emitItemsInserted(int index, int count)
{
if (count <= 0)
return;
if (m_mainThread) {
- beginInsertRows(QModelIndex(), index, index + count - 1);
endInsertRows();
emit countChanged();
} else {
@@ -1726,13 +1740,20 @@ void QQmlListModel::emitItemsInserted(int index, int count)
}
}
+void QQmlListModel::emitItemsAboutToBeMoved(int from, int to, int n)
+{
+ if (n <= 0 || !m_mainThread)
+ return;
+
+ beginMoveRows(QModelIndex(), from, from + n - 1, QModelIndex(), to > from ? to + n : to);
+}
+
void QQmlListModel::emitItemsMoved(int from, int to, int n)
{
if (n <= 0)
return;
if (m_mainThread) {
- beginMoveRows(QModelIndex(), from, from + n - 1, QModelIndex(), to > from ? to + n : to);
endMoveRows();
} else {
int uid = m_dynamicRoles ? getUid() : m_listModel->getUid();
@@ -1872,6 +1893,8 @@ void QQmlListModel::clear()
{
int cleared = count();
+ emitItemsAboutToBeRemoved(0, cleared);
+
if (m_dynamicRoles) {
for (int i=0 ; i < m_modelObjects.count() ; ++i)
delete m_modelObjects[i];
@@ -1904,6 +1927,8 @@ void QQmlListModel::remove(QQmlV4Function *args)
return;
}
+ emitItemsAboutToBeRemoved(index, removeCount);
+
if (m_dynamicRoles) {
for (int i=0 ; i < removeCount ; ++i)
delete m_modelObjects[index+i];
@@ -1952,6 +1977,7 @@ void QQmlListModel::insert(QQmlV4Function *args)
QV4::ScopedObject argObject(scope);
int objectArrayLength = objectArray->getLength();
+ emitItemsAboutToBeInserted(index, objectArrayLength);
for (int i=0 ; i < objectArrayLength ; ++i) {
argObject = objectArray->getIndexed(i);
@@ -1963,6 +1989,8 @@ void QQmlListModel::insert(QQmlV4Function *args)
}
emitItemsInserted(index, objectArrayLength);
} else if (argObject) {
+ emitItemsAboutToBeInserted(index, 1);
+
if (m_dynamicRoles) {
m_modelObjects.insert(index, DynamicRoleModelNode::create(args->engine()->variantMapFromJS(argObject), this));
} else {
@@ -2001,6 +2029,8 @@ void QQmlListModel::move(int from, int to, int n)
return;
}
+ emitItemsAboutToBeMoved(from, to, n);
+
if (m_dynamicRoles) {
int realFrom = from;
@@ -2056,6 +2086,8 @@ void QQmlListModel::append(QQmlV4Function *args)
int objectArrayLength = objectArray->getLength();
int index = count();
+ emitItemsAboutToBeInserted(index, objectArrayLength);
+
for (int i=0 ; i < objectArrayLength ; ++i) {
argObject = objectArray->getIndexed(i);
@@ -2072,9 +2104,12 @@ void QQmlListModel::append(QQmlV4Function *args)
if (m_dynamicRoles) {
index = m_modelObjects.count();
+ emitItemsAboutToBeInserted(index, 1);
m_modelObjects.append(DynamicRoleModelNode::create(args->engine()->variantMapFromJS(argObject), this));
} else {
- index = m_listModel->append(argObject, args->engine());
+ index = m_listModel->elementCount();
+ emitItemsAboutToBeInserted(index, 1);
+ m_listModel->append(argObject, args->engine());
}
emitItemsInserted(index, 1);
@@ -2169,6 +2204,7 @@ void QQmlListModel::set(int index, const QQmlV4Handle &handle)
if (index == count()) {
+ emitItemsAboutToBeInserted(index, 1);
if (m_dynamicRoles) {
m_modelObjects.append(DynamicRoleModelNode::create(engine()->variantMapFromJS(object), this));
diff --git a/src/qml/types/qqmllistmodel_p.h b/src/qml/types/qqmllistmodel_p.h
index 59cfce81e5..8c12173425 100644
--- a/src/qml/types/qqmllistmodel_p.h
+++ b/src/qml/types/qqmllistmodel_p.h
@@ -144,8 +144,11 @@ private:
static QQmlListModel *createWithOwner(QQmlListModel *newOwner);
void emitItemsChanged(int index, int count, const QVector<int> &roles);
+ void emitItemsAboutToBeRemoved(int index, int count);
void emitItemsRemoved(int index, int count);
+ void emitItemsAboutToBeInserted(int index, int count);
void emitItemsInserted(int index, int count);
+ void emitItemsAboutToBeMoved(int from, int to, int n);
void emitItemsMoved(int from, int to, int n);
};
diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp
index 507e94fb7e..80c4112930 100644
--- a/src/qml/types/qquickworkerscript.cpp
+++ b/src/qml/types/qquickworkerscript.cpp
@@ -382,36 +382,44 @@ void QQuickWorkerScriptEnginePrivate::processLoad(int id, const QUrl &url)
QString fileName = QQmlFile::urlToLocalFileOrQrc(url);
- QFile f(fileName);
- if (f.open(QIODevice::ReadOnly)) {
- QByteArray data = f.readAll();
- QString sourceCode = QString::fromUtf8(data);
- QmlIR::Document::removeScriptPragmas(sourceCode);
+ QV4::ExecutionEngine *v4 = QV8Engine::getV4(workerEngine);
+ QV4::Scope scope(v4);
+ QScopedPointer<QV4::Script> program;
- WorkerScript *script = workers.value(id);
- if (!script)
- return;
- script->source = url;
+ WorkerScript *script = workers.value(id);
+ if (!script)
+ return;
+ script->source = url;
- QV4::ExecutionEngine *v4 = QV8Engine::getV4(workerEngine);
- QV4::Scope scope(v4);
+ QV4::Scoped<QV4::Object> activation(scope, getWorker(script));
+ if (!activation)
+ return;
- QV4::Scoped<QV4::Object> activation(scope, getWorker(script));
- if (!activation)
+ if (const QQmlPrivate::CachedQmlUnit *cachedUnit = QQmlMetaType::findCachedCompilationUnit(url)) {
+ QV4::CompiledData::CompilationUnit *jsUnit = cachedUnit->createCompilationUnit();
+ program.reset(new QV4::Script(v4, activation, jsUnit));
+ } else {
+ QFile f(fileName);
+ if (!f.open(QIODevice::ReadOnly)) {
+ qWarning().nospace() << "WorkerScript: Cannot find source file " << url.toString();
return;
+ }
+
+ QByteArray data = f.readAll();
+ QString sourceCode = QString::fromUtf8(data);
+ QmlIR::Document::removeScriptPragmas(sourceCode);
- QV4::Script program(v4, activation, sourceCode, url.toString());
+ program.reset(new QV4::Script(v4, activation, sourceCode, url.toString()));
+ program->parse();
+ }
+
+ if (!v4->hasException)
+ program->run();
+ if (v4->hasException) {
QV4::ExecutionContext *ctx = v4->currentContext();
- program.parse();
- if (!v4->hasException)
- program.run();
- if (v4->hasException) {
- QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
- reportScriptException(script, error);
- }
- } else {
- qWarning().nospace() << "WorkerScript: Cannot find source file " << url.toString();
+ QQmlError error = QV4::ExecutionEngine::catchExceptionAsQmlError(ctx);
+ reportScriptException(script, error);
}
}