forked from qt-creator/qt-creator
AutoTest: Use working copy of own parser
In TestCodeParser::syncTestFrameworks(), a parser is created for every test framework. As a result, the last parser being created would "win" the global s_parserInstance variable, which is not predictable and probably not intended. So turn CppParser::getFileContent() into a non- static method, avoiding the global variable altogether. Change-Id: I9f7560f1185bc4a3bc7b2b36e89280351998465e Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -31,12 +31,9 @@
|
||||
|
||||
namespace Autotest {
|
||||
|
||||
static CppParser *s_parserInstance = nullptr;
|
||||
|
||||
CppParser::CppParser(ITestFramework *framework)
|
||||
: ITestParser(framework)
|
||||
{
|
||||
s_parserInstance = this;
|
||||
}
|
||||
|
||||
void CppParser::init(const QStringList &filesToParse, bool fullParse)
|
||||
@@ -55,11 +52,11 @@ bool CppParser::selectedForBuilding(const QString &fileName)
|
||||
return !projParts.isEmpty() && projParts.at(0)->selectedForBuilding;
|
||||
}
|
||||
|
||||
QByteArray CppParser::getFileContent(const QString &filePath)
|
||||
QByteArray CppParser::getFileContent(const QString &filePath) const
|
||||
{
|
||||
QByteArray fileContent;
|
||||
if (s_parserInstance->m_workingCopy.contains(filePath)) {
|
||||
fileContent = s_parserInstance->m_workingCopy.source(filePath);
|
||||
if (m_workingCopy.contains(filePath)) {
|
||||
fileContent = m_workingCopy.source(filePath);
|
||||
} else {
|
||||
QString error;
|
||||
const QTextCodec *codec = Core::EditorManager::defaultTextCodec();
|
||||
|
||||
Reference in New Issue
Block a user