diff --git a/src/gui/folderwatcher_linux.cpp b/src/gui/folderwatcher_linux.cpp index 01fcdba1ae5e3..62b826244a2fb 100644 --- a/src/gui/folderwatcher_linux.cpp +++ b/src/gui/folderwatcher_linux.cpp @@ -149,7 +149,7 @@ void FolderWatcherPrivate::slotReceivedNotification(int fd) // iterate events in buffer unsigned int ulen = len; - for (i = 0; i + sizeof(inotify_event) < ulen; i += sizeof(inotify_event) + (event ? event->len : 0)) { + for (i = 0; i + sizeof(inotify_event) <= ulen; i += sizeof(inotify_event) + (event ? event->len : 0)) { // cast an inotify_event event = (struct inotify_event *)&buffer[i]; if (!event) { @@ -157,6 +157,13 @@ void FolderWatcherPrivate::slotReceivedNotification(int fd) continue; } + if (event->mask & IN_Q_OVERFLOW) { + qCWarning(lcFolderWatcher) + << "The inotify event queue overflowed; triggering a full local discovery"; + emit _parent->lostChanges(); + continue; + } + // Fire event for the path that was changed. if (event->len == 0 || event->wd <= -1) continue; diff --git a/src/gui/folderwatcher_win.cpp b/src/gui/folderwatcher_win.cpp index a46b429d8176b..895adf4380a8e 100644 --- a/src/gui/folderwatcher_win.cpp +++ b/src/gui/folderwatcher_win.cpp @@ -72,6 +72,7 @@ void WatcherThread::watchChanges(size_t fileNotifyBufferSize, const DWORD errorCode = GetLastError(); if (errorCode == ERROR_NOTIFY_ENUM_DIR) { qCDebug(lcFolderWatcher) << "The buffer for changes overflowed! Triggering a generic change and resizing"; + emit lostChanges(); emit changed(_path); *increaseBufferSize = true; } else {