From c77061d4d19de23c805ccbcc7cc229b221d4c1d5 Mon Sep 17 00:00:00 2001 From: Arno Date: Tue, 2 Jan 2018 19:31:42 +0100 Subject: Try harder to delete a file QFile::remove() fails when the read-only attribute is set. Turn out it can be unset with QFile::setPermissions(QFile::ReadOther | QFile::WriteOther). Try it when the initial call to remove() failed. --- filewidget.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/filewidget.cpp b/filewidget.cpp index ac7f920..948a5d6 100644 --- a/filewidget.cpp +++ b/filewidget.cpp @@ -663,7 +663,11 @@ void FileWidget::deleteFiles(){ QDir d(fi.absoluteFilePath()); d.removeRecursively(); }else{ - QFile::remove(path); + if(!QFile::remove(path)){ + QFile f(path); + f.setPermissions(QFile::ReadOther | QFile::WriteOther); + f.remove(); + } } removed << idx.data().toString(); } -- cgit v1.2.3-70-g09d2