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

issue hebasto openend this issue on July 15, 2020
  1. hebasto commented at 9:21 am on July 15, 2020: member

    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:

    0$ ./src/qt/bitcoin-qt -printtoconsole
    12020-07-15T09:15:39Z [main] Bitcoin Core version v0.20.0 (release build)
    22020-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):

    0$ /home/hebasto/bitcoin-0.20.0/bin/bitcoin-qt -printtoconsole
    12020-07-15T09:07:04Z Bitcoin Core version v0.20.0 (release build)
    22020-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.

  2. hebasto added the label Bug on Jul 15, 2020
  3. hebasto commented at 9:28 am on July 15, 2020: member

    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:

  4. MarcoFalke commented at 9:44 am on July 15, 2020: contributor
    So why is the widget based dialog unable to detect any folders?
  5. hebasto commented at 9:47 am on July 15, 2020: member

    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.

  6. ryanofsky commented at 9:51 am on July 15, 2020: contributor
    Nice find!
  7. hebasto commented at 5:38 pm on July 16, 2020: member

    @MarcoFalke

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

    A: https://github.com/bitcoin/bitcoin/pull/19536

  8. hebasto commented at 6:14 pm on August 9, 2020: member

    UPDATE: such behavior observed on Linux only.

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

  9. fanquake commented at 5:51 am on August 10, 2020: member

    UPDATE: such behavior observed on Linux only.

    I thought this was fixed by https://github.com/bitcoin/bitcoin/pull/19536?

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

    Right, I see these are separate.

  10. hebasto commented at 4:56 pm on August 10, 2020: member
     0$ make -C depends
     1make: Entering directory '/home/hebasto/guix/GitHub/bitcoin/depends'
     2Extracting qt...
     3/home/hebasto/guix/GitHub/bitcoin/depends/sources/qtbase-opensource-src-5.9.8.tar.xz: OK
     4/home/hebasto/guix/GitHub/bitcoin/depends/sources/qttranslations-opensource-src-5.9.8.tar.xz: OK
     5/home/hebasto/guix/GitHub/bitcoin/depends/sources/qttools-opensource-src-5.9.8.tar.xz: OK
     6Preprocessing qt...
     7...
     8Configuring qt...
     9Creating qmake...
    10...
    11Done running configuration tests.
    12
    13Configure summary:
    14...
    15Qt Widgets:
    16  GTK+ ................................... no
    17  Styles ................................. Fusion Windows
    18...
    

    @theuni Could missed GTK+ support cause this bug?

  11. hebasto commented at 7:30 pm on August 11, 2020: member

    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.

  12. hebasto commented at 11:36 am on August 12, 2020: member

    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

    0Qt Widgets:
    1  GTK+ ................................... yes
    2  Styles ................................. Fusion Windows
    

    then compiled bitcoin-qt with statically linked Qt:

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

    and a widget-based QFileDialog is still openning.

  13. hebasto added the label Linux on Mar 5, 2021
  14. hebasto commented at 4:28 am on June 24, 2021: member

    Here is another observation. A non-native QFileDialog requires ICU support, but it is disabled: https://github.com/bitcoin-core/gui/blob/7317e14a44c6efc545e6fb9bcedee7174e93a8fa/depends/packages/qt.mk#L40

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

    02021-06-23T15:48:26Z GUI: Case insensitive sorting unsupported in the posix collation implementation
    12021-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.


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin-core/gui. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2024-10-23 00:20 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me