core/reloader: watch new files detected in failed reloads

This commit is contained in:
outfoxxed 2025-05-26 02:27:50 -07:00
parent e931b85464
commit 4472b27039
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E
3 changed files with 35 additions and 5 deletions

View file

@ -162,6 +162,11 @@ void EngineGeneration::setWatchingFiles(bool watching) {
this->watcher->addPath(QFileInfo(file).dir().absolutePath());
}
for (auto& file: this->extraWatchedFiles) {
this->watcher->addPath(file);
this->watcher->addPath(QFileInfo(file).dir().absolutePath());
}
QObject::connect(
this->watcher,
&QFileSystemWatcher::fileChanged,
@ -184,6 +189,22 @@ void EngineGeneration::setWatchingFiles(bool watching) {
}
}
bool EngineGeneration::setExtraWatchedFiles(const QVector<QString>& files) {
this->extraWatchedFiles.clear();
for (const auto& file: files) {
if (!this->scanner.scannedFiles.contains(file)) {
this->extraWatchedFiles.append(file);
}
}
if (this->watcher) {
this->setWatchingFiles(false);
this->setWatchingFiles(true);
}
return !this->extraWatchedFiles.isEmpty();
}
void EngineGeneration::onFileChanged(const QString& name) {
if (!this->watcher->files().contains(name)) {
this->deletedWatchedFiles.push_back(name);