mirror of
https://bitbucket.org/smil3y/katie.git
synced 2025-02-25 03:12:56 +00:00
lock before accessing global QML plugins map
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
parent
45dad6d585
commit
6d1e5f56a6
1 changed files with 5 additions and 6 deletions
|
@ -44,6 +44,7 @@ static bool greaterThan(const QString &s1, const QString &s2)
|
||||||
}
|
}
|
||||||
|
|
||||||
typedef QMap<QString, QString> StringStringMap;
|
typedef QMap<QString, QString> StringStringMap;
|
||||||
|
Q_GLOBAL_STATIC(QMutex, qmlEnginePluginsWithRegisteredTypesMutex)
|
||||||
Q_GLOBAL_STATIC(StringStringMap, qmlEnginePluginsWithRegisteredTypes) // stores the uri
|
Q_GLOBAL_STATIC(StringStringMap, qmlEnginePluginsWithRegisteredTypes) // stores the uri
|
||||||
|
|
||||||
class QDeclarativeImportedNamespace
|
class QDeclarativeImportedNamespace
|
||||||
|
@ -897,6 +898,7 @@ bool QDeclarativeImportDatabase::importPlugin(const QString &filePath, const QSt
|
||||||
QFileInfo fileInfo(filePath);
|
QFileInfo fileInfo(filePath);
|
||||||
const QString absoluteFilePath = fileInfo.absoluteFilePath();
|
const QString absoluteFilePath = fileInfo.absoluteFilePath();
|
||||||
|
|
||||||
|
QMutexLocker locker(qmlEnginePluginsWithRegisteredTypesMutex());
|
||||||
bool engineInitialized = initializedPlugins.contains(absoluteFilePath);
|
bool engineInitialized = initializedPlugins.contains(absoluteFilePath);
|
||||||
bool typesRegistered = qmlEnginePluginsWithRegisteredTypes()->contains(absoluteFilePath);
|
bool typesRegistered = qmlEnginePluginsWithRegisteredTypes()->contains(absoluteFilePath);
|
||||||
|
|
||||||
|
@ -917,20 +919,17 @@ bool QDeclarativeImportDatabase::importPlugin(const QString &filePath, const QSt
|
||||||
|
|
||||||
if (QDeclarativeExtensionInterface *iface = qobject_cast<QDeclarativeExtensionInterface *>(loader.instance())) {
|
if (QDeclarativeExtensionInterface *iface = qobject_cast<QDeclarativeExtensionInterface *>(loader.instance())) {
|
||||||
|
|
||||||
const QByteArray bytes = uri.toUtf8();
|
const QByteArray moduleId = uri.toUtf8();
|
||||||
const char *moduleId = bytes.constData();
|
|
||||||
if (!typesRegistered) {
|
if (!typesRegistered) {
|
||||||
|
|
||||||
// ### this code should probably be protected with a mutex.
|
|
||||||
qmlEnginePluginsWithRegisteredTypes()->insert(absoluteFilePath, uri);
|
qmlEnginePluginsWithRegisteredTypes()->insert(absoluteFilePath, uri);
|
||||||
iface->registerTypes(moduleId);
|
iface->registerTypes(moduleId.constData());
|
||||||
}
|
}
|
||||||
if (!engineInitialized) {
|
if (!engineInitialized) {
|
||||||
// things on the engine (eg. adding new global objects) have to be done for every engine.
|
// things on the engine (eg. adding new global objects) have to be done for every engine.
|
||||||
|
|
||||||
// protect against double initialization
|
// protect against double initialization
|
||||||
initializedPlugins.insert(absoluteFilePath);
|
initializedPlugins.insert(absoluteFilePath);
|
||||||
iface->initializeEngine(engine, moduleId);
|
iface->initializeEngine(engine, moduleId.constData());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (errorString)
|
if (errorString)
|
||||||
|
|
Loading…
Add table
Reference in a new issue