Commit 7d2199db authored by Ulf Hermann's avatar Ulf Hermann
Browse files

QmlProfiler: Show "anonymous function" instead of empty string



Events with empty names are generally anonymous javascript functions.
Empty strings like to break layouts and aren't very descriptive anyway.

Change-Id: I3add8bd697633368ef20bab4b9788b0d46e7a16f
Reviewed-by: default avatarKai Koehne <kai.koehne@digia.com>
parent d09d5087
......@@ -78,12 +78,16 @@ QString getInitialDetails(const QmlProfilerSimpleModel::QmlEventData &event)
details = QmlProfilerProcessedModel::tr("Source code not available.");
else {
details = event.data.join(QLatin1String(" ")).replace(QLatin1Char('\n'),QLatin1Char(' ')).simplified();
QRegExp rewrite(QLatin1String("\\(function \\$(\\w+)\\(\\) \\{ (return |)(.+) \\}\\)"));
bool match = rewrite.exactMatch(details);
if (match)
details = rewrite.cap(1) + QLatin1String(": ") + rewrite.cap(3);
if (details.startsWith(QLatin1String("file://")))
details = details.mid(details.lastIndexOf(QLatin1Char('/')) + 1);
if (details.isEmpty()) {
details = QmlProfilerProcessedModel::tr("anonymous function");
} else {
QRegExp rewrite(QLatin1String("\\(function \\$(\\w+)\\(\\) \\{ (return |)(.+) \\}\\)"));
bool match = rewrite.exactMatch(details);
if (match)
details = rewrite.cap(1) + QLatin1String(": ") + rewrite.cap(3);
if (details.startsWith(QLatin1String("file://")))
details = details.mid(details.lastIndexOf(QLatin1Char('/')) + 1);
}
}
return details;
......
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