AutoTest: Avoid crash when accessing uninitialized runnable

Change-Id: I87bbf5b824a693a2c8d653bf5093e088f01b84b5
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
Christian Stenger
2016-06-23 07:34:53 +02:00
parent 90bd65479b
commit 8562abbb56
2 changed files with 27 additions and 2 deletions

View File

@@ -187,7 +187,7 @@ void TestConfiguration::completeTestInformation(int runMode)
setProject(project); setProject(project);
setGuessedConfiguration(guessedRunConfiguration); setGuessedConfiguration(guessedRunConfiguration);
if (!guessedRunConfiguration && runMode == TestRunner::Debug) if (!guessedRunConfiguration && runMode == TestRunner::Debug)
m_runConfig = new TestRunConfiguration(runConfigTarget); m_runConfig = new TestRunConfiguration(runConfigTarget, this);
} }
} }

View File

@@ -25,7 +25,15 @@
#pragma once #pragma once
#include "autotestplugin.h"
#include "testconfiguration.h"
#include <projectexplorer/applicationlauncher.h>
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/devicesupport/devicemanager.h>
#include <projectexplorer/runconfiguration.h> #include <projectexplorer/runconfiguration.h>
#include <projectexplorer/runnables.h>
#include <utils/qtcassert.h>
namespace Autotest { namespace Autotest {
namespace Internal { namespace Internal {
@@ -33,15 +41,32 @@ namespace Internal {
class TestRunConfiguration : public ProjectExplorer::RunConfiguration class TestRunConfiguration : public ProjectExplorer::RunConfiguration
{ {
public: public:
TestRunConfiguration(ProjectExplorer::Target *parent) TestRunConfiguration(ProjectExplorer::Target *parent, TestConfiguration *config)
: ProjectExplorer::RunConfiguration(parent, "AutoTest.TestRunConfig") : ProjectExplorer::RunConfiguration(parent, "AutoTest.TestRunConfig")
{ {
setDefaultDisplayName(tr("AutoTest Debug")); setDefaultDisplayName(tr("AutoTest Debug"));
addExtraAspects(); addExtraAspects();
m_testConfig = config;
}
ProjectExplorer::Runnable runnable() const override
{
ProjectExplorer::StandardRunnable r;
QTC_ASSERT(m_testConfig, return r);
r.executable = m_testConfig->targetFile();
r.commandLineArguments = m_testConfig->argumentsForTestRunner(
*AutotestPlugin::instance()->settings()).join(' ');
r.workingDirectory = m_testConfig->workingDirectory();
r.environment = m_testConfig->environment();
r.runMode = ProjectExplorer::ApplicationLauncher::Gui;
r.device = ProjectExplorer::DeviceManager::instance()->defaultDevice(
ProjectExplorer::Constants::DESKTOP_DEVICE_TYPE);
return r;
} }
private: private:
QWidget *createConfigurationWidget() { return 0; } QWidget *createConfigurationWidget() { return 0; }
TestConfiguration *m_testConfig = 0;
}; };
} // namespace Internal } // namespace Internal