Clang: Don't set a translation unit dirty if the main file is deleted

If a file is deleted the translation unit should be not updated. It will be
later removed anyway.

Task-number: QTCREATORBUG-15070
Change-Id: I40c9c70629dab1d35b713d54442ffdbb2df3db43
Reviewed-by: Nikolai Kosjar <nikolai.kosjar@theqtcompany.com>
This commit is contained in:
Marco Bubke
2015-10-12 17:36:18 +02:00
parent d8ba9fa972
commit b8a9e85880
3 changed files with 54 additions and 16 deletions

View File

@@ -213,7 +213,7 @@ const QSet<Utf8String> &TranslationUnit::dependedFilePaths() const
void TranslationUnit::setDirtyIfDependencyIsMet(const Utf8String &filePath)
{
if (d->dependedFilePaths.contains(filePath)) {
if (d->dependedFilePaths.contains(filePath) && isMainFileAndExistsOrIsOtherFile(filePath)) {
d->needsToBeReparsed = true;
d->hasNewDiagnostics = true;
}
@@ -249,6 +249,14 @@ bool TranslationUnit::projectPartIsOutdated() const
return d->projectPart.lastChangeTimePoint() >= d->lastProjectPartChangeTimePoint;
}
bool TranslationUnit::isMainFileAndExistsOrIsOtherFile(const Utf8String &filePath) const
{
if (filePath == d->filePath)
return QFileInfo::exists(d->filePath);
return true;
}
void TranslationUnit::createTranslationUnitIfNeeded() const
{
if (!d->translationUnit) {