QFileSystemWatcher/Windows: Output paths if FindNext fails.
authorFriedemann Kleint <Friedemann.Kleint@nokia.com>
Wed, 11 Jan 2012 15:58:45 +0000 (16:58 +0100)
committerQt by Nokia <qt-info@nokia.com>
Thu, 12 Jan 2012 11:08:19 +0000 (12:08 +0100)
Change-Id: I72bd28868c84d37e3dd4ea8ab892fa092d853d4a
Reviewed-by: Bradley T. Hughes <bradley.hughes@nokia.com>
src/corelib/io/qfilesystemwatcher_win.cpp

index 4f2ff93..3028f94 100644 (file)
@@ -50,6 +50,7 @@
 #include <qset.h>
 #include <qdatetime.h>
 #include <qdir.h>
+#include <qtextstream.h>
 
 QT_BEGIN_NAMESPACE
 
@@ -312,6 +313,17 @@ QWindowsFileSystemWatcherEngineThread::~QWindowsFileSystemWatcherEngineThread()
     }
 }
 
+static inline QString msgFindNextFailed(const QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo> &pathInfos)
+{
+    QString result;
+    QTextStream str(&result);
+    str << "QFileSystemWatcher: FindNextChangeNotification failed for";
+    foreach (const QWindowsFileSystemWatcherEngine::PathInfo &pathInfo, pathInfos)
+        str << " \"" << QDir::toNativeSeparators(pathInfo.absolutePath) << '"';
+    str << ' ';
+    return result;
+}
+
 void QWindowsFileSystemWatcherEngineThread::run()
 {
     QMutexLocker locker(&mutex);
@@ -342,11 +354,11 @@ void QWindowsFileSystemWatcherEngineThread::run()
                 // for some reason, so we must check if the handle exist in the handles vector
                 if (handles.contains(handle)) {
                     // qDebug()<<"thread"<<this<<"Acknowledged handle:"<<at<<handle;
+                    QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo> &h = pathInfoForHandle[handle];
                     if (!FindNextChangeNotification(handle)) {
-                        qErrnoWarning("QFileSystemWatcher: FindNextChangeNotification failed!!");
+                        const DWORD error = GetLastError();
+                        qErrnoWarning(error, "%s", qPrintable(msgFindNextFailed(h)));
                     }
-
-                    QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo> &h = pathInfoForHandle[handle];
                     QMutableHashIterator<QString, QWindowsFileSystemWatcherEngine::PathInfo> it(h);
                     while (it.hasNext()) {
                         QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo>::iterator x = it.next();