Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2016-12

Tools->Options segfaults with ancient gtk (GtkTreeView problem)

15 messages · 6 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Luca Olivetti

I just installed an old version of puppy linux (4.00) in a virtual machine to recreate a system I have to maintain (and, no, I cannot update it, the video card in the production system only works with puppy linux and this specific version).

This version of puppy linux has gtk 2.12.1

I installed fpc 2.6.4 in it and compiled lazarus 1.6.2. Everything works but clicking on Tools->Options the ide segfaults. I cannot use the debugger, but the segfault happens in line 207 of lcl/interfaces/gtk2/gtk2listviewtreemodel.pas

function TLCLListViewModel.get_iter(iter: PGtkTreeIter; path:
PGtkTreePath): gboolean; cdecl;
var
   Index: PtrUInt;
begin
   Result := False;
   Index := gtk_tree_path_get_indices(path)[0]; <--- here
   if Index < ListView.Items.Count then
   begin
     iter^.user_data:= {%H-}Pointer(Index);
     Exit(True);
   end;
end;

and it appears it is triggered by line 1517 of
lcl/interfaces/gtk2/gtk2wscustomlistview.inc

         lisFocused:
         begin
           //gtk2 iter has no focus??
           Path := gtk_tree_path_new_from_string(PChar(IntToStr(AIndex)));
           if GTK_IS_TREE_VIEW(MainView) then
           begin
             if AIsSet then
               gtk_tree_view_set_cursor(PGtkTreeView(MainView), Path,
nil, False)
             else
             begin
               if (gtk_major_version = 2) and (gtk_minor_version < 14) then
                 gtk_tree_view_set_cursor(PGtkTreeView(MainView), nil,
nil, False) <--- here
               else
                 gtk_tree_view_set_cursor(PGtkTreeView(MainView), Path,
nil, False);
             end;
           end
           else
           if GTK_IS_ICON_VIEW(MainView) then
             gtk_icon_view_set_cursor(PGtkIconView(MainView), Path, nil,
False);
           gtk_tree_path_free(Path);
         end;

I changed the call to look like the one for gtk >= 2.14 (i.e, Path instead of nil) and now I can open the options dialog. I really don't know gtk2, but maybe the differentiation is needed for an earlier version of gtk and not 2.14?

Bye

Luca Olivetti Wetron Automation Technology http://www.wetron.es/ Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007

Reply by email

zeljko
to Luca Olivetti
Show quoted text 6 lines
I changed the call to look like the one for gtk >= 2.14 (i.e, Path instead of nil) and now I can open the options dialog. I really don't know gtk2, but maybe the differentiation is needed for an earlier version of gtk and not 2.14?

Maybe < 2.12 should be there

zeljko

Reply by email

Luca Olivetti
to zeljko

El 05/12/16 a les 17:39, zeljko ha escrit:

Show quoted text 8 lines
> > > I changed the call to look like the one for gtk >= 2.14 (i.e, Path > instead of nil) and now I can open the options dialog. > I really don't know gtk2, but maybe the differentiation is needed for an > earlier version of gtk and not 2.14? Maybe < 2.12 should be there

I wouldn't know, as I said I know nothing about gtk, but the available documentation doesn't mention if and when the api was changed:

https://developer.gnome.org/gtk2/stable/GtkTreeView.html#gtk-tree-view-set-cursor

Bye

Luca Olivetti Wetron Automation Technology http://www.wetron.es/ Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007

Reply by email

Luca Olivetti
to Luca Olivetti

El 05/12/16 a les 22:26, Luca Olivetti via Lazarus ha escrit:

Show quoted text 15 lines
El 05/12/16 a les 17:39, zeljko ha escrit: >> >> >> I changed the call to look like the one for gtk >= 2.14 (i.e, Path >> instead of nil) and now I can open the options dialog. >> I really don't know gtk2, but maybe the differentiation is needed for an >> earlier version of gtk and not 2.14? > > Maybe < 2.12 should be there I wouldn't know, as I said I know nothing about gtk, but the available documentation doesn't mention if and when the api was changed: https://developer.gnome.org/gtk2/stable/GtkTreeView.html#gtk-tree-view-set-cursor

I checked gtktreeview.c starting from gtk 2.0
https://git.gnome.org/browse/gtk+/tree/gtk/gtktreeview.c?h=gtk-2-0

until gtk 2.24

https://git.gnome.org/browse/gtk+/tree/gtk/gtktreeview.c?h=gtk-2-0

and the implementation of gtk_tree_view_set_cell basically didn't change (apart form the introduction of gtk_tree_view_set_cursor_on_cell in gtk 2.2).

At the beginning of the function there is

g_return_if_fail (path != NULL);

so I guess path should never be null and the LCL implementation works just because nobody else is using an older gtk.

Maybe the function could be simplified to

         lisFocused:
         begin
           //gtk2 iter has no focus??
           Path := gtk_tree_path_new_from_string(PChar(IntToStr(AIndex)));
           if GTK_IS_TREE_VIEW(MainView) then
             gtk_tree_view_set_cursor(PGtkTreeView(MainView), Path, nil,
False)
           else
           if GTK_IS_ICON_VIEW(MainView) then
             gtk_icon_view_set_cursor(PGtkIconView(MainView), Path, nil,
False);
           gtk_tree_path_free(Path);
         end;

of course I may be guessing wrong.

Should I file a bug report?

Bye

Luca Olivetti Wetron Automation Technology http://www.wetron.es/ Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007

Reply by email

Luca Olivetti
to Luca Olivetti

El 07/12/16 a les 11:28, Luca Olivetti via Lazarus ha escrit:

Show quoted text 26 lines
El 05/12/16 a les 22:26, Luca Olivetti via Lazarus ha escrit: > El 05/12/16 a les 17:39, zeljko ha escrit: >>> >>> >>> I changed the call to look like the one for gtk >= 2.14 (i.e, Path >>> instead of nil) and now I can open the options dialog. >>> I really don't know gtk2, but maybe the differentiation is needed >>> for an >>> earlier version of gtk and not 2.14? >> >> Maybe < 2.12 should be there > > I wouldn't know, as I said I know nothing about gtk, but the available > documentation doesn't mention if and when the api was changed: > > https://developer.gnome.org/gtk2/stable/GtkTreeView.html#gtk-tree-view-set-cursor > > I checked gtktreeview.c starting from gtk 2.0 https://git.gnome.org/browse/gtk+/tree/gtk/gtktreeview.c?h=gtk-2-0 until gtk 2.24 https://git.gnome.org/browse/gtk+/tree/gtk/gtktreeview.c?h=gtk-2-0

Oops, the link here should have been
https://git.gnome.org/browse/gtk+/tree/gtk/gtktreeview.c?h=gtk-2-24

Show quoted text 35 lines
and the implementation of gtk_tree_view_set_cell basically didn't change (apart form the introduction of gtk_tree_view_set_cursor_on_cell in gtk 2.2). At the beginning of the function there is g_return_if_fail (path != NULL); so I guess path should never be null and the LCL implementation works just because nobody else is using an older gtk. Maybe the function could be simplified to lisFocused: begin //gtk2 iter has no focus?? Path := gtk_tree_path_new_from_string(PChar(IntToStr(AIndex))); if GTK_IS_TREE_VIEW(MainView) then gtk_tree_view_set_cursor(PGtkTreeView(MainView), Path, nil, False) else if GTK_IS_ICON_VIEW(MainView) then gtk_icon_view_set_cursor(PGtkIconView(MainView), Path, nil, False); gtk_tree_path_free(Path); end; of course I may be guessing wrong. Should I file a bug report? Bye
Luca Olivetti Wetron Automation Technology http://www.wetron.es/ Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007

Reply by email

Juha Manninen
to Luca Olivetti: El 05/12/16 a les 22:26, Luca Olivetti via Lazarus ha escrit: I checked gtktreeview.c…
Luca Olivetti wrote 15 lines
Maybe the function could be simplified to lisFocused: begin //gtk2 iter has no focus?? Path := gtk_tree_path_new_from_string(PChar(IntToStr(AIndex))); if GTK_IS_TREE_VIEW(MainView) then gtk_tree_view_set_cursor(PGtkTreeView(MainView), Path, nil, False) else if GTK_IS_ICON_VIEW(MainView) then gtk_icon_view_set_cursor(PGtkIconView(MainView), Path, nil, False); gtk_tree_path_free(Path); end;

Yes, I believe so, too. LCL-GTK2 is full of historical remains. Many of them come from GTK1 times, the sources were just copied. This piece of code however was not from there.
According to documentation the API has not changed. Why should the code be different?

Should I file a bug report?

No need. I changed it in r53590. Please test.
If somebody finds an old GTK version where it does NOT work then we will scratch our heads more, but I doubt it.

Juha

Reply by email

Luca Olivetti
to Juha Manninen

El 07/12/16 a les 18:57, Juha Manninen via Lazarus ha escrit:

No need. I changed it in r53590. Please test. If somebody finds an old GTK version where it does NOT work then we will scratch our heads more, but I doubt it.

Apart from the fact that I had to comment out a call to gdk_window_restack in lcl/interfaces/gtk2/gtk2widgetset.inc (not available in this old gtk) and to install fpc 3.0.0 (trunk is not compilable by 2.6.4) it works.
Please remember to merge it to fixes_1_6

Thank you.

Luca Olivetti Wetron Automation Technology http://www.wetron.es/ Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007

Reply by email

Juha Manninen
to Luca Olivetti
Luca Olivetti wrote
Apart from the fact that I had to comment out a call to gdk_window_restack in lcl/interfaces/gtk2/gtk2widgetset.inc (not available in this old gtk)

Can you please create a patch for that one. You are the best person to test it. You can attach a patch here if you like.

and to install fpc 3.0.0 (trunk is not compilable by 2.6.4) it works.

Ondrej fixed that in r53603. Please test.

Please remember to merge it to fixes_1_6

Ok, after some testing period. Maybe we can include your new patch there, too.

Juha

Reply by email

Luca Olivetti
to Juha Manninen

El 08/12/16 a les 19:20, Juha Manninen via Lazarus ha escrit:

Show quoted text 7 lines
On Wed, Dec 7, 2016 at 9:35 PM, Luca Olivetti via Lazarus wrote: > Apart from the fact that I had to comment out a call to gdk_window_restack > in lcl/interfaces/gtk2/gtk2widgetset.inc (not available in this old gtk) Can you please create a patch for that one. You are the best person to test it. You can attach a patch here if you like.

No, I just commented it out in order to test the patch in this old machine, it surely affects the functionality of the procedure where it is if removed.

Bye

Luca Olivetti Wetron Automation Technology http://www.wetron.es/ Tel. +34 93 5883004 (Ext.3010) Fax +34 93 5883007

Reply by email

Juha Manninen
to Luca Olivetti
Luca Olivetti wrote
No, I just commented it out in order to test the patch in this old machine, it surely affects the functionality of the procedure where it is if removed.

It must be inside an IFDEF. I don't have enough knowledge (nor motivation) to study the old GTK versions.
If somebody comes up with a patch, I can apply it.

Juha

Reply by email

Juha Manninen
to Alexey
Alexey wrote
Juha, what do you think about this big patch. http://mantis.freepascal.org/view.php?id=30992

I was hoping Michl and Bart take care of it.
Your patch may be OK but must concentrate on other things now. Alexey, you really must make some substantial patches for a change. Take a bug report that nobody could fix yet, dive to the code, debug, fix it and make a patch.
Your patches often tweak code that was just committed by somebody and may be still under contruction. Not good. Tweaking is for developers who have earned their commit rights by doing substantial stuff.

There are now 1767 open issues for Lazarus project. http://bugs.freepascal.org/view_all_bug_page.php
Pick the one that bothers you most and fix it. I will apply your patch if it works.

Juha

Reply by email

Michael W. Vogel
to Juha Manninen
Juha Manninen wrote 7 lines
On Thu, Dec 8, 2016 at 11:11 PM, Alexey via Lazarus wrote: > Juha, what do you think about this big patch. > http://mantis.freepascal.org/view.php?id=30992 I was hoping Michl and Bart take care of it. ... I will apply your patch if it works.

It breaks some locals for german keys (other languages, I've not tested till now). I'll have a look at it and report. But it will take a while - sorry.

Kind regards

Michl

Reply by email

Bart
to Michael W. Vogel
Michael W. Vogel wrote
It breaks some locals for german keys (other languages, I've not tested till now). I'll have a look at it and report. But it will take a while - sorry.

As Juha pointed out, this is low priority, so no need to say

Reply by email

Alexey
to Juha Manninen: On Thu, Dec 8, 2016 at 11:11 PM, Alexey via Lazarus I was hoping Michl and Bart take care…
Juha Manninen wrote
Pick the one that bothers you most and fix it. I will apply your patch if it works.

I see what you mean, making substancial. Why I dont do it 80% of time, is because I dont see these bugs. In my app CudaText. If i see these bugs, i try to fix some: e.g. OSX LineTo was very bad**s bug for my app... and etc...

I'm focused on my app :)
Ok will see some other bugs (can't promise)

Regards, Alex

Reply by email