Commit ef963635 authored by Christian Kamm's avatar Christian Kamm
Browse files

QmlJS: Fix plugin dumpers running all the time if dump fails.

Task-number: QTCREATORBUG-2733
Reviewed-by: Kai Koehne
parent 87bb2276
......@@ -358,6 +358,7 @@ LibraryInfo::LibraryInfo(const QmlDirParser &parser)
: _valid(true)
, _components(parser.components())
, _plugins(parser.plugins())
, _dumped(false)
{
}
......
......@@ -122,6 +122,7 @@ class QMLJS_EXPORT LibraryInfo
QList<QmlDirParser::Plugin> _plugins;
typedef QList<const Interpreter::FakeMetaObject *> FakeMetaObjectList;
FakeMetaObjectList _metaObjects;
bool _dumped;
public:
LibraryInfo();
......@@ -142,6 +143,12 @@ public:
bool isValid() const
{ return _valid; }
bool isDumped() const
{ return _dumped; }
void setDumped(bool dumped)
{ _dumped = dumped; }
};
class QMLJS_EXPORT Snapshot
......
......@@ -472,6 +472,8 @@ void ModelManager::onLoadPluginTypes(const QString &libraryPath, const QString &
const QString canonicalLibraryPath = QDir::cleanPath(libraryPath);
if (m_runningQmldumps.values().contains(canonicalLibraryPath))
return;
if (_snapshot.libraryInfo(canonicalLibraryPath).isDumped())
return;
ProjectExplorer::Project *activeProject = ProjectExplorer::ProjectExplorerPlugin::instance()->startupProject();
if (!activeProject)
......@@ -526,36 +528,33 @@ void ModelManager::qmlPluginTypeDumpDone(int exitCode)
process->deleteLater();
const QString libraryPath = m_runningQmldumps.take(process);
LibraryInfo libraryInfo = _snapshot.libraryInfo(libraryPath);
libraryInfo.setDumped(true);
if (exitCode != 0) {
Core::MessageManager *messageManager = Core::MessageManager::instance();
messageManager->printToOutputPane(qmldumpErrorMessage(libraryPath, process->readAllStandardError()));
return;
}
const QByteArray output = process->readAllStandardOutput();
QMap<QString, Interpreter::FakeMetaObject *> newObjects;
const QString error = Interpreter::CppQmlTypesLoader::parseQmlTypeXml(output, &newObjects);
if (!error.isEmpty())
return;
// convert from QList<T *> to QList<const T *>
QList<const Interpreter::FakeMetaObject *> objectsList;
QMapIterator<QString, Interpreter::FakeMetaObject *> it(newObjects);
while (it.hasNext()) {
it.next();
objectsList.append(it.value());
}
QMutexLocker locker(&m_mutex);
if (!libraryPath.isEmpty()) {
LibraryInfo libraryInfo = _snapshot.libraryInfo(libraryPath);
if (exitCode == 0 && error.isEmpty()) {
// convert from QList<T *> to QList<const T *>
QList<const Interpreter::FakeMetaObject *> objectsList;
QMapIterator<QString, Interpreter::FakeMetaObject *> it(newObjects);
while (it.hasNext()) {
it.next();
objectsList.append(it.value());
}
libraryInfo.setMetaObjects(objectsList);
_snapshot.insertLibraryInfo(libraryPath, libraryInfo);
} else {
Interpreter::CppQmlTypesLoader::builtinObjects.append(objectsList);
if (libraryPath.isEmpty())
Interpreter::CppQmlTypesLoader::builtinObjects.append(objectsList);
}
if (!libraryPath.isEmpty())
emitLibraryInfoUpdated(libraryPath, libraryInfo);
}
void ModelManager::qmlPluginTypeDumpError(QProcess::ProcessError)
......@@ -569,4 +568,10 @@ void ModelManager::qmlPluginTypeDumpError(QProcess::ProcessError)
Core::MessageManager *messageManager = Core::MessageManager::instance();
messageManager->printToOutputPane(qmldumpErrorMessage(libraryPath, process->readAllStandardError()));
if (!libraryPath.isEmpty()) {
LibraryInfo libraryInfo = _snapshot.libraryInfo(libraryPath);
libraryInfo.setDumped(true);
emitLibraryInfoUpdated(libraryPath, libraryInfo);
}
}
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment