Skip to content

Commit

Permalink
kde-frameworks/kcoreaddons: Add kdirwatch fix
Browse files Browse the repository at this point in the history
Package-Manager: Portage-2.3.5, Repoman-2.3.1
  • Loading branch information
a17r committed May 24, 2017
1 parent 0550664 commit 60aa472
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
From 792680d43877efbea7c2367bab564e41da98be45 Mon Sep 17 00:00:00 2001
From: Elvis Angelaccio <[email protected]>
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

32 changes: 32 additions & 0 deletions kde-frameworks/kcoreaddons/kcoreaddons-5.34.0-r1.ebuild
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 1999-2017 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

EAPI=6

inherit kde5

DESCRIPTION="Framework for solving common problems such as caching, randomisation, and more"
LICENSE="LGPL-2+"
KEYWORDS="~amd64 ~arm ~x86"
IUSE="fam nls"

RDEPEND="
$(add_qt_dep qtcore 'icu')
fam? ( virtual/fam )
!<kde-frameworks/kservice-5.2.0:5
"
DEPEND="${RDEPEND}
x11-misc/shared-mime-info
nls? ( $(add_qt_dep linguist-tools) )
"

PATCHES=( "${FILESDIR}/${P}-ignore-qrc-paths.patch" )

src_configure() {
local mycmakeargs=(
-D_KDE4_DEFAULT_HOME_POSTFIX=4
$(cmake-utils_use_find_package fam FAM)
)

kde5_src_configure
}

0 comments on commit 60aa472

Please sign in to comment.