forked from qt-creator/qt-creator
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: Kai Koehne <kai.koehne@digia.com>
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user