Re: [AD] Problem with remove_mouse() and video bitmaps.

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


I was in hurry so I did not explain myself enough. Let me explain what I meant:

As far as I can tell, the problem is that the draw_mouse() function (called by the show_mouse()) tries to draw the mouse pointer to a non-valid bitmap (one that has been deallocated). If we had a way to tell whether a bitmap is valid, draw_mouse() could bail out without crashing. (Note: There is NO reason to put mouse specific code in destroy_bitmap() - that's out of the question. It is the mouse code that checks if the target bitmap is valid!)

The follwoing code provides a (half-correct) way:

void destroy_bitmap(BITMAP *bmp)
{
   /* do stuff */
   ...
   bmp = NULL;
}

(ideally there would be a bitmap_exists(BITMAP *bmp) function, and all allegro functions that use bitmaps (read from them or draw to them) would bail out if one of their arguments is not valid.)

Since we don't have a bitmap_exists() function (and for compatibilty reasons can't add one now), we could at least place a check against NULL in draw_mouse().

This is orthogonal to the documentation issue (ie. that one should not use a non-valid bitmap as a target, or crashes may occur).

Does this seem reasonal?




Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/