PerfProfiler: Handle failure to read trace point script file

We can just write an error message into the text edit in that case.

Change-Id: I9ab0ab226bd8f171ab1a693884053a8c759cec2b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Ulf Hermann
2019-01-07 14:36:50 +01:00
parent 4c6a497c89
commit a7435ae785

View File

@@ -59,8 +59,12 @@ PerfTracePointDialog::PerfTracePointDialog() :
QTC_ASSERT(m_device, return);
QFile file(":/perfprofiler/tracepoints.sh");
file.open(QIODevice::ReadOnly);
m_ui->textEdit->setPlainText(QString::fromUtf8(file.readAll()));
if (file.open(QIODevice::ReadOnly)) {
m_ui->textEdit->setPlainText(QString::fromUtf8(file.readAll()));
} else {
m_ui->textEdit->setPlainText(tr("Error: Failed to load trace point script %1: %2.")
.arg(file.fileName()).arg(file.errorString()));
}
m_ui->privilegesChooser->setCurrentText(m_device->type() == Constants::DESKTOP_DEVICE_TYPE
? QLatin1String("pkexec") : QLatin1String("n.a."));