- At least one script (md_burst) makes trouble if you try to load it. CDHK does not respond anymore and the scriptload menu looks
strange. If find out the it has something to do with the name tag in the script. CHDK gets very busy during the try to draw the script title into the scriptmenu. Current workarround to get it run, is to change the title in the script:
@title Fast MD Burst/Review + Mask 080411
to
@title Fast MD Burst
I find the root cause for the "crash" here, it looks like a bug in the CHDK core gui_menu.c function:
In the the case "case MENUITEM_SEPARATOR:" the xx coordinate calculation is done in that way:
j = rbf_str_width(lang_str(curr_menu->menu[imenu].text));
xx+=(w-j-len_space*2)>>1;
..
draw_line(x+len_space, yy+rbf_font_height()/2, xx-1, yy+rbf_font_height()/2, cl);
draw_filled_rect(x+len_space, yy+rbf_font_height()/2+1, xx-1, yy+rbf_font_height()-1, MAKE_COLOR(cl>>8, cl>>8));
On the G11 (with a screen_width of 320 Pixels, and not with the "usual" 360), this calculation results with the md_burst title to a really big negative xx coordinate:
unsigned int w=260;
int j=272;
int lenspace=8;
int xx=30;
xx+=(w-j-len_space*2)>>1;
Result is: xx=-2147483632
So the following draw functions start to draw a really, really, long line over the hole RAM area, and crashes the camera.
I can workarround/bugfix this by adding a cast in that way:
xx+=((int)w-j-len_space*2)>>1;
or so:
xx+=(int)(w-j-len_space*2)>>1;
Both fixes the problem with the "unsigned int w", which seems to be the cause for negative xx result.
But the drawn result looks not so good, because the width is now correct (check attached photo).
Another way to fix the crash is to change the calculation of w in void gui_menu_init(CMenu *menu_ptr):
Original code: w = screen_width-30-30;
G11 fix version: w= screen_width-10-10;
This fixes the crash, and also the menu looks good on the G11. But why are here used "fixed" magics (-30) anyway?
So i think the calculation routines in gui_osd.c needs some updates to fix the problem with cameras which
have a screen_width smaller then 360 (which are working fine with the above "unfixed" calculation routine).
Should i open a new issue in the CHDK mantis bugtracking system for that?