forked from qt-creator/qt-creator
QmlDesigner: Add mutex
Creating models can trigger this initialization potentially from multiple threads. Task-number: QDS-6429 Change-Id: I1e9f715c150e37e6381c3f4e94fe6de1aaec7556 Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
This commit is contained in:
@@ -32,9 +32,9 @@
|
|||||||
#include <coreplugin/messagebox.h>
|
#include <coreplugin/messagebox.h>
|
||||||
#include "pluginmanager/widgetpluginmanager.h"
|
#include "pluginmanager/widgetpluginmanager.h"
|
||||||
|
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
|
#include <QMutex>
|
||||||
|
|
||||||
enum {
|
enum {
|
||||||
debug = false
|
debug = false
|
||||||
@@ -107,6 +107,7 @@ void MetaInfoPrivate::parseItemLibraryDescriptions()
|
|||||||
using QmlDesigner::Internal::MetaInfoPrivate;
|
using QmlDesigner::Internal::MetaInfoPrivate;
|
||||||
|
|
||||||
MetaInfo MetaInfo::s_global;
|
MetaInfo MetaInfo::s_global;
|
||||||
|
QMutex s_lock;
|
||||||
QStringList MetaInfo::s_pluginDirs;
|
QStringList MetaInfo::s_pluginDirs;
|
||||||
|
|
||||||
|
|
||||||
@@ -157,6 +158,8 @@ ItemLibraryInfo *MetaInfo::itemLibraryInfo() const
|
|||||||
*/
|
*/
|
||||||
MetaInfo MetaInfo::global()
|
MetaInfo MetaInfo::global()
|
||||||
{
|
{
|
||||||
|
QMutexLocker locker(&s_lock);
|
||||||
|
|
||||||
if (!s_global.m_p->m_isInitialized) {
|
if (!s_global.m_p->m_isInitialized) {
|
||||||
s_global.m_p = QSharedPointer<MetaInfoPrivate>(new MetaInfoPrivate(&s_global));
|
s_global.m_p = QSharedPointer<MetaInfoPrivate>(new MetaInfoPrivate(&s_global));
|
||||||
s_global.m_p->initialize();
|
s_global.m_p->initialize();
|
||||||
|
Reference in New Issue
Block a user