Commit 0fa0d00f authored by Christian Kamm's avatar Christian Kamm
Browse files

Qml: Write qmldump errors to 'General messages'.

This should make it easier to debug problems with Qml plugin type
dumping.

Reviewed-by: Roberto Raggi
parent 59a341d6
......@@ -34,6 +34,7 @@
#include <coreplugin/icore.h>
#include <coreplugin/editormanager/editormanager.h>
#include <coreplugin/progressmanager/progressmanager.h>
#include <coreplugin/messagemanager.h>
#include <coreplugin/mimedatabase.h>
#include <qmljs/qmljsinterpreter.h>
#include <qmljs/qmljsbind.h>
......@@ -497,6 +498,7 @@ void ModelManager::onLoadPluginTypes(const QString &libraryPath, const QString &
QProcess *process = new QProcess(this);
connect(process, SIGNAL(finished(int)), SLOT(qmlPluginTypeDumpDone(int)));
connect(process, SIGNAL(error(QProcess::ProcessError)), SLOT(qmlPluginTypeDumpError(QProcess::ProcessError)));
QStringList args;
args << importPath;
args << importUri;
......@@ -525,14 +527,25 @@ void ModelManager::updateImportPaths()
updateSourceFiles(importedFiles, true);
}
static QString qmldumpErrorMessage(const QString &libraryPath, const QString &error)
{
return ModelManager::tr("Type dump of QML plugin in %0 failed.\nErrors:\n%1\n").arg(libraryPath, error);
}
void ModelManager::qmlPluginTypeDumpDone(int exitCode)
{
QProcess *process = qobject_cast<QProcess *>(sender());
if (!process)
return;
process->deleteLater();
if (exitCode != 0)
const QString libraryPath = m_runningQmldumps.take(process);
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;
......@@ -548,8 +561,6 @@ void ModelManager::qmlPluginTypeDumpDone(int exitCode)
objectsList.append(it.value());
}
const QString libraryPath = m_runningQmldumps.take(process);
QMutexLocker locker(&m_mutex);
if (!libraryPath.isEmpty()) {
......@@ -560,3 +571,16 @@ void ModelManager::qmlPluginTypeDumpDone(int exitCode)
Interpreter::CppQmlTypesLoader::builtinObjects.append(objectsList);
}
}
void ModelManager::qmlPluginTypeDumpError(QProcess::ProcessError)
{
QProcess *process = qobject_cast<QProcess *>(sender());
if (!process)
return;
process->deleteLater();
const QString libraryPath = m_runningQmldumps.take(process);
Core::MessageManager *messageManager = Core::MessageManager::instance();
messageManager->printToOutputPane(qmldumpErrorMessage(libraryPath, process->readAllStandardError()));
}
......@@ -81,6 +81,7 @@ private Q_SLOTS:
void onLibraryInfoUpdated(const QString &path, const QmlJS::LibraryInfo &info);
void onLoadPluginTypes(const QString &libraryPath, const QString &importPath, const QString &importUri);
void qmlPluginTypeDumpDone(int exitCode);
void qmlPluginTypeDumpError(QProcess::ProcessError error);
protected:
struct WorkingCopy
......
......@@ -63,11 +63,13 @@ void processObject(QObject *object, QSet<const QMetaObject *> *metas)
return;
const QMetaObject *meta = object->metaObject();
qDebug() << "Processing object" << meta->className();
processMetaObject(meta, metas);
for (int index = 0; index < meta->propertyCount(); ++index) {
QMetaProperty prop = meta->property(index);
if (QDeclarativeMetaType::isQObject(prop.userType())) {
qDebug() << " Processing property" << prop.name();
QObject *oo = QDeclarativeMetaType::toQObject(prop.read(object));
if (oo && !metas->contains(oo->metaObject()))
processObject(oo, metas);
......
......@@ -6,6 +6,7 @@
TARGET = qmldump
QT += declarative
CONFIG += console
TEMPLATE = app
......
Markdown is supported
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