forked from qt-creator/qt-creator
qmldump: Produce an error message if module import fails.
Reviewed-by: Kai Koehne
This commit is contained in:
@@ -265,12 +265,18 @@ void writeEasingCurve(QXmlStreamWriter *xml)
|
|||||||
xml->writeEndElement();
|
xml->writeEndElement();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum ExitCode {
|
||||||
|
EXIT_INVALIDARGUMENTS = 1,
|
||||||
|
EXIT_SEGV = 2,
|
||||||
|
EXIT_IMPORTERROR = 3
|
||||||
|
};
|
||||||
|
|
||||||
#ifdef Q_OS_UNIX
|
#ifdef Q_OS_UNIX
|
||||||
void sigSegvHandler(int) {
|
void sigSegvHandler(int) {
|
||||||
fprintf(stderr, "Error: qmldump SEGV\n");
|
fprintf(stderr, "Error: qmldump SEGV\n");
|
||||||
if (!currentProperty.isEmpty())
|
if (!currentProperty.isEmpty())
|
||||||
fprintf(stderr, "While processing the property '%s', which probably has uninitialized data.\n", currentProperty.toLatin1().constData());
|
fprintf(stderr, "While processing the property '%s', which probably has uninitialized data.\n", currentProperty.toLatin1().constData());
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_SEGV);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@@ -296,7 +302,7 @@ int main(int argc, char *argv[])
|
|||||||
if (argc != 1 && argc != 3) {
|
if (argc != 1 && argc != 3) {
|
||||||
qWarning() << "Usage: qmldump [plugin/import/path plugin.uri]";
|
qWarning() << "Usage: qmldump [plugin/import/path plugin.uri]";
|
||||||
qWarning() << "Example: ./qmldump /home/user/dev/qt-install/imports Qt.labs.particles";
|
qWarning() << "Example: ./qmldump /home/user/dev/qt-install/imports Qt.labs.particles";
|
||||||
return 1;
|
return EXIT_INVALIDARGUMENTS;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString pluginImportName;
|
QString pluginImportName;
|
||||||
@@ -315,7 +321,7 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
QByteArray code = "import QtQuick 1.0; Item {}";
|
QByteArray code = "import QtQuick 1.0; Item {}";
|
||||||
QDeclarativeComponent c(engine);
|
QDeclarativeComponent c(engine);
|
||||||
c.setData(code, QUrl("xxx"));
|
c.setData(code, QUrl("qtquickcheck"));
|
||||||
c.create();
|
c.create();
|
||||||
if (c.errors().isEmpty()) {
|
if (c.errors().isEmpty()) {
|
||||||
hasQtQuickModule = true;
|
hasQtQuickModule = true;
|
||||||
@@ -341,10 +347,13 @@ int main(int argc, char *argv[])
|
|||||||
code += "Item {}";
|
code += "Item {}";
|
||||||
QDeclarativeComponent c(engine);
|
QDeclarativeComponent c(engine);
|
||||||
|
|
||||||
c.setData(code, QUrl("xxx"));
|
c.setData(code, QUrl("typelist"));
|
||||||
c.create();
|
c.create();
|
||||||
if (!c.errors().isEmpty())
|
if (!c.errors().isEmpty()) {
|
||||||
qDebug() << c.errorString();
|
foreach (const QDeclarativeError &error, c.errors())
|
||||||
|
qWarning() << error.toString();
|
||||||
|
return EXIT_IMPORTERROR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
cppToId.insert("QString", "string");
|
cppToId.insert("QString", "string");
|
||||||
@@ -400,7 +409,7 @@ int main(int argc, char *argv[])
|
|||||||
code += " {}\n";
|
code += " {}\n";
|
||||||
|
|
||||||
QDeclarativeComponent c(engine);
|
QDeclarativeComponent c(engine);
|
||||||
c.setData(code, QUrl("xxx"));
|
c.setData(code, QUrl("typeinstance"));
|
||||||
|
|
||||||
QObject *object = c.create();
|
QObject *object = c.create();
|
||||||
if (object)
|
if (object)
|
||||||
|
|||||||
@@ -121,9 +121,17 @@ static QString qmldumpErrorMessage(const QString &libraryPath, const QString &er
|
|||||||
return PluginDumper::tr("Type dump of QML plugin in %0 failed.\nErrors:\n%1\n").arg(libraryPath, error);
|
return PluginDumper::tr("Type dump of QML plugin in %0 failed.\nErrors:\n%1\n").arg(libraryPath, error);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QString qmldumpFailedMessage()
|
static QString qmldumpFailedMessage(const QString &error)
|
||||||
{
|
{
|
||||||
return PluginDumper::tr("Type dump of C++ plugin failed.\nCheck 'General Messages' output pane for details.");
|
QString firstLines =
|
||||||
|
QStringList(error.split(QLatin1Char('\n')).mid(0, 10)).join(QLatin1String("\n"));
|
||||||
|
return PluginDumper::tr("Type dump of C++ plugin failed.\n"
|
||||||
|
"First 10 lines or errors:\n"
|
||||||
|
"\n"
|
||||||
|
"%1"
|
||||||
|
"\n"
|
||||||
|
"Check 'General Messages' output pane for details."
|
||||||
|
).arg(firstLines);
|
||||||
}
|
}
|
||||||
|
|
||||||
static QList<FakeMetaObject::ConstPtr> parseHelper(const QByteArray &xml, QString *error)
|
static QList<FakeMetaObject::ConstPtr> parseHelper(const QByteArray &xml, QString *error)
|
||||||
@@ -156,8 +164,9 @@ void PluginDumper::qmlPluginTypeDumpDone(int exitCode)
|
|||||||
|
|
||||||
if (exitCode != 0) {
|
if (exitCode != 0) {
|
||||||
Core::MessageManager *messageManager = Core::MessageManager::instance();
|
Core::MessageManager *messageManager = Core::MessageManager::instance();
|
||||||
messageManager->printToOutputPane(qmldumpErrorMessage(libraryPath, process->readAllStandardError()));
|
const QString errorMessages = process->readAllStandardError();
|
||||||
libraryInfo.setDumpStatus(LibraryInfo::DumpError, qmldumpFailedMessage());
|
messageManager->printToOutputPane(qmldumpErrorMessage(libraryPath, errorMessages));
|
||||||
|
libraryInfo.setDumpStatus(LibraryInfo::DumpError, qmldumpFailedMessage(errorMessages));
|
||||||
}
|
}
|
||||||
|
|
||||||
const QByteArray output = process->readAllStandardOutput();
|
const QByteArray output = process->readAllStandardOutput();
|
||||||
@@ -188,12 +197,13 @@ void PluginDumper::qmlPluginTypeDumpError(QProcess::ProcessError)
|
|||||||
const QString libraryPath = m_runningQmldumps.take(process);
|
const QString libraryPath = m_runningQmldumps.take(process);
|
||||||
|
|
||||||
Core::MessageManager *messageManager = Core::MessageManager::instance();
|
Core::MessageManager *messageManager = Core::MessageManager::instance();
|
||||||
messageManager->printToOutputPane(qmldumpErrorMessage(libraryPath, process->readAllStandardError()));
|
const QString errorMessages = process->readAllStandardError();
|
||||||
|
messageManager->printToOutputPane(qmldumpErrorMessage(libraryPath, errorMessages));
|
||||||
|
|
||||||
if (!libraryPath.isEmpty()) {
|
if (!libraryPath.isEmpty()) {
|
||||||
const Snapshot snapshot = m_modelManager->snapshot();
|
const Snapshot snapshot = m_modelManager->snapshot();
|
||||||
LibraryInfo libraryInfo = snapshot.libraryInfo(libraryPath);
|
LibraryInfo libraryInfo = snapshot.libraryInfo(libraryPath);
|
||||||
libraryInfo.setDumpStatus(LibraryInfo::DumpError, qmldumpFailedMessage());
|
libraryInfo.setDumpStatus(LibraryInfo::DumpError, qmldumpFailedMessage(errorMessages));
|
||||||
m_modelManager->updateLibraryInfo(libraryPath, libraryInfo);
|
m_modelManager->updateLibraryInfo(libraryPath, libraryInfo);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user