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

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


Since we don't have a bitmap_exists() function (and for compatibilty
reasons can't add one now),

It implies a global data structure with links to every single bitmap
allocated.  Traversing this for every mouse cursor update would not be
nice.  Moreover it would not strictly be correct since you might destroy
a bitmap with address A, then allocate a new bitmap with exactly the
same address A before the draw_mouse() function is called again.

True, but we don't actually need to do that to solve this problem.

we could at least place a check against NULL
in draw_mouse().

That requires checking if a bitmap being destroyed by destroy_bitmap()
has a mouse cursor shown on it and setting a pointer to NULL if that is
so.

Nope. The destroy_bitmap does not care whether anything else is using the bitmap. It just destroys the bitmap (as it does now), sets the pointer to NULL (which is the only thing we add) and returns. Then we change the draw_mouse() function as follows:

void draw_mouse(int remove, int add)
{
   if (_mouse_screen == NULL)
      return;

   /* The rest of the code remains as is. */
}

This just shows the concept. The actual code would not be so trivial, since draw_mouse does other things besides drawing the mouse.

I can't understand why one would need to put any kind of bizarre check in destroy_bitmap().




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