Bug 509320

Summary: KRecentFilesMenu sometimes shows empty file names when a secondary display is disconnected
Product: [Frameworks and Libraries] frameworks-kwidgetsaddons Reporter: Forest <forestix>
Component: generalAssignee: Christoph Feck <cfeck>
Status: RESOLVED FIXED    
Severity: normal CC: kdelibs-bugs-null, nate
Priority: NOR Keywords: regression
Version First Reported In: 6.13.0   
Target Milestone: ---   
Platform: Debian stable   
OS: Linux   
Latest Commit: Version Fixed In: 6.19
Sentry Crash Report:

Description Forest 2025-09-09 18:58:48 UTC
SUMMARY

When calculating the maximum available width for file names/paths, RecentFilesEntry uses the narrowest screen reported by QApplication.screens(). This is usually fine, but on some systems, that method can return screens with zero width. (For example, when an xorg.conf ServerLayout refers to a Screen that is not currently connected.) Consequently, KRecentFilesMenu populates itself with file names truncated to zero characters.

STEPS TO REPRODUCE
1. Configure xorg.conf with a ServerLayout section including at least two Screen entries.
2. Disconnect the display corresponding to one of those entries.
3. Start a Plasma X11 session
4. Open a few archive files with Ark, to populate its Recent Files menu. (Or Kate or Okular, since they seem to be affected as well.)
5. Open the Recent Files menu

OBSERVED RESULT

The Recent Files menu looks something like this:

[]
[]
[]

EXPECTED RESULT

The Recent Files menu should look more like this:

stuff.zip [/home/user/stuff.zip]
my.tar.gz [/home/user/my.tar.gz]
stuff.tar [/home/user/stuff.tar]

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Debian Stable 13.1 (Trixie)
KDE Plasma Version: 6.3.6
KDE Frameworks Version: 6.13.0
Qt Version: 6.8.2

ADDITIONAL INFORMATION

I will submit a merge request soon.
Comment 2 Forest 2025-09-09 23:48:23 UTC
This problem appeared after upgrading Debian from Plasma 5.27 to Plasma 6.3.6 + Frameworks 6.13.0.
Comment 3 Christoph Cullmann 2025-09-15 17:49:25 UTC
Git commit e55448c18f0666433f70b88b922a295033b456e2 by Christoph Cullmann, on behalf of Forest ix.
Committed on 15/09/2025 at 17:49.
Pushed by cullmann into branch 'master'.

KRecentFilesMenu: do not cut text for zero-width screens

When calculating the maximum available width for file names/paths,
RecentFilesEntry uses the narrowest screen reported by
QApplication.screens(). This is usually fine, but on some systems, that
method can return screens with zero width. (For example, when an
xorg.conf ServerLayout refers to a Screen that is not currently
connected.) Consequently, KRecentFilesMenu populates itself with file
names truncated to zero characters. The menu looks like this:

    []
    []
    []

...when it should look like this:

    stuff.zip [/home/user/stuff.zip]
    my.tar.gz [/home/user/my.tar.gz]
    stuff.tar [/home/user/stuff.tar]

This patch makes titleWithSensibleWidth() ignore zero-width screens when deciding how short to cut file names and paths.

M  +9    -1    src/krecentfilesmenu.cpp

https://invent.kde.org/frameworks/kwidgetsaddons/-/commit/e55448c18f0666433f70b88b922a295033b456e2