summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAnthony Fieroni <bvbfan@abv.bg>2016-12-04 18:54:57 (GMT)
committerAnthony Fieroni <bvbfan@abv.bg>2016-12-04 18:54:57 (GMT)
commit4a1c479b24f1fdc17e96326be43d0398e610b16b (patch)
treec566bc4dfdfd7ec5cdc5f3731315868409983155
parent9ff088660d66391fdd9ca46d62d12fd2e4a6deac (diff)
[filenamesearch] Fix huge ram usage in kded modulev16.12.0
Signed-off-by: Anthony Fieroni <bvbfan@abv.bg>
-rw-r--r--filenamesearch/kded/filenamesearchmodule.cpp33
1 files changed, 22 insertions, 11 deletions
diff --git a/filenamesearch/kded/filenamesearchmodule.cpp b/filenamesearch/kded/filenamesearchmodule.cpp
index 3f9f582..f12626d 100644
--- a/filenamesearch/kded/filenamesearchmodule.cpp
+++ b/filenamesearch/kded/filenamesearchmodule.cpp
@@ -59,8 +59,13 @@ void FileNameSearchModule::unregisterSearchUrl(const QString &urlString)
void FileNameSearchModule::slotFilesAdded(const QString &urlString)
{
+ const QUrl url(urlString);
+ if (!url.isLocalFile()) {
+ return;
+ }
+ const QString urlPath = url.path();
for (const QUrl &dirUrl : m_searchUrls) {
- if (urlString.startsWith(dirUrl.path())) {
+ if (urlPath.startsWith(dirUrl.path())) {
org::kde::KDirNotify::emitFilesAdded(dirUrl);
}
}
@@ -69,11 +74,14 @@ void FileNameSearchModule::slotFilesAdded(const QString &urlString)
void FileNameSearchModule::slotFilesChanged(const QStringList &files)
{
QList<QUrl> fileList;
- fileList.reserve(files.count());
- for (const QUrl &dirUrl : m_searchUrls) {
- for (const QString &file : files) {
- if (file.startsWith(dirUrl.path())) {
- QUrl url(file);
+ for (const QString &file : files) {
+ QUrl url(file);
+ if (!url.isLocalFile()) {
+ continue;
+ }
+ const QString urlPath = url.path();
+ for (const QUrl &dirUrl : m_searchUrls) {
+ if (urlPath.startsWith(dirUrl.path())) {
url.setScheme(QStringLiteral("filenamesearch"));
fileList << url;
}
@@ -87,11 +95,14 @@ void FileNameSearchModule::slotFilesChanged(const QStringList &files)
void FileNameSearchModule::slotFilesRemoved(const QStringList &files)
{
QList<QUrl> fileList;
- fileList.reserve(files.count());
- for (const QUrl &dirUrl : m_searchUrls) {
- for (const QString &file : files) {
- if (file.startsWith(dirUrl.path())) {
- QUrl url(file);
+ for (const QString &file : files) {
+ QUrl url(file);
+ if (!url.isLocalFile()) {
+ continue;
+ }
+ const QString urlPath = url.path();
+ for (const QUrl &dirUrl : m_searchUrls) {
+ if (urlPath.startsWith(dirUrl.path())) {
url.setScheme(QStringLiteral("filenamesearch"));
fileList << url;
}