On Tuesday 31 July 2012 03:33:39 Aleix Pol wrote:
> Hi,
> I've run into a problem recently that I'm not sure what's the
> solution, so I thought I'd ask the wise KDE crowd and see what we can
> do.
> 
> The problem happens in KDevelop, when editing CMakeLists.txt files. We
> have two KDirWatch instances pointing to those files:
> - kate to see if it has changed outside
> - kdevelop to see if the project has changed outside
> 
> now the problem is that, with my KDevelop hat on, if I add this file
> to my kdevelop's watch, when I save a CMakeLists.txt file Kate opens
> an dialog saying it has changed by a different process. But it's Kate
> itself who edited this file.
> 
> I've checked Kate's code and it looks ok to me and likewise kdevelop's
> not doing much else than listening to the file. If I comment out the
> addFile/addDir call, then it doesn't happen.

Is this two separate KDirWatch instances, or is this using KDirWatch::self()?

Also, could you try to make a unittest for the issue?
kdelibs/kdecore/tests/kdirwatch_unittest.cpp would seem appropriate :)
I tried, but it worked, see attached patch.
Please compare the situation in the unittest with the situation you're seeing 
in kdevelop+kate.

-- 
David Faure, fa...@kde.org, http://www.davidfaure.fr
Sponsored by Nokia to work on KDE, incl. KDE Frameworks 5
diff --git a/kdecore/tests/kdirwatch_unittest.cpp b/kdecore/tests/kdirwatch_unittest.cpp
index f743cf2..f7c49e3 100644
--- a/kdecore/tests/kdirwatch_unittest.cpp
+++ b/kdecore/tests/kdirwatch_unittest.cpp
@@ -89,6 +89,7 @@ private Q_SLOTS: // test methods
     void touchOneFile();
     void touch1000Files();
     void watchAndModifyOneFile();
+    void watchOneFileTwoInstances();
     void removeAndReAdd();
     void watchNonExistent();
     void watchNonExistentWithSingleton();
@@ -367,6 +368,28 @@ void KDirWatch_UnitTest::watchAndModifyOneFile() // watch a specific file, and m
     QVERIFY(waitForOneSignal(watch, SIGNAL(dirty(QString)), existingFile));
 }
 
+void KDirWatch_UnitTest::watchOneFileTwoInstances()
+{
+    KDirWatch watch;
+    KDirWatch watch2;
+    const QString existingFile = m_path + "ExistingFile";
+    watch.addFile(existingFile);
+    watch.startScan();
+    watch2.addFile(existingFile);
+    watch2.startScan();
+    QSignalSpy spy1(&watch, SIGNAL(dirty(QString)));
+    QSignalSpy spy2(&watch2, SIGNAL(dirty(QString)));
+    if (m_slow)
+        waitUntilNewSecond();
+    appendToFile(existingFile);
+    QVERIFY(waitForOneSignal(watch, SIGNAL(dirty(QString)), existingFile));
+    if (spy2.isEmpty())
+        QVERIFY(waitForOneSignal(watch2, SIGNAL(dirty(QString)), existingFile));
+    QTest::qWait(200);
+    QCOMPARE(spy1.count(), 1);
+    QCOMPARE(spy2.count(), 1);
+}
+
 void KDirWatch_UnitTest::removeAndReAdd()
 {
     KDirWatch watch;
>> Visit http://mail.kde.org/mailman/listinfo/kde-devel#unsub to unsubscribe <<

Reply via email to