diff options
author | Christian Stenger <christian.stenger@theqtcompany.com> | 2015-01-30 12:19:01 +0100 |
---|---|---|
committer | Christian Stenger <christian.stenger@theqtcompany.com> | 2015-02-05 08:25:01 +0200 |
commit | 834c52f48318caa9875c87914bcab9ab47e4eb2c (patch) | |
tree | f1894137dd233d13f51be3cbace297448ab93ed3 /plugins/autotest/testtreemodel.cpp | |
parent | 3629aa904448d7f62aab00629156093ca0cd5c60 (diff) | |
download | qt-creator-834c52f48318caa9875c87914bcab9ab47e4eb2c.tar.gz |
Avoid crash when using wrongly created test tree
Change-Id: I686f0cf285daeb3889161109964efd6e9ac47a40
Reviewed-by: Tim Jenssen <tim.jenssen@theqtcompany.com>
Diffstat (limited to 'plugins/autotest/testtreemodel.cpp')
-rw-r--r-- | plugins/autotest/testtreemodel.cpp | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/plugins/autotest/testtreemodel.cpp b/plugins/autotest/testtreemodel.cpp index 560820c586..81e4d4bfc9 100644 --- a/plugins/autotest/testtreemodel.cpp +++ b/plugins/autotest/testtreemodel.cpp @@ -420,7 +420,7 @@ QList<TestConfiguration *> TestTreeModel::getAllTestCases() const QList<TestConfiguration *> TestTreeModel::getSelectedTests() const { QList<TestConfiguration *> result; - TestConfiguration *tc; + TestConfiguration *testConfiguration = 0; for (int row = 0, count = m_autoTestRootItem->childCount(); row < count; ++row) { TestTreeItem *child = m_autoTestRootItem->child(row); @@ -429,9 +429,9 @@ QList<TestConfiguration *> TestTreeModel::getSelectedTests() const case Qt::Unchecked: continue; case Qt::Checked: - tc = new TestConfiguration(child->name(), QStringList(), child->childCount()); - addProjectInformation(tc, child->filePath()); - result << tc; + testConfiguration = new TestConfiguration(child->name(), QStringList(), child->childCount()); + addProjectInformation(testConfiguration, child->filePath()); + result << testConfiguration; continue; case Qt::PartiallyChecked: default: @@ -444,9 +444,9 @@ QList<TestConfiguration *> TestTreeModel::getSelectedTests() const testCases << grandChild->name(); } - tc = new TestConfiguration(childName, testCases); - addProjectInformation(tc, child->filePath()); - result << tc; + testConfiguration = new TestConfiguration(childName, testCases); + addProjectInformation(testConfiguration, child->filePath()); + result << testConfiguration; } } // Quick Tests must be handled differently - need the calling cpp file to use this in @@ -461,7 +461,10 @@ QList<TestConfiguration *> TestTreeModel::getSelectedTests() const const TestTreeItem *grandChild = unnamed->child(childRow); const QString mainFile = grandChild->mainFile(); if (foundMains.contains(mainFile)) { - foundMains[mainFile]->setTestCaseCount(tc->testCaseCount() + 1); + QTC_ASSERT(testConfiguration, + qWarning() << "Illegal state (unnamed Quick Test listed as named)"; + return QList<TestConfiguration *>()); + foundMains[mainFile]->setTestCaseCount(testConfiguration->testCaseCount()); } else { TestConfiguration *tc = new TestConfiguration(QString(), QStringList()); tc->setTestCaseCount(1); |