Bug 441802 - Can't open file via menu / Ctrl+O but can via drag-and-drop / recent files
Summary: Can't open file via menu / Ctrl+O but can via drag-and-drop / recent files
Status: RESOLVED UPSTREAM
Alias: None
Product: okteta
Classification: Applications
Component: general (show other bugs)
Version: 0.26.6
Platform: Arch Linux Linux
: NOR normal
Target Milestone: ---
Assignee: Friedrich W. H. Kossebau
URL:
Keywords:
: 452943 461185 (view as bug list)
Depends on:
Blocks:
 
Reported: 2021-08-31 08:10 UTC by viktor
Modified: 2022-10-30 02:03 UTC (History)
3 users (show)

See Also:
Latest Commit:
Version Fixed In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description viktor 2021-08-31 08:10:44 UTC
SUMMARY
I've found similar report on Arch Linux forum (https://bbs.archlinux.org/viewtopic.php?id=252546), but will describe here too. When opening file via main menu after file was selected and Open button was clicked nothing happens at all. However if I drag file from Dolphin and drop in Okteta main window it loads into separate tab as it should. Also selecting file from Recent list in main menu works too.

STEPS TO REPRODUCE
1. Choose file for opening via main menu
2. Click Open button
3. No file will be opened
4. Try to drag-and-drop file from Dolphin or select one from Recent menu
5. File will be opened

OBSERVED RESULT
File will not be opened via main menu

EXPECTED RESULT
File should be opened via main menu

SOFTWARE/OS VERSIONS
KDE Plasma Version: 5.22.4
KDE Frameworks Version: 5.85.0
Qt Version: 5.15.2 with KDE patches
Comment 1 Friedrich W. H. Kossebau 2021-08-31 13:07:52 UTC
Thanks for the report. First time I hear this, also sadly can not reproduce it when trying with Okteta from openSUSE TW package, as well using Qt 5.15.2 & KF 5.85.0 (and Plasma 5.22.4).

For now I have to suspect some Arch-specific issue. Does opening files via the Open menu entry and then the file picker work for other KF-based programs?
Comment 2 viktor 2021-08-31 13:13:51 UTC
Just tested opening ZIP archive with Ark - works fine
Comment 3 Friedrich W. H. Kossebau 2021-08-31 13:23:29 UTC
Looking at the different code paths, the only thing for now I could imagine to fail between showing the file picker dialog and the methods then triggering loading is the usage of the QFileDialog::urlsSelected signal, which I just fonud to be Okteta the only one in the KDE sheres by lxr.kde.org grepping.
So chance is that whatever got broken (perhaps by some Arch-specific patches) then also only affects Okteta.

Respective ocde is at
https://invent.kde.org/utilities/okteta/-/blob/0.26/libs/kasten/controllers/documentsystem/loader/loadercontroller.cpp#L63

Qt API docs:
https://doc.qt.io/qt-5/qfiledialog.html#urlsSelected

So this needs someone to invesigate why with Arch that signal would not be emitted. Does Arch have some special file dialog plugin, after all Qt uses the one coming from the respective plugin integration?
Comment 4 viktor 2021-08-31 13:26:35 UTC
According to their PKGBUILD (https://github.com/archlinux/svntogit-packages/blob/packages/okteta/trunk/PKGBUILD) no special patches were used for Okteta package
Comment 5 Friedrich W. H. Kossebau 2021-08-31 13:29:14 UTC
While you gave "KDE Plasma Version: 5.22.4" as requested by the form, are you also using Plasma when experiencing this? Or some other environment (like the person whose Arch report you linked)? In that case our eyes should move to the Qt plugin for that environment and what QFileDialog implementation it provides.
Comment 6 viktor 2021-08-31 13:30:40 UTC
It happens both in Plasma and Cinnamon as well

I've filed a bug (https://bugs.archlinux.org/task/71964) for Arch too
Comment 7 Friedrich W. H. Kossebau 2021-08-31 13:57:06 UTC
Quick dump of where on first understanding the issue might to be searched:

the file dialog picker dialog as provided by Qt when using QFileDialog can be delivered from the platform integration used for the respective environment. That will be loaded from a respective plugin, where e.g. a QPlatformTheme subclass is provided and in the override of
   QPlatformDialogHelper *createPlatformDialogHelper(DialogType type) const
would provide a specific subclass of QPlatformFileDialogHelper in case of type being QPlatformTheme::FileDialog.

That QPlatformFileDialogHelper implementation needs to emit the signal
    void filesSelected(const QList<QUrl> &files);
accordingly to the expectations of QFileDialog itself, which cares for the emission of the QFileDialog::urlsSelected when that other signal is emitted
See the wire-up at https://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/dialogs/qfiledialog.cpp?h=5.15#n559

So we would need to find what QPA plugin(s) are used here and what their QPlatformTheme subclass injects here as file dialog helper code. As by now I would suspect it misses to emit the filesSelected() signal.

No clue about QPA myself otherwise, also not a bug of Okteta then.
Comment 8 Friedrich W. H. Kossebau 2021-08-31 15:29:08 UTC
Some further code understandings:

QFileDialog in QFileDialog::accept() (see https://code.qt.io/cgit/qt/qtbase.git/tree/src/widgets/dialogs/qfiledialog.cpp?h=5.15#n2809) has code to trigger the emission of the QFileDialog::urlsSelected even if the platform integration helper does not emit the filesSelected() signal, as !d->usingWidgets() would be true and   d->_q_emitUrlsSelected(urls); would trigger the emission.

Looked around elsewhere and found some suspicuous code in the xdg portal variant of the Plasma integration which perhaps could trigger things, left comment at related MR:
https://invent.kde.org/plasma/plasma-integration/-/merge_requests/4#note_296573
Comment 9 Antonio Rojas 2021-08-31 17:08:09 UTC
Are you using qt5ct? That's the only way I can reproduce this.
Comment 10 Antonio Rojas 2021-08-31 17:12:34 UTC
(In reply to Antonio Rojas from comment #9)
> Are you using qt5ct? That's the only way I can reproduce this.

Actually, the problem seems to be the plain Qt file picker. I can reproduce in Plasma by removing plasma-integration (I couldn't find an env variable to force using the Qt file picker without removing it)
Comment 11 Friedrich W. H. Kossebau 2021-08-31 18:45:41 UTC
(In reply to Antonio Rojas from comment #10)
> Actually, the problem seems to be the plain Qt file picker. I can reproduce
> in Plasma by removing plasma-integration (I couldn't find an env variable to
> force using the Qt file picker without removing it)

Good idea. Indeed, on a quick look I could not find how QFileDialog itself would invoke the signal if not using a QPlatformDialogHelper. Ouch.

And the built-in would be used for any QPA which does not provide a custom one on the request by QGuiApplicationPrivate::platformTheme()->createPlatformDialogHelper(static_cast<QPlatformTheme::DialogType>(type));

Seems https://codereview.qt-project.org/c/qt/qtbase/+/89484 missed out that code path :(

Next up: writing a test & bug for Qt
Comment 12 viktor 2021-08-31 19:10:13 UTC
I'm using qt5ct and the only thing that it serve is to select breeze theme
Comment 13 Friedrich W. H. Kossebau 2021-08-31 21:35:00 UTC
I created some sample code to demonstrate the bug and filed an issue with Qt: https://bugreports.qt.io/browse/QTBUG-96157

Hopefully someone can invest into fixing that bug, should not be that difficult, given things are done properly in the other code paths. No spare resources myselr sadly. I would also not want to invest any resources in a work-around in Okteta, they all should be put onto fixing this upstream and helping any users of those signals.

Thanks Viktor for reporting the bug and Antonio for hunting down at least one source for the wrong behaviour.
Comment 14 Friedrich W. H. Kossebau 2022-05-05 15:15:13 UTC
*** Bug 452943 has been marked as a duplicate of this bug. ***
Comment 15 Friedrich W. H. Kossebau 2022-05-20 11:27:00 UTC
*** Bug 454083 has been marked as a duplicate of this bug. ***
Comment 16 Friedrich W. H. Kossebau 2022-10-30 02:03:04 UTC
*** Bug 461185 has been marked as a duplicate of this bug. ***