Bug 439961

Summary: kdirmodel not finding node for removed items when dialogs using kmozillahelper for Firefox are called
Product: [Frameworks and Libraries] frameworks-kio Reporter: Rob Krum <biggestsonicfan>
Component: Open/save dialogsAssignee: KIO Bugs <kio-bugs-null>
Status: REPORTED ---    
Severity: minor CC: kdebugs, kdelibs-bugs-null, smowtenshi
Priority: NOR    
Version First Reported In: 5.115.0   
Target Milestone: ---   
Platform: openSUSE   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:
Attachments: reproducible test case
kiobug.py rewritten more pythonically
Screenshot which shows the error still occurs in fresh install of TW

Description Rob Krum 2021-07-17 04:07:51 UTC
SUMMARY
Software kmozillahelper is an add-on installed by default with OpenSUSE installations. It works in conjunction with Firefox to create a richer file dialog experience when downloading and uploading files. Occasionally, certain files saved using the save file dialog will create the following warnings from kmozillahelper: kf.kio.widgets.kdirmodel: No node found for item that was just removed: QUrl("file:///location/to/file.extension"). Once this warning happens, it has a 1:3 to 1:2 chance of occurring again the next time the save file dialog is opened. It's not always the same file, but typically it lists the same file in succession over multiple entries. 

STEPS TO REPRODUCE
It's unclear what the direct cause is of the issue, but it's assumed to be this
1. Download a file using the save file dialog through kmozillahelper
2. Download another file before the save file dialog is finished closing through the save file dialog through kmozillahelper
3. The warning should appear in systemd journal logs

OBSERVED RESULT

Files saved through kmozillahelper throw warnings in the KDirModelPrivate::_k_slotDeleteItems function.

EXPECTED RESULT
Nodes should be properly created for removed items(?) to avoid the flood of warnings and allow proper garbage collection from files that have successfully completed downloading.

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: x86_64 Linux 5.13.1-1-default KDE 5.83.0 / Plasma 5.22.3
(available in About System)
KDE Plasma Version: 5.22.3
KDE Frameworks Version: 5.83.0
Qt Version: 5.15.2

ADDITIONAL INFORMATION
These errors have been logging for approximately 1.5 years and have persisted across multiple distro reinstallations.
Comment 1 kdebugs 2023-02-22 06:23:26 UTC
Created attachment 156588 [details]
reproducible test case

I also see this error using Frescobaldi (based on PyQt5) almost every time an open or save dialog is launched.

I've reduced the problem to a tiny reproducible test case.  Simply run the attached .py file according to the instructions at the top of the file, and the error message will appear, i.e.

kf.kio.widgets.kdirmodel: No node found for item that was just removed: QUrl("file:///home/user/path-to/subdir/not-a-cool-file.txt")

Operating System: Kubuntu 22.10
KDE Plasma Version: 5.25.5
KDE Frameworks Version: 5.98.0
Qt Version: 5.15.6
Comment 2 Rob Krum 2023-02-24 21:41:08 UTC
Sadly I am unable to reproduce the error with the script provided. I had however put: [export QT_LOGGING_RULES="kf.kio.widgets.kdirmodel.warning=false"] into my .bashrc file previously to supress the noise these errors cause. I've removed that line and the noise from kmozillahelper has resumed, flooding my logs, but the script itself isn't generating anything. It might be because I'm running it in IDLE and terminal?
Comment 3 kdebugs 2023-02-25 02:38:20 UTC
(In reply to Rob Krum from comment #2)
> Sadly I am unable to reproduce the error with the script provided. 
> ... It might be because I'm running
> it in IDLE and terminal?

I just realized we're experiencing this error message in different places.  You say it's in your systemd journal logs.  For me, it's just dumped into my Konsole window via stderr.  It does not appear when I look in journalctl.

I don't have IDLE installed, but I can't imagine that would make a difference.  It works the same for me whether I just run
python3 kiobug.py
or whether I start the REPL with python3 and then paste in the contents of the file.
You do, of course, need to follow the directions at the top of the file, i.e. click into the 'subdir' folder and hit escape to close the first popup.  The script I provided depends on PyQt5, but I also tried it with PySide2 and it works identically.

Sorry if it didn't reproduce for you.  It still does 100% for me.

I was also able to reproduce it in K3B using the same method.**  I also reproduced it in Konsole using the same method (using the Open File dialog that comes up with you click "View" -> "Load tab layout from file").  I couldn't reproduce it from certain other KDE programs, but that may have something to do with the particular file type filter each program applies to the Open File dialog.

**Make a folder containing a file that the program will not recognize and will thus filter out in the Open File dialog.  Launch the program from the folder containing the new folder (not from the new folder itself).  Open the open dialog, click into the folder, cancel/escape, and then open the dialog again.
Comment 4 Rob Krum 2024-03-07 01:23:35 UTC
Created attachment 166530 [details]
kiobug.py rewritten more pythonically

I had been meaning to do this for some time, but I have rewritten the test case by kdebugs@toeai.com in a more pythonic way. Instead of handing file/folder creation/removal via the "system" command, it uses python libraries. There is also the rare danger of running the original script in where a "subdir" folder exists, and the script will nuke it. This is avoided by creating a temp folder with a hashed timestamp to avoid any potential conflicts.

However, as with the original script, I can not reproduce the error still. I also no longer use linux as a daily driver but only as a subsystem in Windows now. However, I am confident if I just installed Firefox with Kmozillahelper and use it, I would continue to get this error flooding the journal.
Comment 5 kdebugs 2024-03-07 03:50:47 UTC
The error message doesn't reproduce for me anymore, either where it did for me (in the console) or where it did for you (in journal logs).  I get other errors in the journal log (related to QXcbConnection) but not this one.

Of course whatever used to cause this message was not directly related to Firefox, so the title of this bug isn't super useful.

If you can't reproduce it anymore, maybe it should be resolved WORKSFORME.
Comment 6 Rob Krum 2024-03-07 04:00:06 UTC
> If you can't reproduce it anymore, maybe it should be resolved WORKSFORME.

In my previous post I stated

> However, I am confident if I just installed Firefox with Kmozillahelper and use it, I would continue to get this error flooding the journal.

I will not be marking this resolved because your particular circumstance invoking the error is no longer reproducible whereas my original report still is. I can spin up a VM to verify but, again, I am confident nothing has changed. The title remains useful in that it is the exact circumstances to encounter this issue. The bug does not occur if you do not use kmozillahelper, and kmozillahelper cannot be invoked without firefox, but you can use firefox without kmozillahelper. Kmozillahelper is the bridge between Firefox and KDE to use KDE dialogs.
Comment 7 Rob Krum 2024-03-07 04:47:45 UTC
Created attachment 166540 [details]
Screenshot which shows the error still occurs in fresh install of TW

To see if the error was still reproducible using the steps given in the original report, a virtual machine with the most up to date build of openSUSE Tumbleweed was spun up. The error is still reproducible and I will update the bug report's specs.