AutotoolsProject: Simplify using Project::projectFileIsDirty signal

Change-Id: Idbb81a8d3ddd2f2d81b9060f228331a233fd6ccf
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Tobias Hunger
2019-08-15 12:20:49 +02:00
parent d13307b5bf
commit c89a8a4084
2 changed files with 10 additions and 33 deletions

View File

@@ -67,16 +67,17 @@ using namespace AutotoolsProjectManager;
using namespace AutotoolsProjectManager::Internal; using namespace AutotoolsProjectManager::Internal;
using namespace ProjectExplorer; using namespace ProjectExplorer;
AutotoolsProject::AutotoolsProject(const Utils::FilePath &fileName) : AutotoolsProject::AutotoolsProject(const Utils::FilePath &fileName)
Project(Constants::MAKEFILE_MIMETYPE, fileName), : Project(Constants::MAKEFILE_MIMETYPE, fileName)
m_fileWatcher(new Utils::FileSystemWatcher(this)), , m_cppCodeModelUpdater(new CppTools::CppProjectUpdater)
m_cppCodeModelUpdater(new CppTools::CppProjectUpdater)
{ {
setId(Constants::AUTOTOOLS_PROJECT_ID); setId(Constants::AUTOTOOLS_PROJECT_ID);
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID)); setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
setDisplayName(projectDirectory().fileName()); setDisplayName(projectDirectory().fileName());
setHasMakeInstallEquivalent(true); setHasMakeInstallEquivalent(true);
connect(this, &AutotoolsProject::projectFileIsDirty, this, &AutotoolsProject::loadProjectTree);
} }
AutotoolsProject::~AutotoolsProject() AutotoolsProject::~AutotoolsProject()
@@ -100,9 +101,6 @@ Project::RestoreResult AutotoolsProject::fromMap(const QVariantMap &map, QString
if (result != RestoreResult::Ok) if (result != RestoreResult::Ok)
return result; return result;
connect(m_fileWatcher, &Utils::FileSystemWatcher::fileChanged,
this, &AutotoolsProject::onFileChanged);
// Load the project tree structure. // Load the project tree structure.
loadProjectTree(); loadProjectTree();
@@ -165,12 +163,9 @@ void AutotoolsProject::makefileParsingFinished()
if (m_makefileParserThread->hasError()) if (m_makefileParserThread->hasError())
qWarning("Parsing of makefile contained errors."); qWarning("Parsing of makefile contained errors.");
// Remove file watches for the current project state.
// The file watches will be added again after the parsing.
m_fileWatcher->removeFiles(m_watchedFiles);
m_files.clear(); m_files.clear();
m_watchedFiles.clear();
QVector<Utils::FilePath> filesToWatch;
// Apply sources to m_files, which are returned at AutotoolsProject::files() // Apply sources to m_files, which are returned at AutotoolsProject::files()
const QFileInfo fileInfo = projectFilePath().toFileInfo(); const QFileInfo fileInfo = projectFilePath().toFileInfo();
@@ -187,8 +182,7 @@ void AutotoolsProject::makefileParsingFinished()
m_files.append(absMakefile); m_files.append(absMakefile);
m_fileWatcher->addFile(absMakefile, Utils::FileSystemWatcher::WatchAllChanges); filesToWatch.append(Utils::FilePath::fromString(absMakefile));
m_watchedFiles.append(absMakefile);
} }
// Add configure.ac file to project and watch for changes. // Add configure.ac file to project and watch for changes.
@@ -198,8 +192,7 @@ void AutotoolsProject::makefileParsingFinished()
const QString absConfigureAc = dir.absoluteFilePath(configureAc); const QString absConfigureAc = dir.absoluteFilePath(configureAc);
m_files.append(absConfigureAc); m_files.append(absConfigureAc);
m_fileWatcher->addFile(absConfigureAc, Utils::FileSystemWatcher::WatchAllChanges); filesToWatch.append(Utils::FilePath::fromString(absConfigureAc));
m_watchedFiles.append(absConfigureAc);
} }
auto newRoot = std::make_unique<ProjectNode>(projectDirectory()); auto newRoot = std::make_unique<ProjectNode>(projectDirectory());
@@ -209,6 +202,7 @@ void AutotoolsProject::makefileParsingFinished()
FileNode::fileTypeForFileName(path))); FileNode::fileTypeForFileName(path)));
} }
setRootProjectNode(std::move(newRoot)); setRootProjectNode(std::move(newRoot));
setExtraProjectFiles(filesToWatch);
updateCppCodeModel(); updateCppCodeModel();
@@ -216,12 +210,6 @@ void AutotoolsProject::makefileParsingFinished()
m_makefileParserThread = nullptr; m_makefileParserThread = nullptr;
} }
void AutotoolsProject::onFileChanged(const QString &file)
{
Q_UNUSED(file)
loadProjectTree();
}
static QStringList filterIncludes(const QString &absSrc, const QString &absBuild, static QStringList filterIncludes(const QString &absSrc, const QString &absBuild,
const QStringList &in) const QStringList &in)
{ {

View File

@@ -79,13 +79,6 @@ private:
*/ */
void makefileParsingFinished(); void makefileParsingFinished();
/**
* Is invoked, if a file of the project tree has been changed by the user.
* If a Makefile.am or a configure.ac file has been changed, the project
* configuration must be updated.
*/
void onFileChanged(const QString &file);
/** /**
* This function is in charge of the code completion. * This function is in charge of the code completion.
*/ */
@@ -94,10 +87,6 @@ private:
/// Return value for AutotoolsProject::files() /// Return value for AutotoolsProject::files()
QStringList m_files; QStringList m_files;
/// Watches project files for changes.
Utils::FileSystemWatcher *m_fileWatcher;
QStringList m_watchedFiles;
/// Responsible for parsing the makefiles asynchronously in a thread /// Responsible for parsing the makefiles asynchronously in a thread
MakefileParserThread *m_makefileParserThread = nullptr; MakefileParserThread *m_makefileParserThread = nullptr;