--- /dev/null
+From 792680d43877efbea7c2367bab564e41da98be45 Mon Sep 17 00:00:00 2001
+From: Elvis Angelaccio <elvis.angelaccio@kde.org>
+Date: Mon, 15 May 2017 23:44:04 +0200
+Subject: Do not watch QRC's paths
+
+Watching a QRC path is not supported and results in `"."` being
+watched which can lead to problems.
+
+For example in bug #374075 KIO adds ":/kio5/newfile-templates"
+as path to watch (this is probably another bug in itself).
+If we are already watching "/home/user", this breaks the emission
+of the dirty() signal for every new children of "/home/user" (somehow,
+the relative path is used for them, e.g. "./foo.txt" instead of
+"/home/user/foo.txt"). In particular, in inotifyEventReceived()
+e->m_client is empty and so e->path is not added to
+e->m_pendingFileChanges. This only happens if "/home/user" is also
+the cwd of the process using KDirWatch.
+
+Ignoring QRC paths fixes this issue.
+
+BUG: 374075
+FIXED-IN: 5.35
+
+Test Plan:
+From dolphin, Create New -> Text File in a folder which is also the current working
+directory of the dolphin process.
+
+Reviewers: dfaure
+
+Differential Revision: https://phabricator.kde.org/D5877
+---
+ autotests/kdirwatch_unittest.cpp | 24 ++++++++++++++++++++++++
+ src/lib/io/kdirwatch.cpp | 4 ++++
+ 2 files changed, 28 insertions(+)
+
+diff --git a/autotests/kdirwatch_unittest.cpp b/autotests/kdirwatch_unittest.cpp
+index b436eb4..e574b5a 100644
+--- a/autotests/kdirwatch_unittest.cpp
++++ b/autotests/kdirwatch_unittest.cpp
+@@ -112,6 +112,7 @@ private Q_SLOTS: // test methods
+ void nestedEventLoop();
+ void testHardlinkChange();
+ void stopAndRestart();
++ void shouldIgnoreQrcPaths();
+
+ protected Q_SLOTS: // internal slots
+ void nestedEventLoopSlot();
+@@ -749,4 +750,27 @@ void KDirWatch_UnitTest::stopAndRestart()
+ QFile::remove(file3);
+ }
+
++void KDirWatch_UnitTest::shouldIgnoreQrcPaths()
++{
++ const auto oldCwd = QDir::currentPath();
++ QVERIFY(QDir::setCurrent(QDir::homePath()));
++
++ KDirWatch watch;
++ watch.addDir(QDir::homePath());
++ // This triggers bug #374075.
++ watch.addDir(QStringLiteral(":/kio5/newfile-templates"));
++
++ QSignalSpy dirtySpy(&watch, &KDirWatch::dirty);
++
++ QFile file(QStringLiteral("bug374075.txt"));
++ QVERIFY(file.open(QIODevice::WriteOnly));
++ QVERIFY(file.write(QByteArrayLiteral("test")));
++ file.close();
++ QVERIFY(file.exists());
++ QVERIFY(dirtySpy.wait());
++ QVERIFY(dirtySpy.count() > 0);
++ QVERIFY(file.remove());
++ QVERIFY(QDir::setCurrent(oldCwd));
++}
++
+ #include "kdirwatch_unittest.moc"
+diff --git a/src/lib/io/kdirwatch.cpp b/src/lib/io/kdirwatch.cpp
+index 060037b..2278b71 100644
+--- a/src/lib/io/kdirwatch.cpp
++++ b/src/lib/io/kdirwatch.cpp
+@@ -791,6 +791,10 @@ void KDirWatchPrivate::addEntry(KDirWatch *instance, const QString &_path,
+ Entry *sub_entry, bool isDir, KDirWatch::WatchModes watchModes)
+ {
+ QString path(_path);
++ if (path.startsWith(QLatin1String(":/"))) {
++ qCWarning(KDIRWATCH) << "Cannot watch QRC-like path" << path;
++ return;
++ }
+ if (path.isEmpty()
+ #ifndef Q_OS_WIN
+ || path == QLatin1String("/dev")
+--
+cgit v0.11.2
+