Recent

Author Topic: 30sec Freeze per click in GTK3 file dialog under QT5 widgetset  (Read 11599 times)

AlexTP

  • Hero Member
  • *****
  • Posts: 2384
    • UVviewsoft
30sec Freeze per click in GTK3 file dialog under QT5 widgetset
« on: December 14, 2022, 03:49:49 pm »
Please see, Zeljko:
https://github.com/Alexey-T/CudaText/issues/4674
Can you do something here?

zeljko

  • Hero Member
  • *****
  • Posts: 1594
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: 30sec Freeze per click in GTK3 file dialog under QT5 widgetset
« Reply #1 on: December 14, 2022, 05:20:05 pm »
No, sorry, I cannot follow / debug each theme for qt. It is known (from Qt bugtracker) that there are some issues with gtk2/3 themes since Qt uses gtk libs to paint controls and also gtk native dialogs. I've spotted that it might have something with our clipboard implementation (qtobjects.pas) since gtk dialog triggers enormous number of clipboard selection events when shown and maybe that could be the reason.
Open dialog does not have such problem, only saveDialog (if you provided filename). Try saveDialog without provided filename and see if it lags also and let me know.

AlexTP

  • Hero Member
  • *****
  • Posts: 2384
    • UVviewsoft
Re: 30sec Freeze per click in GTK3 file dialog under QT5 widgetset
« Reply #2 on: December 14, 2022, 06:05:34 pm »
I told the user to test save-dialog without initial filename. He confirmed: click on filenames freezes there (not in open-dialog).
What can we do?

zeljko

  • Hero Member
  • *****
  • Posts: 1594
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: 30sec Freeze per click in GTK3 file dialog under QT5 widgetset
« Reply #3 on: December 14, 2022, 08:30:34 pm »
Debug our lclqt (4,5,6) clipboard selection implementation and create patch. qtobjects.pas
procedure TQtClipboard.signalSelectionChanged; cdecl;
function TQtClipboard.EventFilter(Sender: QObjectH; Event: QEventH): Boolean; cdecl;
That's what I remember that was bottleneck with gtk theme and gtk dialogs, but didn't have time to investigate and fix it.
Same routines are used in qt/qtobjects.pas , qt5/qtobjects.pas and qt6/qtobjects.pas.

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: 30sec Freeze per click in GTK3 file dialog under QT5 widgetset
« Reply #4 on: February 12, 2023, 07:10:04 am »
Might help other users if we spell out what is, and is not, a problem.

  • Debian Bullseye, Bookworm, Ubuntu 22.04 (Qt5 5.15)  not a problem.
  • Ubuntu 20.04 (Qt5 5.12) with Mate or KDE Desktop is a problem with some dialogs (SaveAs, Font), even if no Qt5 theme is set.


I don't have any VMs at present with a Qt5 between 5.12 and 5.15, maybe everyone except the long termers have moved on and thats a really good thing.

So, a summary, probably best to avoid Qt5 if the underlying Qt5 is less that 5:15, thats especially so if you a Qt5 theme of gtk3. But the native Qt theme looks heaps better anyway !

Davo

« Last Edit: February 12, 2023, 08:50:50 am by dbannon »
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

AlexTP

  • Hero Member
  • *****
  • Posts: 2384
    • UVviewsoft
Re: 30sec Freeze per click in GTK3 file dialog under QT5 widgetset
« Reply #5 on: February 12, 2023, 08:05:26 am »
2 PCs with Ubuntu.
1) Ubuntu 20.04 has a problem.
2) Ubuntu 22.04 with Qt5 5.15 - no problem (even if I set GTK3 dialogs in qt5ct).

dbannon

  • Hero Member
  • *****
  • Posts: 2786
    • tomboy-ng, a rewrite of the classic Tomboy
Re: 30sec Freeze per click in GTK3 file dialog under QT5 widgetset
« Reply #6 on: February 12, 2023, 08:54:40 am »
Yes Alex, its U20.04 thats the problem, Debian Bullseye has a later Qt5 so, no issues.

Sadly, U20.04 still has some time to go !  I tell my users to use GTK2 version on U20.04, even if they are using Plasma/KDE !

Davo
Lazarus 3, Linux (and reluctantly Win10/11, OSX Monterey)
My Project - https://github.com/tomboy-notes/tomboy-ng and my github - https://github.com/davidbannon

rca

  • Jr. Member
  • **
  • Posts: 67
Re: 30sec Freeze per click in GTK3 file dialog under QT5 widgetset
« Reply #7 on: March 02, 2023, 04:28:55 pm »
Try disabling QtUseNativeEventLoop in lcl/interfaces/qt5/qtdefines.inc

Code: Pascal  [Select][+][-]
  1. {.$DEFINE QtUseNativeEventLoop}

Go back to Build Lazarus and recompile the applications.

AlexTP

  • Hero Member
  • *****
  • Posts: 2384
    • UVviewsoft
Re: 30sec Freeze per click in GTK3 file dialog under QT5 widgetset
« Reply #8 on: March 02, 2023, 05:16:12 pm »
@rca, what is the 'price' of such LCL change? LCL breaks in other places?

rca

  • Jr. Member
  • **
  • Posts: 67
Re: 30sec Freeze per click in GTK3 file dialog under QT5 widgetset
« Reply #9 on: March 02, 2023, 05:25:20 pm »
@rca, what is the 'price' of such LCL change? LCL breaks in other places?

I have already recompiled several applications that I have, and so far everything is OK.

rca

  • Jr. Member
  • **
  • Posts: 67
Re: 30sec Freeze per click in GTK3 file dialog under QT5 widgetset
« Reply #10 on: March 06, 2023, 05:34:48 pm »
In the lazarus_2_2_4 or lazarus_2_2_6 (stable) branch, in lcl/interfaces/qt5/qtdefines.inc, QtUseNativeEventLoop is only enabled for MacOSX cocoa 64.

Code: Pascal  [Select][+][-]
  1.   {$IF DEFINED(LINUX) or DEFINED(FREEBSD) or DEFINED(NETBSD)}
  2.     {$DEFINE HASX11}
  3.   {$ENDIF}
  4.  
  5.   {Qt must use native event loop at least under MacOSX cocoa 64}
  6.   {$IFNDEF HASX11}
  7.   {$DEFINE QtUseNativeEventLoop}
  8.   {$ENDIF}

I see that the change was made to the main (trunk) branch about three months ago:
"Qt5: use native event loop on all platforms."

https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/df5754c7f4ff8a16b62eaadb0053b9a74f8dc6fa

Code: Pascal  [Select][+][-]
  1.   {Qt must use native event loop at least under MacOSX cocoa 64}
  2.   {.$IFNDEF HASX11}
  3.   {$DEFINE QtUseNativeEventLoop}
  4.   {.$ENDIF}

By leaving QtUseNativeEventLoop enabled for all platforms, in my case I have linux, tested with Fedora 37, Debian 12 the problem appears when opening the dialogs both in Lazarus IDE and in the created applications.

zeljko

  • Hero Member
  • *****
  • Posts: 1594
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: 30sec Freeze per click in GTK3 file dialog under QT5 widgetset
« Reply #11 on: March 14, 2023, 05:55:38 pm »
That can highly rely on current Qt theme. I don't spot any slowness with dialogs here (Fedora 35, KDE, so Breeze is default style).

rca

  • Jr. Member
  • **
  • Posts: 67
Re: 30sec Freeze per click in GTK3 file dialog under QT5 widgetset
« Reply #12 on: April 11, 2023, 02:26:13 am »
This behavior only affects save dialogs that are native to both Qt5 and Qt6:

Parsing the file lazarus/lcl/interfaces/qt5/qtwsdialogs.pp

Inside TQtWSOpenDialog.CreateHandle
Code: Pascal  [Select][+][-]
  1. class function TQtWSOpenDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
  2.  
  3.     {$ifndef QT_NATIVE_DIALOGS}
  4.     QFileDialog_setOption(QFileDialogH(FileDialog.Widget),
  5.       QFileDialogDontUseNativeDialog, True);
  6.     FileDialog.initializePreview(TPreviewFileDialog(ACommonDialog).PreviewFileControl);
  7.     {$endif}

But inside TQtWSFileDialog.CreateHandle
Code: Pascal  [Select][+][-]
  1. class function TQtWSFileDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;
  2.  
  3.   QFileDialog_setOption(QFileDialogH(FileDialog.Widget),
  4.     QFileDialogDontUseNativeDialog, False);

I changed from
Code: Pascal  [Select][+][-]
  1.   QFileDialog_setOption(QFileDialogH(FileDialog.Widget),
  2.     QFileDialogDontUseNativeDialog, False);

for this
Code: Pascal  [Select][+][-]
  1.   {$ifndef QT_NATIVE_DIALOGS}
  2.   QFileDialog_setOption(QFileDialogH(FileDialog.Widget),
  3.     QFileDialogDontUseNativeDialog, True);
  4.   {$endif}

Rebuild Lazarus and recompile your applications.
« Last Edit: April 11, 2023, 07:49:50 pm by rca »

AlexTP

  • Hero Member
  • *****
  • Posts: 2384
    • UVviewsoft
Re: 30sec Freeze per click in GTK3 file dialog under QT5 widgetset
« Reply #13 on: April 11, 2023, 09:03:32 am »
Please apply this patch to the Git.

rca

  • Jr. Member
  • **
  • Posts: 67

 

TinyPortal © 2005-2018