diff options
author | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-09-05 15:31:08 +0200 |
---|---|---|
committer | Sergio Ahumada <sergio.ahumada@digia.com> | 2013-09-06 10:11:04 +0200 |
commit | af44559780765c7121a49c2e0764cf24e740312d (patch) | |
tree | a4f2f50ddfe969f33a4d4accd392523c6809fd5a /src/qml | |
parent | 8784a4a46ea1357bde546c9a1c88bd060e863f30 (diff) | |
parent | b30d7c9ee8fbc3a395c74b618f2ab176ae1e7f7e (diff) |
Merge branch 'stable' into dev
Conflicts:
src/qml/debugger/qv8debugservice.cpp
src/qml/qml/v8/qv8engine.cpp
tests/auto/quick/qquickitem/qquickitem.pro
Change-Id: Ic4a1dcdd8b8a84155d2f2abefdf1da5c3a56af31
Diffstat (limited to 'src/qml')
-rw-r--r-- | src/qml/debugger/qv8debugservice.cpp | 8 | ||||
-rw-r--r-- | src/qml/debugger/qv8debugservice_p.h | 3 | ||||
-rw-r--r-- | src/qml/jsapi/qjsvalueiterator.h | 6 | ||||
-rw-r--r-- | src/qml/qml/qqmlcompiler.cpp | 4 | ||||
-rw-r--r-- | src/qml/qml/qqmlengine.cpp | 3 | ||||
-rw-r--r-- | src/qml/qml/qqmlimport.cpp | 54 |
6 files changed, 55 insertions, 23 deletions
diff --git a/src/qml/debugger/qv8debugservice.cpp b/src/qml/debugger/qv8debugservice.cpp index eeab21d6ab..2195dad089 100644 --- a/src/qml/debugger/qv8debugservice.cpp +++ b/src/qml/debugger/qv8debugservice.cpp @@ -146,12 +146,18 @@ QV8DebugService *QV8DebugService::instance() return v8ServiceInstance(); } -void QV8DebugService::initialize(const QV8Engine *engine) +void QV8DebugService::addEngine(const QV8Engine *engine) { // just make sure that the service is properly registered v8ServiceInstance()->setEngine(engine); } +void QV8DebugService::removeEngine(const QV8Engine *engine) +{ + if (v8ServiceInstance()->d_func()->engine == engine) + v8ServiceInstance()->setEngine(0); +} + void QV8DebugService::setEngine(const QV8Engine *engine) { Q_D(QV8DebugService); diff --git a/src/qml/debugger/qv8debugservice_p.h b/src/qml/debugger/qv8debugservice_p.h index e6f05a2397..75fd69290c 100644 --- a/src/qml/debugger/qv8debugservice_p.h +++ b/src/qml/debugger/qv8debugservice_p.h @@ -75,7 +75,8 @@ public: ~QV8DebugService(); static QV8DebugService *instance(); - static void initialize(const QV8Engine *engine); + static void addEngine(const QV8Engine *engine); + static void removeEngine(const QV8Engine *engine); void debugMessageHandler(const QString &message); diff --git a/src/qml/jsapi/qjsvalueiterator.h b/src/qml/jsapi/qjsvalueiterator.h index e204558e90..9bbcc7bc3e 100644 --- a/src/qml/jsapi/qjsvalueiterator.h +++ b/src/qml/jsapi/qjsvalueiterator.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QSCRIPTVALUEITERATOR_H -#define QSCRIPTVALUEITERATOR_H +#ifndef QJSVALUEITERATOR_H +#define QJSVALUEITERATOR_H #include <QtQml/qjsvalue.h> #include <QtQml/qtqmlglobal.h> @@ -75,4 +75,4 @@ private: QT_END_NAMESPACE -#endif // QSCRIPTVALUEITERATOR_H +#endif // QJSVALUEITERATOR_H diff --git a/src/qml/qml/qqmlcompiler.cpp b/src/qml/qml/qqmlcompiler.cpp index ddefffe8e2..6bc9128730 100644 --- a/src/qml/qml/qqmlcompiler.cpp +++ b/src/qml/qml/qqmlcompiler.cpp @@ -1747,7 +1747,9 @@ bool QQmlCompiler::buildProperty(QQmlScript::Property *prop, if (d == 0 && notInRevision) { const QList<QQmlTypeData::TypeReference> &resolvedTypes = unit->resolvedTypes(); - const QQmlTypeData::TypeReference &type = resolvedTypes.at(obj->type); + QQmlTypeData::TypeReference type; + if (obj->type != -1) + type = resolvedTypes.at(obj->type); if (type.type) { COMPILE_EXCEPTION(prop, tr("\"%1.%2\" is not available in %3 %4.%5.").arg(elementName(obj)).arg(prop->name().toString()).arg(type.type->module()).arg(type.majorVersion).arg(type.minorVersion)); } else { diff --git a/src/qml/qml/qqmlengine.cpp b/src/qml/qml/qqmlengine.cpp index 5c59cc3383..39c3399917 100644 --- a/src/qml/qml/qqmlengine.cpp +++ b/src/qml/qml/qqmlengine.cpp @@ -757,7 +757,7 @@ void QQmlEnginePrivate::init() QQmlEngineDebugService::isDebuggingEnabled()) { isDebugging = true; QQmlEngineDebugService::instance()->addEngine(q); - QV8DebugService::initialize(v8engine()); + QV8DebugService::addEngine(v8engine()); QV8ProfilerService::initialize(); QQmlProfilerService::initialize(); QDebugMessageService::instance(); @@ -846,6 +846,7 @@ QQmlEngine::~QQmlEngine() Q_D(QQmlEngine); if (d->isDebugging) { QQmlEngineDebugService::instance()->remEngine(this); + QV8DebugService::removeEngine(handle()); } // Emit onDestruction signals for the root context before diff --git a/src/qml/qml/qqmlimport.cpp b/src/qml/qml/qqmlimport.cpp index 816f9cec0f..85c6a4246a 100644 --- a/src/qml/qml/qqmlimport.cpp +++ b/src/qml/qml/qqmlimport.cpp @@ -161,13 +161,20 @@ QQmlType *getTypeForUrl(const QString &urlString, const QHashedStringRef& typeNa } -typedef QMap<QString, QString> StringStringMap; -Q_GLOBAL_STATIC(StringStringMap, qmlEnginePluginsWithRegisteredTypes); // stores the uri +struct RegisteredPlugin { + QString uri; + QPluginLoader* loader; +}; + +typedef QMap<QString, RegisteredPlugin> StringRegisteredPluginMap; +Q_GLOBAL_STATIC(StringRegisteredPluginMap, qmlEnginePluginsWithRegisteredTypes); // stores the uri and the PluginLoaders void qmlClearEnginePlugins() { - foreach (const QString &s, qmlEnginePluginsWithRegisteredTypes()->values()) { - QPluginLoader loader(s); - loader.unload(); // ### Always returns false, worth doing? + foreach (RegisteredPlugin plugin, qmlEnginePluginsWithRegisteredTypes()->values()) { + QPluginLoader* loader = plugin.loader; + if (!loader->unload()) + qWarning("Unloading %s failed: %s", qPrintable(plugin.uri), qPrintable(loader->errorString())); + delete loader; } qmlEnginePluginsWithRegisteredTypes()->clear(); } @@ -1634,7 +1641,7 @@ bool QQmlImportDatabase::importPlugin(const QString &filePath, const QString &ur bool typesRegistered = qmlEnginePluginsWithRegisteredTypes()->contains(absoluteFilePath); if (typesRegistered) { - Q_ASSERT_X(qmlEnginePluginsWithRegisteredTypes()->value(absoluteFilePath) == uri, + Q_ASSERT_X(qmlEnginePluginsWithRegisteredTypes()->value(absoluteFilePath).uri == uri, "QQmlImportDatabase::importPlugin", "Internal error: Plugin imported previously with different uri"); } @@ -1648,25 +1655,37 @@ bool QQmlImportDatabase::importPlugin(const QString &filePath, const QString &ur } return false; } - QPluginLoader loader(absoluteFilePath); - if (!loader.load()) { - if (errors) { - QQmlError error; - error.setDescription(loader.errorString()); - errors->prepend(error); + QPluginLoader* loader = 0; + if (!typesRegistered) { + loader = new QPluginLoader(absoluteFilePath); + + if (!loader->load()) { + if (errors) { + QQmlError error; + error.setDescription(loader->errorString()); + errors->prepend(error); + + delete loader; + } + return false; } - return false; + } else { + loader = qmlEnginePluginsWithRegisteredTypes()->value(absoluteFilePath).loader; } - QObject *instance = loader.instance(); + QObject *instance = loader->instance(); if (QQmlTypesExtensionInterface *iface = qobject_cast<QQmlExtensionInterface *>(instance)) { const QByteArray bytes = uri.toUtf8(); const char *moduleId = bytes.constData(); if (!typesRegistered) { - qmlEnginePluginsWithRegisteredTypes()->insert(absoluteFilePath, uri); + RegisteredPlugin plugin; + plugin.uri = uri; + plugin.loader = loader; + + qmlEnginePluginsWithRegisteredTypes()->insert(absoluteFilePath, plugin); QStringList registrationFailures; @@ -1734,8 +1753,11 @@ bool QQmlImportDatabase::importPlugin(const QString &filePath, const QString &ur } else { if (errors) { QQmlError error; - error.setDescription(loader.errorString()); + error.setDescription(loader->errorString()); errors->prepend(error); + + if (!typesRegistered) + delete loader; } return false; } |