[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: branches/kdepim/enterprise4/kdelibs-4.0.83/kio
From: Jaroslaw Staniek <js () iidea ! pl>
Date: 2008-07-10 17:33:34
Message-ID: 1215711214.266819.30951.nullmailer () svn ! kde ! org
[Download RAW message or body]
SVN commit 830519 by staniek:
Break limitation of file watchers for KDirWatch on Windows
Maximum number of wait objects per single QFileSystemWatcher
is MAXIMUM_WAIT_OBJECTS (64) on Windows.
Attached implementation of KFileSystemWatcher. It's a typedef
for QFileSystemWatcher, except on Windows, where we allocate
more QFileSystemWatcher instances on demand (and deallocate them too).
(reviewed, backported from trunk)
M +6 -0 CMakeLists.txt
M +1 -4 kio/kdirwatch.cpp
M +42 -1 kio/kdirwatch_p.h
A kio/kdirwatch_win.cpp [License: LGPL (v2)]
--- branches/kdepim/enterprise4/kdelibs-4.0.83/kio/CMakeLists.txt #830518:830519
@@ -128,6 +128,12 @@
)
endif(UNIX)
+if(WIN32)
+ set(kiocore_STAT_SRCS ${kiocore_STAT_SRCS}
+ kio/kdirwatch_win.cpp
+ )
+endif(WIN32)
+
set(kbookmarks_STAT_SRCS
bookmarks/kbookmark.cc
bookmarks/kbookmarkimporter.cc
--- branches/kdepim/enterprise4/kdelibs-4.0.83/kio/kio/kdirwatch.cpp #830518:830519
@@ -51,9 +51,6 @@
#include <QtCore/QFile>
#include <QtCore/QSocketNotifier>
#include <QtCore/QTimer>
-#ifdef HAVE_QFILESYSTEMWATCHER
-#include <QtCore/QFileSystemWatcher>
-#endif
#include <kapplication.h>
#include <kdebug.h>
@@ -202,7 +199,7 @@
#endif
#ifdef HAVE_QFILESYSTEMWATCHER
availableMethods << "QFileSystemWatcher";
- fsWatcher = new QFileSystemWatcher();
+ fsWatcher = new KFileSystemWatcher();
connect(fsWatcher, SIGNAL(directoryChanged(QString)), this, SLOT(fswEventReceived(QString)));
connect(fsWatcher, SIGNAL(fileChanged(QString)), this, SLOT(fswEventReceived(QString)));
#endif
--- branches/kdepim/enterprise4/kdelibs-4.0.83/kio/kio/kdirwatch_p.h #830518:830519
@@ -7,6 +7,7 @@
* Copyright (C) 1998 Sven Radej <sven@lisa.exp.univie.ac.at>
* Copyright (C) 2006 Dirk Mueller <mueller@kde.org>
* Copyright (C) 2007 Flavio Castelli <flavio.castelli@gmail.com>
+ * Copyright (C) 2008 Jaroslaw Staniek <js@iidea.pl>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -63,6 +64,46 @@
#define invalid_ctime ((time_t)-1)
+#ifdef HAVE_QFILESYSTEMWATCHER
+#include <QtCore/QFileSystemWatcher>
+
+#if defined Q_WS_WIN
+/* Helper implemented as a workaround for limitation on Windows:
+ * the maximum number of object handles is MAXIMUM_WAIT_OBJECTS (64) per thread.
+ *
+ * From http://msdn.microsoft.com/en-us/library/ms687025(VS.85).aspx
+ * "To wait on more than MAXIMUM_WAIT_OBJECTS handles, create a thread to wait
+ * on MAXIMUM_WAIT_OBJECTS handles, then wait on that thread plus the other handles.
+ * Use this technique to break the handles into groups of MAXIMUM_WAIT_OBJECTS."
+ *
+ * QFileSystemWatcher is implemented as thread, so KFileSystemWatcher
+ * allocates more QFileSystemWatcher instances on demand (and deallocates them later).
+ */
+class KFileSystemWatcher : public QObject
+{
+ Q_OBJECT
+public:
+ KFileSystemWatcher();
+ ~KFileSystemWatcher();
+ void addPath(const QString &file);
+ void removePath(const QString &file);
+
+Q_SIGNALS:
+ void fileChanged(const QString &path);
+ void directoryChanged(const QString &path);
+
+private:
+ QFileSystemWatcher* availableWatcher();
+ QFileSystemWatcher* m_recentWatcher;
+ QList<QFileSystemWatcher*> m_watchers;
+ QHash<QFileSystemWatcher*, uint> m_usedObjects;
+ QHash<QString,QFileSystemWatcher*> m_paths;
+};
+#else
+typedef KFileSystemWatcher QFileSystemWatcher;
+#endif
+#endif
+
/* KDirWatchPrivate is a singleton and does the watching
* for every KDirWatch instance in the application.
*/
@@ -194,7 +235,7 @@
bool useINotify(Entry*);
#endif
#ifdef HAVE_QFILESYSTEMWATCHER
- QFileSystemWatcher *fsWatcher;
+ KFileSystemWatcher *fsWatcher;
bool useQFSWatch(Entry* e);
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic