Delete pointer if it is no more used...

...and postpone creation of the newItem object a bit.

Change-Id: Id2322dcaae33cd902267dc73d2929db06880e20c
Reviewed-by: David Schulz <david.schulz@theqtcompany.com>
This commit is contained in:
Christian Stenger
2015-12-09 07:52:15 +01:00
committed by David Schulz
parent 7eab6a53b1
commit 1a8f37db0e

View File

@@ -137,7 +137,6 @@ void TestResultModel::addTestResult(TestResult *testResult, bool autoExpand)
QVector<Utils::TreeItem *> topLevelItems = rootItem()->children(); QVector<Utils::TreeItem *> topLevelItems = rootItem()->children();
int lastRow = topLevelItems.size() - 1; int lastRow = topLevelItems.size() - 1;
TestResultItem *newItem = new TestResultItem(testResult);
// we'll add the new item, so raising it's counter // we'll add the new item, so raising it's counter
if (!isCurrentTestMssg) { if (!isCurrentTestMssg) {
int count = m_testResultCount.value(testResult->result(), 0); int count = m_testResultCount.value(testResult->result(), 0);
@@ -150,14 +149,16 @@ void TestResultModel::addTestResult(TestResult *testResult, bool autoExpand)
if (result && result->result() == Result::MESSAGE_CURRENT_TEST) { if (result && result->result() == Result::MESSAGE_CURRENT_TEST) {
current->updateDescription(testResult->description()); current->updateDescription(testResult->description());
emit dataChanged(current->index(), current->index()); emit dataChanged(current->index(), current->index());
delete testResult;
return; return;
} }
} }
rootItem()->appendChild(newItem); rootItem()->appendChild(new TestResultItem(testResult));
return; return;
} }
TestResultItem *newItem = new TestResultItem(testResult);
// FIXME this might be totally wrong... we need some more unique information! // FIXME this might be totally wrong... we need some more unique information!
for (int row = lastRow; row >= 0; --row) { for (int row = lastRow; row >= 0; --row) {
TestResultItem *current = static_cast<TestResultItem *>(topLevelItems.at(row)); TestResultItem *current = static_cast<TestResultItem *>(topLevelItems.at(row));