kio: check if the local watcher exists before attempting to remove entries from it in KDirListerPrivate::unwatchUrl()

for the rare case of currently listing remote protocol (such as
filenamesearch:/) and local file that is not watched being deleted (the
signal is emitted by KDirNotify)

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
This commit is contained in:
Ivailo Monev 2023-07-06 08:06:15 +03:00
parent 6deb136bad
commit 7ca48a2806

View file

@ -149,9 +149,11 @@ void KDirListerPrivate::unwatchUrl(const KUrl &it)
if (it.isLocalFile()) {
const QString localfile = it.toLocalFile();
kDebug(7003) << "no longer watching" << localfile;
// not tracking what it is, KDirWatch does tho
dirWatch->removeDir(localfile);
dirWatch->removeFile(localfile);
if (dirWatch) {
// not tracking what it is, KDirWatch does tho
dirWatch->removeDir(localfile);
dirWatch->removeFile(localfile);
}
} else {
kDebug(7003) << "no longer watching remote" << it.url();
org::kde::KDirNotify::emitLeftDirectory(it.url());