[fpc-pascal] FPC and GTK2: problems with GTKCombo
Jan Je/lowicki
Jasj at OZI.AR.WROC.PL
Fri Apr 22 15:13:25 CEST 2005
Hello all,
Today I have localised a problem with GtkCombo; there is a minimal
program that could reproduce crash of GtkCombo in W32 environment.
I cannot see any bug, there are just standard instructions;
maybe I am wrong? or rather the bug is in the GTK binary for Windows?
or even in FPC bind?
Tested with GTK+2.4,14, 2.4.7, 2.2.4, 2.0.7 binaries
in win2000 and wine20040914 with w2k emulation.
Sory for yesterday's sample. It wasn't too hard to clear it.
Here is the right code -- at least possible to analysis for anyone:
program samp;
uses
glib2, gdk2, gtk2;
const
n = 5;
var
items: array[1..n] of pchar;
const
current_item: integer = 0;
var
e: pGTKWidget;
function sample_stop(w: pGTKWidget; data: pointer): longbool; cdecl;
begin
writeln('inside: ---------------');
writeln('postselected: "', gtk_entry_get_text(pGTKEntry(e)), '"');
gtk_widget_destroy(data);
gtk_main_quit();
result := false;
end;
var
d: pGTKWidget;
h: pGTKWidget;
b: pGTKWidget;
c: pGTKWidget;
g: pGList;
l: pGTKWidget;
var
i: integer;
begin
gtk_init(@argc, @argv);
items[1] := 'field 1'#0;
items[2] := 'field 2'#0;
items[3] := 'field 3'#0;
items[4] := 'field 4'#0;
items[5] := 'last field'#0;
current_item := 3;
writeln('starting: --------------');
d := gtk_dialog_new;
gtk_window_set_title(pGTKWindow(d), 'A sample dialog');
h := pGTKDialog(d)^.vbox;
l := gtk_label_new('A sample Combo list');
gtk_widget_show(l);
gtk_box_pack_start(pGTKBox(h), l, false, false, 0);
c := gtk_combo_new();
e := pGTKCombo(c)^.entry;
writeln('is Entry nil? ', e=nil);
g := nil;
for i := 1 to n do
g := g_list_append(g, items[i]);
gtk_combo_set_popdown_strings(pgtkcombo(c), g);
gtk_entry_set_text(pgtkentry(e), items[current_item]);
writeln('before: --------------');
writeln('preselected: "', gtk_entry_get_text(pGTKEntry(e)), '"');
gtk_combo_set_value_in_list(pgtkcombo(c), true, false);
gtk_entry_set_editable(pgtkentry(e), false);
gtk_box_pack_start(pGTKBox(h), c, false, false, 0);
gtk_widget_show(c);
b := gtk_button_new_with_label(' OK ');
gtk_signal_connect(pGTKObject(b), 'clicked', @sample_stop, d);
gtk_box_pack_start(pGTKBox(h), b, false, false, 0);
gtk_widget_show(b);
gtk_widget_show(d);
gtk_main();
writeln('thanks ---------------');
end.
(* runtime log in linux:
[jasj at hydra test]$ ../../bin/gtk/samp
starting: --------------
is Entry nil? FALSE
before: --------------
preselected: "field 3"
inside: ---------------
postselected: "last field"
thanks ---------------
[jasj at hydra test]$
*)
(* runtime log in wine -- w2k gives the same
F:\devel\src\test>../../bin/gtkw/samp.exe
starting: --------------
is Entry nil? TRUE
(samp.exe): Gtk-CRITICAL **: file gtkentry.c: line 3642
(gtk_entry_set_text): assertion `GTK_IS_ENTRY (entry)' failed
before: --------------
(samp.exe): Gtk-CRITICAL **: file gtkentry.c: line 3797
(gtk_entry_get_text): assertion `GTK_IS_ENTRY (entry)' failed
preselected: ""
(samp.exe): Gtk-CRITICAL **: file gtkentry.c: line 3777
(gtk_entry_set_editable): assertion `GTK_IS_ENTRY (entry)' failed
inside: ---------------
(samp.exe): Gtk-CRITICAL **: file gtkentry.c: line 3797
(gtk_entry_get_text): assertion `GTK_IS_ENTRY (entry)' failed
postselected: ""
thanks ---------------
F:\devel\src\test>
*)
With regards,
Jan Jelowicki
jasj at ozi.ar.wroc.pl
-------------------------------------------------------------------
Wroclaw University of Agriculture Akademia Rolnicza we Wroclawiu
Department of Mathematics Katedra Matematyki
-------------------------------------------------------------------
More information about the fpc-pascal
mailing list