[frameworks/kcoreaddons] src/lib/io: KDirWatch: fix/tweak determination of default
Pino Toscano <[email protected]> Wed, 5 Aug 2026 03:45:45 +0000 (UTC)
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 9dc5b45ba907d327679a012f7e6c9aeb75961e36 by Pino Toscano.
Committed on 02/08/2026 at 18:22.
Pushed by pino into branch 'master'.
KDirWatch: fix/tweak determination of default
The non-NFS preferred method determination used "inotify" as default:
since that value is not checked in methodFromString(), then always the
default is used. Tweak the default string to use something that can be
mistaken less for an actual string.
Also, when returning the default method, take into account whether
QFileSystemWatcher is available, rather than always using it. This way,
in case it is not available (e.g. not built into Qt), then the default
method can properly be "Stat".
M +4 -2 src/lib/io/kdirwatch.cpp
https://invent.kde.org/frameworks/kcoreaddons/-/commit/9dc5b45ba907d327679a012f7e6c9aeb75961e36
diff --git a/src/lib/io/kdirwatch.cpp b/src/lib/io/kdirwatch.cpp
index 2e68bec7..f6e43227 100644
--- a/src/lib/io/kdirwatch.cpp
+++ b/src/lib/io/kdirwatch.cpp
@@ -103,8 +103,10 @@ static KDirWatch::Method methodFromString(const QByteArray &method)
#if HAVE_SYS_INOTIFY_H
// inotify supports delete+recreate+modify, which QFSWatch doesn't support
return KDirWatch::INotify;
-#else
+#elif HAVE_QFILESYSTEMWATCHER
return KDirWatch::QFSWatch;
+#else
+ return KDirWatch::Stat;
#endif
}
}
@@ -180,7 +182,7 @@ KDirWatchPrivate::KDirWatchPrivate()
m_nfsPollInterval = qEnvironmentVariableIsSet(s_envNfsPoll) ? qEnvironmentVariableIntValue(s_envNfsPoll) : 5000;
m_PollInterval = qEnvironmentVariableIsSet(s_envPoll) ? qEnvironmentVariableIntValue(s_envPoll) : 500;
- m_preferredMethod = methodFromString(qEnvironmentVariableIsSet(s_envMethod) ? qgetenv(s_envMethod) : "inotify");
+ m_preferredMethod = methodFromString(qEnvironmentVariableIsSet(s_envMethod) ? qgetenv(s_envMethod) : "default");
// The nfs method defaults to the normal (local) method
m_nfsPreferredMethod = methodFromString(qEnvironmentVariableIsSet(s_envNfsMethod) ? qgetenv(s_envNfsMethod) : "Stat");