Re: [AD] Problem with remove_mouse() and video bitmaps. |
[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Peter Wang wrote:
On 2005-12-29, Andrei Ellman <ae-a-alleg@xxxxxxxxxx> wrote:
Peter Wang wrote:
Just to be sure, calling show_mouse(NULL); before destroying the video
bitmap had no negative side effects, correct?
That is correct. Adding show_mouse(NULL) also solved the problem that
was reported on the other machine failing to change the resolution back,
so it looks like the documentation needs to be changed.
How's this? The text goes in the entry for show_mouse:
--- docs/src/allegro._tx (revision 5645)
+++ docs/src/allegro._tx (local)
@@ -2860,6 +2860,10 @@
pointer whenever you draw onto the screen. This is not needed if you are
using a hardware cursor.
+ Note: you must not be showing a mouse pointer on a bitmap at the time that
+ the bitmap is destroyed with destroy_bitmap(). This does not apply to
+ `screen' since you never destroy `screen' with destroy_bitmap().
+
@@void @scare_mouse();
@xref unscare_mouse, scare_mouse_area, show_mouse
@shortdesc Helper for hiding the mouse pointer before drawing.
Seems OK to me, but I would add a bit about calling show_mouse(NULL).
--- docs/src/allegro._tx (revision 5645)
+++ docs/src/allegro._tx (local)
@@ -2860,6 +2860,11 @@
pointer whenever you draw onto the screen. This is not needed if
you are
using a hardware cursor.
+ Note: you must not be showing a mouse pointer on a bitmap at the
time that
+ the bitmap is destroyed with destroy_bitmap() (make sure that you call
+ show_mouse(NULL) before the bitmap is destroyed). This does not apply to
+ `screen' since you never destroy `screen' with destroy_bitmap().
+
@@void @scare_mouse();
@xref unscare_mouse, scare_mouse_area, show_mouse
@shortdesc Helper for hiding the mouse pointer before drawing.
Also, I would add something to the entry for derstroy_bitmap() about
making sure that show_mouse(NULL) is called if it's the bitmap that
contains the mouse-cursor.
Stef wrote:
I have a hunch that the crash is caused by the draw_mouse() function accessing the _mouse_screen bitmap (which in this case is invalid, since it is destroyed).
It's show_mouse() (called from remove_mouse() ) attempting to remove the
mouse cursor from _mouse_screen (the crash happens in
bmp->vtable->acquire(bmp) which is in acquire_bitmap() ). By the time
remove_mouse() is called, _mouse_screen is an invalid bitmap.
Even if destroy_bitmap() took in it's argument by reference and set it
to NULL (or the programmer set the pointer to NULL immediately after
destroy_bitmap()), it will not help. This is because _mouse_screen is
stored internally.
So what we would need is a way of setting _mouse_screen to NULL, and
guess what, that's exactly what show_mouse(NULL) does. Therefore, I
think that only the documentstion needs to be changed.
AE.