Commit 834c52f4 authored by Christian Stenger's avatar Christian Stenger
Browse files

Avoid crash when using wrongly created test tree



Change-Id: I686f0cf285daeb3889161109964efd6e9ac47a40
Reviewed-by: default avatarTim Jenssen <tim.jenssen@theqtcompany.com>
parent 3629aa90
...@@ -420,7 +420,7 @@ QList<TestConfiguration *> TestTreeModel::getAllTestCases() const ...@@ -420,7 +420,7 @@ QList<TestConfiguration *> TestTreeModel::getAllTestCases() const
QList<TestConfiguration *> TestTreeModel::getSelectedTests() const QList<TestConfiguration *> TestTreeModel::getSelectedTests() const
{ {
QList<TestConfiguration *> result; QList<TestConfiguration *> result;
TestConfiguration *tc; TestConfiguration *testConfiguration = 0;
for (int row = 0, count = m_autoTestRootItem->childCount(); row < count; ++row) { for (int row = 0, count = m_autoTestRootItem->childCount(); row < count; ++row) {
TestTreeItem *child = m_autoTestRootItem->child(row); TestTreeItem *child = m_autoTestRootItem->child(row);
...@@ -429,9 +429,9 @@ QList<TestConfiguration *> TestTreeModel::getSelectedTests() const ...@@ -429,9 +429,9 @@ QList<TestConfiguration *> TestTreeModel::getSelectedTests() const
case Qt::Unchecked: case Qt::Unchecked:
continue; continue;
case Qt::Checked: case Qt::Checked:
tc = new TestConfiguration(child->name(), QStringList(), child->childCount()); testConfiguration = new TestConfiguration(child->name(), QStringList(), child->childCount());
addProjectInformation(tc, child->filePath()); addProjectInformation(testConfiguration, child->filePath());
result << tc; result << testConfiguration;
continue; continue;
case Qt::PartiallyChecked: case Qt::PartiallyChecked:
default: default:
...@@ -444,9 +444,9 @@ QList<TestConfiguration *> TestTreeModel::getSelectedTests() const ...@@ -444,9 +444,9 @@ QList<TestConfiguration *> TestTreeModel::getSelectedTests() const
testCases << grandChild->name(); testCases << grandChild->name();
} }
tc = new TestConfiguration(childName, testCases); testConfiguration = new TestConfiguration(childName, testCases);
addProjectInformation(tc, child->filePath()); addProjectInformation(testConfiguration, child->filePath());
result << tc; result << testConfiguration;
} }
} }
// Quick Tests must be handled differently - need the calling cpp file to use this in // Quick Tests must be handled differently - need the calling cpp file to use this in
...@@ -461,7 +461,10 @@ QList<TestConfiguration *> TestTreeModel::getSelectedTests() const ...@@ -461,7 +461,10 @@ QList<TestConfiguration *> TestTreeModel::getSelectedTests() const
const TestTreeItem *grandChild = unnamed->child(childRow); const TestTreeItem *grandChild = unnamed->child(childRow);
const QString mainFile = grandChild->mainFile(); const QString mainFile = grandChild->mainFile();
if (foundMains.contains(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 { } else {
TestConfiguration *tc = new TestConfiguration(QString(), QStringList()); TestConfiguration *tc = new TestConfiguration(QString(), QStringList());
tc->setTestCaseCount(1); tc->setTestCaseCount(1);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment