[ Thread Index |
Date Index
| More lists.liballeg.org/allegro-developers Archives
]
Hello,
Attached is a patch that makes uniform the behaviour of al_wait_for_event, al_peek_next_event, al_get_next_event and the timed versions of the wait one when the second argument is 0.
Before, the get/peek versions asserted this away. The wait version took the parameter to mean whether it would actually do anything to the queue or not, which I thought illogical. The behaviour now is consistent amongst all of them: specifically, if a 0 is passed as the return event, it is not written to. Otherwise, everything happens as normal: events are deleted, or peeked as usual.
I don't think it should affect anything, as I couldn't find any place where 0 was actually used in the examples.
Yeah...
Incidentally, examples no longer work on Linux Ubuntu 8.04 64 bit for me. A black window flashes, and goes away. Some examples work however, e.g. ex_drawpixels or others. I think it has to do with loading of resources... just thought I'd bring it up.
-SiegeLord
Index: src/events.c
===================================================================
--- src/events.c (revision 11143)
+++ src/events.c (working copy)
@@ -231,14 +231,15 @@
{
ALLEGRO_EVENT *next_event;
ASSERT(queue);
- ASSERT(ret_event);
_al_mutex_lock(&queue->mutex);
next_event = get_next_event_if_any(queue, true);
if (next_event) {
- copy_event(ret_event, next_event);
- /* Don't increment reference count on user events. */
+ if(ret_event) {
+ copy_event(ret_event, next_event);
+ /* Don't increment reference count on user events. */
+ }
}
_al_mutex_unlock(&queue->mutex);
@@ -259,14 +260,15 @@
{
ALLEGRO_EVENT *next_event;
ASSERT(queue);
- ASSERT(ret_event);
_al_mutex_lock(&queue->mutex);
next_event = get_next_event_if_any(queue, false);
if (next_event) {
- copy_event(ret_event, next_event);
- ref_if_user_event(ret_event);
+ if(ret_event) {
+ copy_event(ret_event, next_event);
+ ref_if_user_event(ret_event);
+ }
}
_al_mutex_unlock(&queue->mutex);
@@ -341,9 +343,12 @@
_al_cond_wait(&queue->cond, &queue->mutex);
}
- if (ret_event) {
- next_event = get_next_event_if_any(queue, true);
- copy_event(ret_event, next_event);
+ next_event = get_next_event_if_any(queue, true);
+ if (next_event) {
+ if(ret_event) {
+ copy_event(ret_event, next_event);
+ /* Don't increment reference count on user events. */
+ }
}
}
_al_mutex_unlock(&queue->mutex);
@@ -411,9 +416,15 @@
if (result == -1)
timed_out = true;
- else if (ret_event) {
+ else
+ {
next_event = get_next_event_if_any(queue, true);
- copy_event(ret_event, next_event);
+ if (next_event) {
+ if(ret_event) {
+ copy_event(ret_event, next_event);
+ /* Don't increment reference count on user events. */
+ }
+ }
}
}
_al_mutex_unlock(&queue->mutex);