Fix qmake's pro file cache to interact correctly with write_file
When writing a file with write_file() we have to inform the pro file parser cache to discard the file if it's existant in the cache, to ensure that calling include() after write_file() always works. Change-Id: I7d09269a57de55ca30b0e11dd40770de9f919f64 Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com>
This commit is contained in:
parent
79a389c346
commit
f45d6414ad
@ -320,6 +320,7 @@ QMakeEvaluator::writeFile(const QString &ctx, const QString &fn, QIODevice::Open
|
||||
.arg(ctx, QDir::toNativeSeparators(qfi.filePath()), errStr));
|
||||
return ReturnFalse;
|
||||
}
|
||||
m_parser->discardFileFromCache(qfi.filePath());
|
||||
return ReturnTrue;
|
||||
}
|
||||
|
||||
|
@ -222,6 +222,12 @@ ProFile *QMakeParser::parsedProBlock(
|
||||
return pro;
|
||||
}
|
||||
|
||||
void QMakeParser::discardFileFromCache(const QString &fileName)
|
||||
{
|
||||
if (m_cache)
|
||||
m_cache->discardFile(fileName);
|
||||
}
|
||||
|
||||
bool QMakeParser::read(ProFile *pro)
|
||||
{
|
||||
QFile file(pro->fileName());
|
||||
|
@ -94,6 +94,8 @@ public:
|
||||
ProFile *parsedProBlock(const QString &contents, const QString &name, int line = 0,
|
||||
SubGrammar grammar = FullGrammar);
|
||||
|
||||
void discardFileFromCache(const QString &fileName);
|
||||
|
||||
private:
|
||||
enum ScopeNesting {
|
||||
NestNone = 0,
|
||||
|
19
tests/auto/tools/qmake/testdata/pro_file_cache/pro_file_cache.pro
vendored
Normal file
19
tests/auto/tools/qmake/testdata/pro_file_cache/pro_file_cache.pro
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
TEMPLATE = app
|
||||
CONFIG -= debug_and_release_target
|
||||
|
||||
SOURCES =
|
||||
|
||||
content = ""
|
||||
write_file("include.pri", content)
|
||||
include(include.pri)
|
||||
|
||||
content = "SOURCES = main.cpp"
|
||||
write_file("include.pri", content)
|
||||
include(include.pri)
|
||||
|
||||
# Make sure that including the .pri file a second time will reload it properly
|
||||
# off disk with the new content.
|
||||
isEmpty(SOURCES): error(No sources defined)
|
||||
|
||||
# Empty it again to silence qmake about non-existance sources
|
||||
SOURCES =
|
@ -92,6 +92,7 @@ private slots:
|
||||
void includefunction();
|
||||
void substitutes();
|
||||
void project();
|
||||
void proFileCache();
|
||||
|
||||
private:
|
||||
TestCompiler test_compiler;
|
||||
@ -546,5 +547,11 @@ void tst_qmake::project()
|
||||
QVERIFY( test_compiler.removeProject( workDir, "project" ));
|
||||
}
|
||||
|
||||
void tst_qmake::proFileCache()
|
||||
{
|
||||
QString workDir = base_path + "/testdata/pro_file_cache";
|
||||
QVERIFY( test_compiler.qmake( workDir, "pro_file_cache" ));
|
||||
}
|
||||
|
||||
QTEST_MAIN(tst_qmake)
|
||||
#include "tst_qmake.moc"
|
||||
|
Loading…
Reference in New Issue
Block a user