Skip to content

Commit 0224fa9

Browse files
committed
io/fileview: use deleteLater() to delete file watchers
Fixes crashes when writing a file while watching it.
1 parent 91000a5 commit 0224fa9

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/io/fileview.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,9 @@ void FileView::updatePath() {
490490
}
491491

492492
void FileView::updateWatchedFiles() {
493-
delete this->watcher;
493+
// If inotify events are sent to the watcher after deletion and deleteLater
494+
// isn't used, a use after free in the QML engine will occur.
495+
if (this->watcher) this->watcher->deleteLater();
494496

495497
if (!this->targetPath.isEmpty() && this->bWatchChanges) {
496498
qCDebug(logFileView) << "Creating watcher for" << this << "at" << this->targetPath;

0 commit comments

Comments
 (0)