[Tuxracer-checkins] CVS: tuxracer/src button.c,1.2,1.3 listbox.c,1.3,1.4 ssbutton.c,1.2,1.3 textarea
Status: Beta
Brought to you by:
jfpatry
From: Jasmin P. <jf...@us...> - 2000-09-25 23:47:36
|
Update of /cvsroot/tuxracer/tuxracer/src In directory slayer.i.sourceforge.net:/tmp/cvs-serv11111 Modified Files: button.c listbox.c ssbutton.c textarea.c Log Message: Added lots of debugging assertions. Index: button.c =================================================================== RCS file: /cvsroot/tuxracer/tuxracer/src/button.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** button.c 2000/09/25 14:00:29 1.2 --- button.c 2000/09/25 23:47:32 1.3 *************** *** 88,91 **** --- 88,93 ---- button_t *button = (button_t*) widget; + check_assertion( button != NULL, "button is NULL" ); + if ( which_button != UI_LEFT_BUTTON ) { return; *************** *** 120,123 **** --- 122,127 ---- button_t *button = (button_t*) widget; + check_assertion( button != NULL, "button is NULL" ); + if ( which_button != UI_LEFT_BUTTON ) { return; *************** *** 159,162 **** --- 163,168 ---- button_t *button = (button_t*) widget; + check_assertion( button != NULL, "button is NULL" ); + if ( ! button->enabled ) { return; *************** *** 196,199 **** --- 202,207 ---- char *font_binding; + check_assertion( button != NULL, "button is NULL" ); + pos = button->pos; w = button->w; *************** *** 346,349 **** --- 354,359 ---- button = (button_t*)malloc( sizeof(button_t) ); + check_assertion( button != NULL, "out of memory" ); + button->pos = pos; button->w = w; *************** *** 382,385 **** --- 392,397 ---- void button_delete( button_t *button ) { + check_assertion( button != NULL, "button is NULL" ); + button_set_visible( button, False ); button_set_active( button, False ); *************** *** 404,407 **** --- 416,421 ---- void *userdata ) { + check_assertion( button != NULL, "button is NULL" ); + button->click_cb = cb; button->click_cb_userdata = userdata; *************** *** 418,421 **** --- 432,437 ---- void button_set_hilit_font_binding( button_t *button, char *binding ) { + check_assertion( button != NULL, "button is NULL" ); + button->hilit_font_binding = binding; } *************** *** 431,434 **** --- 447,452 ---- void button_set_disabled_font_binding( button_t *button, char *binding ) { + check_assertion( button != NULL, "button is NULL" ); + button->disabled_font_binding = binding; } *************** *** 450,453 **** --- 468,473 ---- point2d_t p0, point2d_t p1, colour_t colour ) { + check_assertion( button != NULL, "button is NULL" ); + button->tex.binding = texture_binding; button->tex.ll = p0; *************** *** 467,470 **** --- 487,492 ---- point2d_t p0, point2d_t p1, colour_t colour ) { + check_assertion( button != NULL, "button is NULL" ); + button->hilit_tex.binding = texture_binding; button->hilit_tex.ll = p0; *************** *** 484,487 **** --- 506,511 ---- point2d_t p0, point2d_t p1, colour_t colour ) { + check_assertion( button != NULL, "button is NULL" ); + button->disabled_tex.binding = texture_binding; button->disabled_tex.ll = p0; *************** *** 502,505 **** --- 526,531 ---- point2d_t p0, point2d_t p1, colour_t colour ) { + check_assertion( button != NULL, "button is NULL" ); + button->clicked_tex.binding = texture_binding; button->clicked_tex.ll = p0; *************** *** 519,522 **** --- 545,550 ---- void button_set_position( button_t *button, point2d_t pos ) { + check_assertion( button != NULL, "button is NULL" ); + button->pos = pos; } *************** *** 534,537 **** --- 562,567 ---- scalar_t button_get_width( button_t *button ) { + check_assertion( button != NULL, "button is NULL" ); + return button->w; } *************** *** 548,551 **** --- 578,583 ---- scalar_t button_get_height( button_t *button ) { + check_assertion( button != NULL, "button is NULL" ); + return button->h; } *************** *** 563,566 **** --- 595,600 ---- void button_set_enabled( button_t *button, bool_t enabled ) { + check_assertion( button != NULL, "button is NULL" ); + if ( button->enabled != enabled ) { ui_set_dirty(); *************** *** 586,589 **** --- 620,625 ---- bool_t button_is_enabled( button_t *button ) { + check_assertion( button != NULL, "button is NULL" ); + return button->enabled; } *************** *** 602,605 **** --- 638,643 ---- void button_set_visible( button_t *button, bool_t visible ) { + check_assertion( button != NULL, "button is NULL" ); + /* This check is necessary to prevent infinite mutual recursion */ if ( button->active != visible ) { *************** *** 632,635 **** --- 670,675 ---- bool_t button_is_visible( button_t *button ) { + check_assertion( button != NULL, "button is NULL" ); + return button->visible; } *************** *** 648,651 **** --- 688,693 ---- void button_set_active( button_t *button, bool_t active ) { + check_assertion( button != NULL, "button is NULL" ); + if ( !button->active && active ) { ui_add_mouse_motion_callback( button, button_mouse_motion_cb ); *************** *** 681,684 **** --- 723,728 ---- bool_t button_is_active( button_t *button ) { + check_assertion( button != NULL, "button is NULL" ); + return button->active; } Index: listbox.c =================================================================== RCS file: /cvsroot/tuxracer/tuxracer/src/listbox.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -r1.3 -r1.4 *** listbox.c 2000/09/25 14:30:37 1.3 --- listbox.c 2000/09/25 23:47:32 1.4 *************** *** 81,84 **** --- 81,86 ---- static void update_button_enabled_states( listbox_t *listbox ) { + check_assertion( listbox != NULL, "listbox is NULL" ); + if ( listbox->cur_item == NULL ) { /* No items in list */ *************** *** 112,115 **** --- 114,119 ---- static void update_button_positions( listbox_t *listbox ) { + check_assertion( listbox != NULL, "listbox is NULL" ); + button_set_position( listbox->up_button, *************** *** 143,146 **** --- 147,152 ---- listbox_t *listbox = (listbox_t*)userdata; + check_assertion( listbox != NULL, "listbox is NULL" ); + if ( button == listbox->up_button ) { listbox->cur_item = get_prev_list_elem( listbox->item_list, *************** *** 178,181 **** --- 184,189 ---- font_t *font; + check_assertion( listbox != NULL, "listbox is NULL" ); + glDisable( GL_TEXTURE_2D ); *************** *** 241,244 **** --- 249,254 ---- static void listbox_draw_cb( void *widget ) { + check_assertion( widget != NULL, "widget is NULL" ); + listbox_draw( (listbox_t*) widget ); } *************** *** 264,267 **** --- 274,279 ---- listbox = (listbox_t*)malloc( sizeof(listbox_t) ); + check_assertion( listbox != NULL, "out of memory" ); + listbox->pos = pos; listbox->w = w; *************** *** 375,378 **** --- 387,392 ---- void listbox_delete( listbox_t *listbox ) { + check_assertion( listbox != NULL, "listbox is NULL" ); + listbox_set_visible( listbox, False ); listbox_set_active( listbox, False ); *************** *** 397,400 **** --- 411,416 ---- void *userdata ) { + check_assertion( listbox != NULL, "listbox is NULL" ); + listbox->item_change_cb = cb; listbox->item_change_cb_userdata = userdata; *************** *** 413,416 **** --- 429,434 ---- listbox_list_elem_to_string_fptr_t func ) { + check_assertion( listbox != NULL, "listbox is NULL" ); + listbox->item_list = item_list; listbox->cur_item = get_list_head(item_list); *************** *** 432,435 **** --- 450,455 ---- list_elem_t listbox_get_current_item( listbox_t *listbox ) { + check_assertion( listbox != NULL, "listbox is NULL" ); + return listbox->cur_item; } *************** *** 446,449 **** --- 466,471 ---- void listbox_set_current_item( listbox_t *listbox, list_elem_t item ) { + check_assertion( listbox != NULL, "listbox is NULL" ); + listbox->cur_item = item; *************** *** 463,466 **** --- 485,490 ---- void listbox_set_position( listbox_t *listbox, point2d_t pos ) { + check_assertion( listbox != NULL, "listbox is NULL" ); + listbox->pos = pos; update_button_positions( listbox ); *************** *** 479,482 **** --- 503,508 ---- scalar_t listbox_get_width( listbox_t *listbox ) { + check_assertion( listbox != NULL, "listbox is NULL" ); + return listbox->w; } *************** *** 493,496 **** --- 519,524 ---- scalar_t listbox_get_height( listbox_t *listbox ) { + check_assertion( listbox != NULL, "listbox is NULL" ); + return listbox->h; } *************** *** 509,512 **** --- 537,542 ---- void listbox_set_visible( listbox_t *listbox, bool_t visible ) { + check_assertion( listbox != NULL, "listbox is NULL" ); + /* This check is necessary to prevent infinite mutual recursion */ if ( listbox->active != visible ) { *************** *** 538,541 **** --- 568,573 ---- bool_t listbox_is_visible( listbox_t *listbox ) { + check_assertion( listbox != NULL, "listbox is NULL" ); + return listbox->visible; } *************** *** 553,556 **** --- 585,590 ---- void listbox_set_active( listbox_t *listbox, bool_t active ) { + check_assertion( listbox != NULL, "listbox is NULL" ); + button_set_active( listbox->up_button, active ); button_set_active( listbox->down_button, active ); *************** *** 575,578 **** --- 609,614 ---- bool_t listbox_is_active( listbox_t *listbox ) { + check_assertion( listbox != NULL, "listbox is NULL" ); + return listbox->active; } Index: ssbutton.c =================================================================== RCS file: /cvsroot/tuxracer/tuxracer/src/ssbutton.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -r1.2 -r1.3 *** ssbutton.c 2000/09/25 15:15:41 1.2 --- ssbutton.c 2000/09/25 23:47:32 1.3 *************** *** 60,63 **** --- 60,65 ---- int i; + check_assertion( ssbutton != NULL, "ssbutton is NULL" ); + /* Set the image for the button to match the current state */ i = ssbutton->current_state; *************** *** 82,85 **** --- 84,89 ---- static void ssbutton_draw_cb ( void *widget ) { + check_assertion( widget != NULL, "widget is NULL" ); + ssbutton_draw( (ssbutton_t*) widget ); } *************** *** 98,101 **** --- 102,107 ---- ssbutton = (ssbutton_t*) userdata; + check_assertion( ssbutton != NULL, "ssbutton is NULL" ); + ssbutton->current_state = ( ssbutton->current_state + 1 ) % ssbutton->num_states; *************** *** 120,123 **** --- 126,131 ---- ssbutton = (ssbutton_t*)malloc( sizeof(ssbutton_t) ); + check_assertion( ssbutton != NULL, "out of memory" ); + ssbutton->pos = pos; ssbutton->w = w; *************** *** 157,160 **** --- 165,170 ---- void ssbutton_delete( ssbutton_t *ssbutton ) { + check_assertion( ssbutton != NULL, "ssbutton is NULL" ); + ssbutton_set_visible( ssbutton, False ); ssbutton_set_active( ssbutton, False ); *************** *** 177,180 **** --- 187,192 ---- void ssbutton_set_state( ssbutton_t *ssbutton, int state ) { + check_assertion( ssbutton != NULL, "ssbutton is NULL" ); + ssbutton->current_state = state; *************** *** 195,198 **** --- 207,212 ---- int ssbutton_get_state( ssbutton_t *ssbutton ) { + check_assertion( ssbutton != NULL, "ssbutton is NULL" ); + return ssbutton->current_state; } *************** *** 212,215 **** --- 226,231 ---- colour_t colour ) { + check_assertion( ssbutton != NULL, "ssbutton is NULL" ); + ssbutton->regions[state].binding = binding; ssbutton->regions[state].colour = colour; *************** *** 231,234 **** --- 247,252 ---- colour_t colour ) { + check_assertion( ssbutton != NULL, "ssbutton is NULL" ); + button_set_hilit_image( ssbutton->button, binding, ll, ur, colour ); *************** *** 246,249 **** --- 264,269 ---- void ssbutton_set_position( ssbutton_t *ssbutton, point2d_t pos ) { + check_assertion( ssbutton != NULL, "ssbutton is NULL" ); + button_set_position( ssbutton->button, pos ); } *************** *** 260,263 **** --- 280,285 ---- scalar_t ssbutton_get_width( ssbutton_t *ssbutton ) { + check_assertion( ssbutton != NULL, "ssbutton is NULL" ); + return ssbutton->w; } *************** *** 274,277 **** --- 296,301 ---- scalar_t ssbutton_get_height( ssbutton_t *ssbutton ) { + check_assertion( ssbutton != NULL, "ssbutton is NULL" ); + return ssbutton->h; } *************** *** 287,290 **** --- 311,316 ---- void ssbutton_set_enabled( ssbutton_t *ssbutton, bool_t enabled ) { + check_assertion( ssbutton != NULL, "ssbutton is NULL" ); + ssbutton->enabled = enabled; button_set_enabled( ssbutton->button, enabled ); *************** *** 302,305 **** --- 328,333 ---- bool_t ssbutton_is_enabled( ssbutton_t *ssbutton ) { + check_assertion( ssbutton != NULL, "ssbutton is NULL" ); + return ssbutton->enabled; } *************** *** 316,319 **** --- 344,349 ---- void ssbutton_set_visible( ssbutton_t *ssbutton, bool_t visible ) { + check_assertion( ssbutton != NULL, "ssbutton is NULL" ); + if ( ssbutton->active != visible ) { ssbutton_set_active( ssbutton, visible ); *************** *** 344,347 **** --- 374,379 ---- bool_t ssbutton_is_visible( ssbutton_t *ssbutton ) { + check_assertion( ssbutton != NULL, "ssbutton is NULL" ); + return ssbutton->visible; } *************** *** 358,361 **** --- 390,395 ---- void ssbutton_set_active( ssbutton_t *ssbutton, bool_t active ) { + check_assertion( ssbutton != NULL, "ssbutton is NULL" ); + button_set_active( ssbutton->button, active ); *************** *** 378,381 **** --- 412,417 ---- bool_t ssbutton_is_active( ssbutton_t *ssbutton ) { + check_assertion( ssbutton != NULL, "ssbutton is NULL" ); + return ssbutton->active; Index: textarea.c =================================================================== RCS file: /cvsroot/tuxracer/tuxracer/src/textarea.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -r1.1 -r1.2 *** textarea.c 2000/09/25 13:55:59 1.1 --- textarea.c 2000/09/25 23:47:32 1.2 *************** *** 66,69 **** --- 66,71 ---- static void calc_text_region_dims( textarea_t *ta ) { + check_assertion( ta != NULL, "ta is NULL" ); + ta->text_region_width = ta->w - 2*ta->border_width - 2*ta->text_pad - ta->arrow_width; *************** *** 103,106 **** --- 105,110 ---- font_t *font; + check_assertion( ta != NULL, "ta is NULL" ); + if ( !get_font_binding( ta->font_binding, &font ) ) { print_warning( IMPORTANT_WARNING, *************** *** 194,197 **** --- 198,203 ---- int height_used; + check_assertion( ta != NULL, "ta is NULL" ); + cur_line = ta->top_line; *************** *** 258,261 **** --- 264,269 ---- font_t *font; + check_assertion( ta != NULL, "ta is NULL" ); + glDisable( GL_TEXTURE_2D ); *************** *** 303,306 **** --- 311,316 ---- static void textarea_draw_cb( void *widget ) { + check_assertion( widget != NULL, "widget is NULL" ); + textarea_draw( (textarea_t*) widget ); } *************** *** 316,319 **** --- 326,331 ---- static void update_button_enabled_states( textarea_t *ta ) { + check_assertion( ta != NULL, "ta is NULL" ); + if ( ta->top_line == NULL ) { /* No lines */ *************** *** 345,348 **** --- 357,362 ---- static void update_button_positions( textarea_t *ta ) { + check_assertion( ta != NULL, "ta is NULL" ); + button_set_position( ta->up_button, *************** *** 372,375 **** --- 386,391 ---- textarea_t *ta = (textarea_t*) userdata; + check_assertion( ta != NULL, "ta is NULL" ); + if ( button == ta->up_button ) { ta->top_line = get_prev_list_elem( ta->line_list, *************** *** 405,408 **** --- 421,426 ---- ta = (textarea_t*)malloc( sizeof(textarea_t) ); + check_assertion( ta != NULL, "out of memory" ); + ta->pos = pos; ta->w = w; *************** *** 516,519 **** --- 534,539 ---- void textarea_delete( textarea_t *ta ) { + check_assertion( ta != NULL, "ta is NULL" ); + textarea_set_visible( ta, False ); textarea_set_active( ta, False ); *************** *** 551,554 **** --- 571,576 ---- void textarea_set_text( textarea_t *ta, char *text ) { + check_assertion( ta != NULL, "ta is NULL" ); + if ( ta->text_orig != NULL ) { free( ta->text_orig ); *************** *** 577,580 **** --- 599,604 ---- void textarea_set_position( textarea_t *ta, point2d_t pos ) { + check_assertion( ta != NULL, "ta is NULL" ); + ta->pos = pos; update_button_positions( ta ); *************** *** 591,594 **** --- 615,620 ---- int textarea_get_height( textarea_t *ta ) { + check_assertion( ta != NULL, "ta is NULL" ); + return ta->h; } *************** *** 604,607 **** --- 630,635 ---- int textarea_get_width( textarea_t *ta ) { + check_assertion( ta != NULL, "ta is NULL" ); + return ta->w; } *************** *** 617,620 **** --- 645,650 ---- void textarea_set_visible( textarea_t *ta, bool_t visible ) { + check_assertion( ta != NULL, "ta is NULL" ); + /* This check is necessary to prevent infinite mutual recursion */ if ( ta->active != visible ) { *************** *** 645,648 **** --- 675,680 ---- bool_t textarea_get_visible( textarea_t *ta ) { + check_assertion( ta != NULL, "ta is NULL" ); + return ta->visible; } *************** *** 658,661 **** --- 690,695 ---- void textarea_set_active( textarea_t *ta, bool_t active ) { + check_assertion( ta != NULL, "ta is NULL" ); + if ( ta->up_button ) { button_set_active( ta->up_button, active ); *************** *** 682,685 **** --- 716,721 ---- bool_t textarea_get_active( textarea_t *ta ) { + check_assertion( ta != NULL, "ta is NULL" ); + return ta->active; } |