QNX: Use inotify on QNX systems that support it
authorThomas McGuire <thomas.mcguire.qnx@kdab.com>
Wed, 15 Aug 2012 13:53:43 +0000 (15:53 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Tue, 30 Oct 2012 13:52:14 +0000 (14:52 +0100)
Change-Id: Ia9bf8d3c202b17746036e203268ef6229aaa900d
Reviewed-by: Kevin Krammer <kevin.krammer@kdab.com>
Reviewed-by: Rafael Roquetto <rafael.roquetto@kdab.com>
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
src/corelib/io/io.pri
src/corelib/io/qfilesystemwatcher.cpp
src/corelib/io/qfilesystemwatcher_inotify.cpp
tests/auto/corelib/io/qfilesystemwatcher/tst_qfilesystemwatcher.cpp

index 174e2a2..f57dceb 100644 (file)
@@ -124,7 +124,7 @@ win32 {
             SOURCES += io/qstandardpaths_unix.cpp
         }
 
-        linux-* {
+        linux-*|if(qnx:contains(QT_CONFIG, inotify)) {
             SOURCES += io/qfilesystemwatcher_inotify.cpp
             HEADERS += io/qfilesystemwatcher_inotify_p.h
         }
index 77a5959..449be9b 100644 (file)
 #include <qset.h>
 #include <qtimer.h>
 
+#if defined(Q_OS_LINUX) || (defined(Q_OS_QNX) && !defined(QT_NO_INOTIFY))
+#define USE_INOTIFY
+#endif
 
 #include "qfilesystemwatcher_polling_p.h"
 #if defined(Q_OS_WIN)
 #  include "qfilesystemwatcher_win_p.h"
-#elif defined(Q_OS_LINUX)
+#elif defined(USE_INOTIFY)
 #  include "qfilesystemwatcher_inotify_p.h"
 #elif defined(Q_OS_FREEBSD) || defined(Q_OS_MAC)
 #  include "qfilesystemwatcher_kqueue_p.h"
@@ -67,7 +70,7 @@ QFileSystemWatcherEngine *QFileSystemWatcherPrivate::createNativeEngine(QObject
 {
 #if defined(Q_OS_WIN)
     return new QWindowsFileSystemWatcherEngine(parent);
-#elif defined(Q_OS_LINUX)
+#elif defined(USE_INOTIFY)
     // there is a chance that inotify may fail on Linux pre-2.6.13 (August
     // 2005), so we can't just new inotify directly.
     return QInotifyFileSystemWatcherEngine::create(parent);
index 390a280..11ac0e5 100644 (file)
 #include <qsocketnotifier.h>
 #include <qvarlengtharray.h>
 
+#if defined(Q_OS_LINUX)
 #include <sys/syscall.h>
 #include <sys/ioctl.h>
 #include <unistd.h>
 #include <fcntl.h>
+#endif
 
 #if defined(QT_NO_INOTIFY)
+
+#if defined(Q_OS_QNX)
+// These files should only be compiled on QNX if the inotify headers are found
+#error "Should not get here."
+#endif
+
 #include <linux/types.h>
 
 #if defined(__i386__)
index 76fa602..82eaa64 100644 (file)
@@ -183,6 +183,9 @@ void tst_QFileSystemWatcher::basicTest()
     // change the permissions, should get a signal from the watcher
     testFile.setPermissions(QFile::ReadOwner);
 
+    // IN_ATTRIB doesn't work on QNX, so skip this test
+#if !defined(Q_OS_QNX)
+
     // waiting max 5 seconds for notification for file permission modification to trigger
     QTRY_COMPARE(changedSpy.count(), 1);
     QCOMPARE(changedSpy.at(0).count(), 1);
@@ -190,6 +193,8 @@ void tst_QFileSystemWatcher::basicTest()
     fileName = changedSpy.at(0).at(0).toString();
     QCOMPARE(fileName, testFile.fileName());
 
+#endif
+
     changedSpy.clear();
 
     // remove the watch and modify file permissions, should not get a signal from the watcher