Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QFileDialog fails to use platform-native dialog if static linked #33

Open
hebasto opened this issue Jul 15, 2020 · 11 comments
Open

QFileDialog fails to use platform-native dialog if static linked #33

hebasto opened this issue Jul 15, 2020 · 11 comments
Labels
Bug Something isn't working Linux

Comments

@hebasto
Copy link
Member

hebasto commented Jul 15, 2020

While investigating #32 I found a buggy (?) behavior of QFileDialog.

From the Qt docs:

By default, a platform-native file dialog will be used if the platform has one.

When Qt and QPA plugin are dynamic linked:

$ ./src/qt/bitcoin-qt -printtoconsole
2020-07-15T09:15:39Z [main] Bitcoin Core version v0.20.0 (release build)
2020-07-15T09:15:39Z [main] Qt 5.12.8 (dynamic), plugin=xcb (dynamic)

QFileDialog works as expected, and uses a platform-native file dialog.


When Qt and QPA plugin are static linked (gitian builds):

$ /home/hebasto/bitcoin-0.20.0/bin/bitcoin-qt -printtoconsole
2020-07-15T09:07:04Z Bitcoin Core version v0.20.0 (release build)
2020-07-15T09:07:04Z Qt 5.9.8 (static), plugin=xcb (static)

QFileDialog fails to recognize the platform, and uses a widget-based implementation.

Even running with QT_QPA_PLATFORM=xcb doesn't help.

@hebasto
Copy link
Member Author

hebasto commented Jul 15, 2020

https://forum.kde.org/viewtopic.php?t=90626#p172050:

In order to use the native KDE file dialog, you need to link to Qt dynamically.

https://forum.kde.org/viewtopic.php?t=90626#p172100:

This is a limitation in Qt, not KDE.
Qt cannot guarantee that plugin loading works on all platforms when being linked statically.

Especially not when the plugin is linked against a different version of Qt.

Could be related:

@maflcko
Copy link
Contributor

maflcko commented Jul 15, 2020

So why is the widget based dialog unable to detect any folders?

@hebasto
Copy link
Member Author

hebasto commented Jul 15, 2020

So why is the widget based dialog unable to detect any folders?

That is the question in #32, and I'm still working on it :)

This issue differs from #32.

@ryanofsky
Copy link
Contributor

Nice find!

@hebasto
Copy link
Member Author

hebasto commented Jul 16, 2020

@MarcoFalke

So why is the widget based dialog unable to detect any folders?

A: bitcoin/bitcoin#19536

@hebasto
Copy link
Member Author

hebasto commented Aug 9, 2020

UPDATE: such behavior observed on Linux only.

Static builds work fine on Windows (tested Windows 10) and macOS (tested macOS 10.15.6).

@fanquake
Copy link
Member

fanquake commented Aug 10, 2020

UPDATE: such behavior observed on Linux only.

I thought this was fixed by bitcoin/bitcoin#19536?

This change partially reverts 248e22b (#16386) and makes QFileDialogs work again for static builds.
Fixes #32.

Right, I see these are separate.

@hebasto
Copy link
Member Author

hebasto commented Aug 10, 2020

$ make -C depends
make: Entering directory '/home/hebasto/guix/GitHub/bitcoin/depends'
Extracting qt...
/home/hebasto/guix/GitHub/bitcoin/depends/sources/qtbase-opensource-src-5.9.8.tar.xz: OK
/home/hebasto/guix/GitHub/bitcoin/depends/sources/qttranslations-opensource-src-5.9.8.tar.xz: OK
/home/hebasto/guix/GitHub/bitcoin/depends/sources/qttools-opensource-src-5.9.8.tar.xz: OK
Preprocessing qt...
...
Configuring qt...
Creating qmake...
...
Done running configuration tests.

Configure summary:
...
Qt Widgets:
  GTK+ ................................... no
  Styles ................................. Fusion Windows
...

@theuni
Could missed GTK+ support cause this bug?

@hebasto
Copy link
Member Author

hebasto commented Aug 11, 2020

This @laanwj's comment is old enough but seems related:

As I've said before many times, I'm not happy about statically linking qt on Linux - and certainly not everything it depends on like font libraries. This should be up to the system. This will mess up appmenu integration in Ubuntu, for example, and other distro-specific customization.

@hebasto
Copy link
Member Author

hebasto commented Aug 12, 2020

Could missed GTK+ support cause this bug?

It seems missed GTK+ support does not cause this bug.
I've configured and compiled static Qt with

Qt Widgets:
  GTK+ ................................... yes
  Styles ................................. Fusion Windows

then compiled bitcoin-qt with statically linked Qt:

$ ldd src/qt/bitcoin-qt | grep -i qt
# empty output
$ src/qt/bitcoin-qt -regtest -printtoconsole
2020-08-12T11:25:36Z [main] Bitcoin Core version v0.20.99.0-7c8e2ecf0 (release build)
2020-08-12T11:25:36Z [main] Qt 5.9.8 (static), plugin=xcb (static)
2020-08-12T11:25:36Z [main] System: Linux Mint 20, x86_64-little_endian-lp64
2020-08-12T11:25:36Z [main] Screen: HDMI-2 1600x1200, pixel ratio=1.0
...

and a widget-based QFileDialog is still openning.

@hebasto
Copy link
Member Author

hebasto commented Jun 24, 2021

Here is another observation. A non-native QFileDialog requires ICU support, but it is disabled:

$(package)_config_opts += -no-icu

As a consequence, users experience Qt warnings every time they open a filesystem dialog:

2021-06-23T15:48:26Z GUI: Case insensitive sorting unsupported in the posix collation implementation
2021-06-23T15:48:26Z GUI: Numeric mode unsupported in the posix collation implementation

Just removing -no-icu is not an option as it introduces new dependencies and exported symbols.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Linux
Projects
None yet
Development

No branches or pull requests

4 participants