bug in gs

Ulf Wiger (ÄL2/EAB) ulf.wiger@REDACTED
Mon Sep 22 17:20:21 CEST 2003

I have the following rather obscure code using gs:

cols(_) ->

rows(_) ->
    lists:duplicate(7, {fixed,40}).

widgets(_) ->
    window:buttons([{but_ok,"Ok"},{but_cancel,"Cancel"}], 1) ++
        window:entries([{e_athlete_id, "Id"},
			      {e_athlete_number, "Number"},
                        {e_athlete_name, "Name"},
                        {e_athlete_born, "Born"},
                        {e_athlete_gender, "Gender"},
			      {e_athlete_club, "Club"},
			      {e_athlete_info, "Info"}], 2).

entries([{Name, Text}|Es], Row) ->
    [{label, [{label,{text,Text}}, {pack_xy,{1,Row}}]},
     {entry, Name, [{pack_xy, {{2,4},Row}}]} | entries(Es, Row+1)];
entries([], _) ->

The bug in the above code is that it declares 7 entries, each on a
row + 1 button row, but (in rows/1) only 7 packer rows. 
This should not work, of course, but the error message (below) could
be a bit more user-friendly:

=ERROR REPORT==== 22-Sep-2003::17:05:29 ===
Error in process <0.263.0> with exit value: {function_clause,[{gstk_frame,find_pos,[8,8,8,150,0,[]]},{gstk_frame,pack_child,5},{gstk_frame,pack_children2,5},{gstk_frame,option,5},{gstk_generic,out_opts,8},{gstk_generic,make_command,7},{gstk_generic,mk_cmd_and_exec,... 

I suspect the logic in gstk_generic:gen_pack_xy/8 could be fixed to 
perform a sanity check and giving a better error description, but 
I'm too lazy to try to do it myself.


More information about the erlang-questions mailing list