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

Luca Olivetti luca at wetron.es
Mon Dec 5 17:14:28 CET 2016


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


More information about the Lazarus mailing list