Bug 423302

Summary: Document in API for KRecentFilesAction::addAction that temp files are ignored
Product: [Frameworks and Libraries] frameworks-kconfigwidgets Reporter: Rick Wagner <rjwgnr27>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs-null>
Status: RESOLVED FIXED    
Severity: wishlist CC: a.samirh78
Priority: NOR    
Version First Reported In: 5.70.0   
Target Milestone: ---   
Platform: Fedora RPMs   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Rick Wagner 2020-06-20 23:55:14 UTC
SUMMARY
Developing an app which uses KRecentFilesAction, I did my debug testing storing a file in /tmp/xxx.json, where added it to a KRecentFilesAction, using addUrl(). When I went to the associated "Open Recent..." menu entry, and found it greyed out. Spent hours looking at the creation of the action (through KXmlGuiClien::actionCollection()->addAction() and other permutations). Finally looked at the source for KRecentFilesAction::addAction() and found where the code quietly discards files in the temp directory:

    if (url.isLocalFile() && url.toLocalFile().startsWith(QDir::tempPath())) {
        return;
    }

While this makes some sense, "favors" done by the code should be documented. Some note to this effect should be in the API for the widget.

STEPS TO REPRODUCE
1. create an app using a KRecentFilesAction action
2. add a QUrl to a local file stored in the temp path
3. wonder why it does not show up in the recent files list

OBSERVED RESULT
1. File mysteriously does not show up in the recents list

EXPECTED RESULT
1. It should not be a mystery, as behavior should be documented.

SOFTWARE/OS VERSIONS
Windows: 
macOS: 
Linux/KDE Plasma: 
(available in About System)
KDE Plasma Version: 
KDE Frameworks Version: 
Qt Version: 

ADDITIONAL INFORMATION
Comment 1 Bug Janitor Service 2021-06-18 22:59:18 UTC
A possibly relevant merge request was started @ https://invent.kde.org/frameworks/kconfigwidgets/-/merge_requests/54
Comment 2 Ahmad Samir 2021-06-18 23:00:00 UTC
Good point, and thanks for the detailed report. :)
Comment 3 Ahmad Samir 2021-06-19 09:30:15 UTC
Git commit c12e0b8b858119b6c6a66ad6016fe92ffe998e02 by Ahmad Samir.
Committed on 19/06/2021 at 09:29.
Pushed by dfaure into branch 'master'.

KRecentFilesAction: document that local file URLs in the temp dir are ignored

M  +4    -1    src/krecentfilesaction.h

https://invent.kde.org/frameworks/kconfigwidgets/commit/c12e0b8b858119b6c6a66ad6016fe92ffe998e02