Commit 408f03ca authored by Robert Hoffmann's avatar Robert Hoffmann Committed by David Faure

Avoid calling QT_LSTAT and accessing recent documents

Document entries pointing to unavailable network shares freeze
the application menu, so avoid calling QT_LSTAT (lstat64())
three times for each list item and reading the first 16k of
each document when showing the recent documents list in application

The current behaviour of accessing each document in the list
just by browsing the application menu is inacceptable in large
enterprise environments where thousands of users work
with documents located on mounted network shares. This induces
additional load on filers and network, slows down working
with the menu and makes its functioning dependent on network
and remote filesystems.

Test Plan:
1. Open a document on a mounted network share, e.g. a text document
   on a CIFS share with Libreoffice Writer or Kate.
2. Open the application menu (kicker), look at Recent Documents, the
   document's filename should be there.
3. Pull out the network plug, open the application menu, try to open
   Recent Documents. Without this patch, the application menu doesn't
   work anymore and just hangs. With this patch applied, the menu
   continues working.

Reviewers: #frameworks, dfaure, #dolphin

Reviewed By: dfaure

Subscribers: apol, ngraham, plasma-devel

Tags: #plasma

Differential Revision:
parent 4487f0f3
......@@ -22,6 +22,7 @@
#include "appsmodel.h"
#include "appentry.h"
#include "kastatsfavoritesmodel.h"
#include <kio_version.h>
#include <config-X11.h>
......@@ -243,9 +244,14 @@ QVariant RecentUsageModel::docData(const QString &resource, int role) const
// Avoid calling QT_LSTAT and accessing recent documents
const KFileItem fileItem(url, KFileItem::SkipMimeTypeFromContent);
const KFileItem fileItem(url);
if (!url.isValid() || !(fileItem.isFile() || fileItem.isDir())) {
if (!url.isValid()) {
return QVariant();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment