Recent

Author Topic: Regarding Linux GTK3 T[Xxx]Dialog component issues  (Read 1570 times)

energy

  • New Member
  • *
  • Posts: 14
  • Go Energy
    • golang energy gui
Regarding Linux GTK3 T[Xxx]Dialog component issues
« on: May 28, 2024, 01:56:56 pm »
Hello,

I am the lead developer of the Energy framework, which is a full set of API libraries for Golang based on the Laz LCL component library's encapsulation.

At present, I have encountered some issues while encapsulating the components.

Under Linux GTK3, because I need the functionality of Gtk3, which I know is still in the beta-testing stage and not yet perfected.

Currently under Gtk3, when encapsulating Dialog-related components, I found that they do not work normally. These include components (TSelectDirectoryDialog, TOpenDialog, TSaveDialog), and there may be others.
The problem occurs when executing the Execute function, and during the Debug tracking, an error appeared at "TGtk3WSOpenDialog.CreateHandle(const ACommonDialog: TCommonDialog): THandle;".
It occurred during the call to CreateOpenDialogHistory and CreateOpenDialogFilter.
Solution: I found that these functions used "virtual" modifier. After removing the "virtual" modifier, it can run normally.
I am not clear why the removal of the "virtual" modifier allows it to run normally. I am not sufficiently knowledgeable in this area.


Here is the code snippet:
Quote
  TGtk3WSOpenDialog = class(TWSOpenDialog)
  protected
    class function CreateOpenDialogFilter(OpenDialog: TOpenDialog; Chooser: PGtkFileChooser): string;// virtual;
    class procedure CreateOpenDialogHistory(OpenDialog: TOpenDialog; SelWidget: PGtkWidget);// virtual;
    class procedure CreatePreviewDialogControl(PreviewDialog: TPreviewFileDialog; Chooser: PGtkFileChooser);// virtual;
  published
    class function CreateHandle(const ACommonDialog: TCommonDialog): THandle; override;
  end;


Lazarus: 3.2
System: ubuntu 22
Energy Open source address: https://github.com/energye/energy
« Last Edit: May 28, 2024, 02:01:57 pm by energy »
Maintain Golang development project: Go CEF  Go WV(Webview2, Webkit2)  Go LCL

jamie

  • Hero Member
  • *****
  • Posts: 6811
Re: Regarding Linux GTK3 T[Xxx]Dialog component issues
« Reply #1 on: May 28, 2024, 02:17:32 pm »
There must be a disruption in the force!

I didn't know a CLASS function could be virtual? also, I am trying to imagine how that would work?

I just did a compilation of a Class function returning a Boolean and it compiles and runs.

Strange things.

The only true wisdom is knowing you know nothing

energy

  • New Member
  • *
  • Posts: 14
  • Go Energy
    • golang energy gui
Re: Regarding Linux GTK3 T[Xxx]Dialog component issues
« Reply #2 on: May 28, 2024, 02:32:18 pm »
code file: lazarus/3.2.0/lcl/interfaces/gtk3/gtk3wsdialogs.pp

method: TGtk3WSOpenDialog.CreateHandle

Here is the place where the function call occurs; errors are reported at both spots.

Quote
  // History List - a frame with an option menu
  CreateOpenDialogHistory(OpenDialog, Dlg.Widget);

  // Filter
  // InternalCreateOpenDialogFilter
  CreateOpenDialogFilter(OpenDialog, Chooser);

The error occurs during runtime when invoking the function. Removing the "virtual" keyword allows the function to run normally.
« Last Edit: May 28, 2024, 02:33:56 pm by energy »
Maintain Golang development project: Go CEF  Go WV(Webview2, Webkit2)  Go LCL

jamie

  • Hero Member
  • *****
  • Posts: 6811
Re: Regarding Linux GTK3 T[Xxx]Dialog component issues
« Reply #3 on: May 28, 2024, 02:51:32 pm »
This is strange code however, it seems that class needs to be created first, even though all you see is class methods there.

The base Class however, I believe requires construction.

 The Dialog Handle in the windows widget is a class that needs to be constructed so it's my guess that maybe you are dealing with that?

The only true wisdom is knowing you know nothing

energy

  • New Member
  • *
  • Posts: 14
  • Go Energy
    • golang energy gui
Re: Regarding Linux GTK3 T[Xxx]Dialog component issues
« Reply #4 on: May 28, 2024, 03:02:06 pm »
I directly dragged the TSelectDirectoryDialog component through the Laz IDE, and then triggered its "Execute" method using a TButton's Click event.

Quote
procedure TForm1.SelectDirDialogBtnClick(Sender: TObject);
begin
  SelectDirectoryDialog1.InitialDir := '/';
  SelectDirectoryDialog1.Execute;
end;

This is a very simple feature; just drag TSelectDirectoryDialog and a TButton onto the form, and trigger it inside the TButton. No additional operations are needed.
« Last Edit: May 28, 2024, 03:05:08 pm by energy »
Maintain Golang development project: Go CEF  Go WV(Webview2, Webkit2)  Go LCL

AlexTP

  • Hero Member
  • *****
  • Posts: 2537
    • UVviewsoft
Re: Regarding Linux GTK3 T[Xxx]Dialog component issues
« Reply #5 on: May 28, 2024, 03:05:10 pm »
Create the smallest example, which shows the problem (error at runtime). It must be runtime error, not compile error. So you can post the bugreport with example.

energy

  • New Member
  • *
  • Posts: 14
  • Go Energy
    • golang energy gui
Re: Regarding Linux GTK3 T[Xxx]Dialog component issues
« Reply #6 on: May 28, 2024, 03:18:44 pm »
The attachment is an example program for Ubuntu 22, Lazarus 3.2.
Note: "LCLWidgetType:=gtk3"

« Last Edit: May 29, 2024, 01:38:17 am by energy »
Maintain Golang development project: Go CEF  Go WV(Webview2, Webkit2)  Go LCL

energy

  • New Member
  • *
  • Posts: 14
  • Go Energy
    • golang energy gui
Re: Regarding Linux GTK3 T[Xxx]Dialog component issues
« Reply #7 on: May 28, 2024, 03:35:20 pm »
Attachments are GIF records of operations
Maintain Golang development project: Go CEF  Go WV(Webview2, Webkit2)  Go LCL

energy

  • New Member
  • *
  • Posts: 14
  • Go Energy
    • golang energy gui
Re: Regarding Linux GTK3 T[Xxx]Dialog component issues
« Reply #8 on: May 28, 2024, 03:41:23 pm »

Dialog_success.gif is the removed 'virtual'
Maintain Golang development project: Go CEF  Go WV(Webview2, Webkit2)  Go LCL

AlexTP

  • Hero Member
  • *****
  • Posts: 2537
    • UVviewsoft
Re: Regarding Linux GTK3 T[Xxx]Dialog component issues
« Reply #9 on: May 28, 2024, 04:27:22 pm »
You have Access Violation so I guess it is a plain bug of Lazarus. I think you can post the bug report to GitLab.

But, delete 'lib' dir from your zip.

jamie

  • Hero Member
  • *****
  • Posts: 6811
Re: Regarding Linux GTK3 T[Xxx]Dialog component issues
« Reply #10 on: May 28, 2024, 04:35:24 pm »
if you don't use forms, don't you need to use the "Interfaces" unit somewhere in your code to get the full widget initiated ?
The only true wisdom is knowing you know nothing

energy

  • New Member
  • *
  • Posts: 14
  • Go Energy
    • golang energy gui
Re: Regarding Linux GTK3 T[Xxx]Dialog component issues
« Reply #11 on: May 29, 2024, 02:13:56 am »
OK
delete lib dir
Send report to GitLab
Maintain Golang development project: Go CEF  Go WV(Webview2, Webkit2)  Go LCL

 

TinyPortal © 2005-2018