forked from qt-creator/qt-creator
More diagnostic messages when debugging examples model.
And less messages when not debugging. Change-Id: Ib30dfe061c399aeeb3523544232b394e12ccb1b6 Reviewed-by: Thomas Hartmann <Thomas.Hartmann@digia.com>
This commit is contained in:
@@ -116,21 +116,37 @@ static QString relativeOrInstallPath(const QString &path, const QString &manifes
|
|||||||
return relativeResolvedPath;
|
return relativeResolvedPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static bool debugExamples()
|
||||||
|
{
|
||||||
|
static bool isDebugging = !qgetenv("QTC_DEBUG_EXAMPLESMODEL").isEmpty();
|
||||||
|
return isDebugging;
|
||||||
|
}
|
||||||
|
|
||||||
static bool isValidExampleOrDemo(ExampleItem &item)
|
static bool isValidExampleOrDemo(ExampleItem &item)
|
||||||
{
|
{
|
||||||
static QString invalidPrefix = QLatin1String("qthelp:////"); /* means that the qthelp url
|
static QString invalidPrefix = QLatin1String("qthelp:////"); /* means that the qthelp url
|
||||||
doesn't have any namespace */
|
doesn't have any namespace */
|
||||||
|
QString reason;
|
||||||
bool ok = true;
|
bool ok = true;
|
||||||
if (!item.hasSourceCode || !QFileInfo(item.projectPath).exists())
|
if (!item.hasSourceCode || !QFileInfo(item.projectPath).exists()) {
|
||||||
ok = false;
|
ok = false;
|
||||||
else if (item.imageUrl.startsWith(invalidPrefix) || !QUrl(item.imageUrl).isValid())
|
reason = QString::fromLatin1("projectPath '%1' empty or does not exist").arg(item.projectPath);
|
||||||
|
} else if (item.imageUrl.startsWith(invalidPrefix) || !QUrl(item.imageUrl).isValid()) {
|
||||||
ok = false;
|
ok = false;
|
||||||
else if (!item.docUrl.isEmpty()
|
reason = QString::fromLatin1("imageUrl '%1' not valid").arg(item.imageUrl);
|
||||||
&& (item.imageUrl.startsWith(invalidPrefix) || !QUrl(item.docUrl).isValid()))
|
} else if (!item.docUrl.isEmpty()
|
||||||
|
&& (item.docUrl.startsWith(invalidPrefix) || !QUrl(item.docUrl).isValid())) {
|
||||||
ok = false;
|
ok = false;
|
||||||
if (!ok)
|
reason = QString::fromLatin1("docUrl '%1' non-empty but not valid").arg(item.docUrl);
|
||||||
|
}
|
||||||
|
if (!ok) {
|
||||||
item.tags.append(QLatin1String("broken"));
|
item.tags.append(QLatin1String("broken"));
|
||||||
return ok || !qgetenv("QTC_DEBUG_EXAMPLESMODEL").isEmpty();
|
if (debugExamples())
|
||||||
|
qWarning() << QString::fromLatin1("ERROR: Item '%1' broken: %2").arg(item.name, reason);
|
||||||
|
}
|
||||||
|
if (debugExamples() && item.description.isEmpty())
|
||||||
|
qWarning() << QString::fromLatin1("WARNING: Item '%1' has no description").arg(item.name);
|
||||||
|
return ok || debugExamples();
|
||||||
}
|
}
|
||||||
|
|
||||||
QList<ExampleItem> ExamplesListModel::parseExamples(QXmlStreamReader *reader,
|
QList<ExampleItem> ExamplesListModel::parseExamples(QXmlStreamReader *reader,
|
||||||
@@ -298,7 +314,8 @@ void ExamplesListModel::updateExamples()
|
|||||||
&examplesFallback, &demosFallback, &sourceFallback)) {
|
&examplesFallback, &demosFallback, &sourceFallback)) {
|
||||||
QFile exampleFile(exampleSource);
|
QFile exampleFile(exampleSource);
|
||||||
if (!exampleFile.open(QIODevice::ReadOnly)) {
|
if (!exampleFile.open(QIODevice::ReadOnly)) {
|
||||||
qDebug() << Q_FUNC_INFO << "Could not open file" << exampleSource;
|
if (debugExamples())
|
||||||
|
qWarning() << "ERROR: Could not open file" << exampleSource;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -319,6 +336,8 @@ void ExamplesListModel::updateExamples()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (debugExamples())
|
||||||
|
qWarning() << QString::fromLatin1("Reading file '%1'...").arg(fi.absoluteFilePath());
|
||||||
QXmlStreamReader reader(&exampleFile);
|
QXmlStreamReader reader(&exampleFile);
|
||||||
while (!reader.atEnd())
|
while (!reader.atEnd())
|
||||||
switch (reader.readNext()) {
|
switch (reader.readNext()) {
|
||||||
@@ -334,8 +353,8 @@ void ExamplesListModel::updateExamples()
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (reader.hasError())
|
if (reader.hasError() && debugExamples())
|
||||||
qDebug() << "error parsing file" << exampleSource << "as XML document";
|
qWarning() << QString::fromLatin1("ERROR: Could not parse file as XML document ('%1')").arg(exampleSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_tags.sort();
|
m_tags.sort();
|
||||||
|
|||||||
Reference in New Issue
Block a user