PerfProfiler: Allow creating trace points without valid project

We can still create trace points on the desktop device then.

Change-Id: I123bece2d11a6405883e0bcec9b066cec4e017b9
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
Ulf Hermann
2019-01-28 10:05:38 +01:00
parent 8bc7e04012
commit e25be3d5ee

View File

@@ -26,6 +26,7 @@
#include "perftracepointdialog.h"
#include "ui_perftracepointdialog.h"
#include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/kitinformation.h>
#include <projectexplorer/project.h>
#include <projectexplorer/session.h>
@@ -46,17 +47,26 @@ PerfTracePointDialog::PerfTracePointDialog() :
{
m_ui->setupUi(this);
Project *currentProject = SessionManager::startupProject();
QTC_ASSERT(currentProject, return);
const Target *target = currentProject->activeTarget();
QTC_ASSERT(target, return);
if (Project *currentProject = SessionManager::startupProject()) {
if (const Target *target = currentProject->activeTarget()) {
const Kit *kit = target->kit();
QTC_ASSERT(kit, return);
m_device = DeviceKitInformation::device(kit);
if (!m_device) {
m_ui->textEdit->setPlainText(tr("Error: No device available for active target."));
return;
}
}
}
if (!m_device) {
const DeviceManager *deviceManager = DeviceManager::instance();
// There should at least be a desktop device.
m_device = deviceManager->defaultDevice(Constants::DESKTOP_DEVICE_TYPE);
QTC_ASSERT(m_device, return);
}
QFile file(":/perfprofiler/tracepoints.sh");
if (file.open(QIODevice::ReadOnly)) {