forked from qt-creator/qt-creator
AutoTest: Postpone removal of root node
If a root node should get removed while scanning we may end up crashing when still getting results. As there is currently no mechanism to stop a certain parser postpone the removal of the root node until the parsing is done. Change-Id: I3766f9e67780e241801166339fa67f39536314b4 Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
@@ -4,7 +4,9 @@
|
|||||||
#include "testprojectsettings.h"
|
#include "testprojectsettings.h"
|
||||||
|
|
||||||
#include "autotestconstants.h"
|
#include "autotestconstants.h"
|
||||||
|
#include "testcodeparser.h"
|
||||||
#include "testframeworkmanager.h"
|
#include "testframeworkmanager.h"
|
||||||
|
#include "testtreemodel.h"
|
||||||
|
|
||||||
#include <projectexplorer/project.h>
|
#include <projectexplorer/project.h>
|
||||||
#include <projectexplorer/projectmanager.h>
|
#include <projectexplorer/projectmanager.h>
|
||||||
@@ -49,7 +51,9 @@ void TestProjectSettings::activateFramework(const Id &id, bool activate)
|
|||||||
{
|
{
|
||||||
ITestFramework *framework = TestFrameworkManager::frameworkForId(id);
|
ITestFramework *framework = TestFrameworkManager::frameworkForId(id);
|
||||||
m_activeTestFrameworks[framework] = activate;
|
m_activeTestFrameworks[framework] = activate;
|
||||||
if (!activate)
|
if (TestTreeModel::instance()->parser()->isParsing())
|
||||||
|
framework->rootNode()->markForRemoval(!activate);
|
||||||
|
else if (!activate)
|
||||||
framework->resetRootNode();
|
framework->resetRootNode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -214,11 +214,15 @@ bool TestTreeItem::modifyLineAndColumn(const TestParseResult *result)
|
|||||||
|
|
||||||
void TestTreeItem::markForRemoval(bool mark)
|
void TestTreeItem::markForRemoval(bool mark)
|
||||||
{
|
{
|
||||||
|
if (type() == Root)
|
||||||
|
m_status = mark ? ForcedRootRemoval : NewlyAdded;
|
||||||
|
else
|
||||||
m_status = mark ? MarkedForRemoval : Cleared;
|
m_status = mark ? MarkedForRemoval : Cleared;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TestTreeItem::markForRemovalRecursively(bool mark)
|
void TestTreeItem::markForRemovalRecursively(bool mark)
|
||||||
{
|
{
|
||||||
|
if (type() != Root)
|
||||||
markForRemoval(mark);
|
markForRemoval(mark);
|
||||||
for (int row = 0, count = childCount(); row < count; ++row)
|
for (int row = 0, count = childCount(); row < count; ++row)
|
||||||
childItem(row)->markForRemovalRecursively(mark);
|
childItem(row)->markForRemovalRecursively(mark);
|
||||||
@@ -231,6 +235,7 @@ void TestTreeItem::markForRemovalRecursively(const QSet<FilePath> &filePaths)
|
|||||||
child->markForRemovalRecursively(filePaths);
|
child->markForRemovalRecursively(filePaths);
|
||||||
mark &= child->markedForRemoval();
|
mark &= child->markedForRemoval();
|
||||||
});
|
});
|
||||||
|
if (type() != Root)
|
||||||
markForRemoval(mark);
|
markForRemoval(mark);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -167,6 +167,7 @@ private:
|
|||||||
{
|
{
|
||||||
NewlyAdded,
|
NewlyAdded,
|
||||||
MarkedForRemoval,
|
MarkedForRemoval,
|
||||||
|
ForcedRootRemoval, // only valid on rootNode
|
||||||
Cleared
|
Cleared
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -485,6 +485,10 @@ void TestTreeModel::markForRemoval(const QSet<Utils::FilePath> &filePaths)
|
|||||||
void TestTreeModel::sweep()
|
void TestTreeModel::sweep()
|
||||||
{
|
{
|
||||||
for (TestTreeItem *frameworkRoot : frameworkRootNodes()) {
|
for (TestTreeItem *frameworkRoot : frameworkRootNodes()) {
|
||||||
|
if (frameworkRoot->m_status == TestTreeItem::ForcedRootRemoval) {
|
||||||
|
frameworkRoot->framework()->resetRootNode();
|
||||||
|
continue;
|
||||||
|
}
|
||||||
sweepChildren(frameworkRoot);
|
sweepChildren(frameworkRoot);
|
||||||
revalidateCheckState(frameworkRoot);
|
revalidateCheckState(frameworkRoot);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user