io/fileview: use deleteLater() to delete file watchers

Fixes crashes when writing a file while watching it.
This commit is contained in:
outfoxxed 2025-06-09 21:44:34 -07:00
parent 91000a582b
commit 0224fa942b
Signed by untrusted user: outfoxxed
GPG key ID: 4C88A185FB89301E

View file

@ -490,7 +490,9 @@ void FileView::updatePath() {
}
void FileView::updateWatchedFiles() {
delete this->watcher;
// If inotify events are sent to the watcher after deletion and deleteLater
// isn't used, a use after free in the QML engine will occur.
if (this->watcher) this->watcher->deleteLater();
if (!this->targetPath.isEmpty() && this->bWatchChanges) {
qCDebug(logFileView) << "Creating watcher for" << this << "at" << this->targetPath;