SDL_RegisterEvents() now returns 0 if it couldn't allocate any user events.
parent
4d20b82850
commit
860155680d
|
@ -338,6 +338,8 @@ SDL_QUERY, SDL_IGNORE, SDL_ENABLE, and SDL_DISABLE have been removed. You can us
|
||||||
|
|
||||||
SDL_AddEventWatch() now returns -1 if it fails because it ran out of memory and couldn't add the event watch callback.
|
SDL_AddEventWatch() now returns -1 if it fails because it ran out of memory and couldn't add the event watch callback.
|
||||||
|
|
||||||
|
SDL_RegisterEvents() now returns 0 if it couldn't allocate any user events.
|
||||||
|
|
||||||
The following symbols have been renamed:
|
The following symbols have been renamed:
|
||||||
* SDL_APP_DIDENTERBACKGROUND => SDL_EVENT_DID_ENTER_BACKGROUND
|
* SDL_APP_DIDENTERBACKGROUND => SDL_EVENT_DID_ENTER_BACKGROUND
|
||||||
* SDL_APP_DIDENTERFOREGROUND => SDL_EVENT_DID_ENTER_FOREGROUND
|
* SDL_APP_DIDENTERFOREGROUND => SDL_EVENT_DID_ENTER_FOREGROUND
|
||||||
|
|
|
@ -1199,15 +1199,8 @@ extern DECLSPEC SDL_bool SDLCALL SDL_EventEnabled(Uint32 type);
|
||||||
* Allocate a set of user-defined events, and return the beginning event
|
* Allocate a set of user-defined events, and return the beginning event
|
||||||
* number for that set of events.
|
* number for that set of events.
|
||||||
*
|
*
|
||||||
* Calling this function with `numevents` <= 0 is an error and will return
|
|
||||||
* (Uint32)-1.
|
|
||||||
*
|
|
||||||
* Note, (Uint32)-1 means the maximum unsigned 32-bit integer value (or
|
|
||||||
* 0xFFFFFFFF), but is clearer to write.
|
|
||||||
*
|
|
||||||
* \param numevents the number of events to be allocated
|
* \param numevents the number of events to be allocated
|
||||||
* \returns the beginning event number, or (Uint32)-1 if there are not enough
|
* \returns the beginning event number, or 0 if numevents is invalid or if there are not enough user-defined events left.
|
||||||
* user-defined events left.
|
|
||||||
*
|
*
|
||||||
* \since This function is available since SDL 3.0.0.
|
* \since This function is available since SDL 3.0.0.
|
||||||
*
|
*
|
||||||
|
|
|
@ -1447,13 +1447,11 @@ SDL_bool SDL_EventEnabled(Uint32 type)
|
||||||
|
|
||||||
Uint32 SDL_RegisterEvents(int numevents)
|
Uint32 SDL_RegisterEvents(int numevents)
|
||||||
{
|
{
|
||||||
Uint32 event_base;
|
Uint32 event_base = 0;
|
||||||
|
|
||||||
if ((numevents > 0) && (SDL_userevents + numevents <= SDL_EVENT_LAST)) {
|
if ((numevents > 0) && (SDL_userevents + numevents <= SDL_EVENT_LAST)) {
|
||||||
event_base = SDL_userevents;
|
event_base = SDL_userevents;
|
||||||
SDL_userevents += numevents;
|
SDL_userevents += numevents;
|
||||||
} else {
|
|
||||||
event_base = (Uint32)-1;
|
|
||||||
}
|
}
|
||||||
return event_base;
|
return event_base;
|
||||||
}
|
}
|
||||||
|
|
|
@ -182,7 +182,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
int status = 0;
|
int status = 0;
|
||||||
SDL_Event event;
|
SDL_Event event;
|
||||||
intptr_t eventNumber = SDL_RegisterEvents(1);
|
Uint32 eventNumber = SDL_RegisterEvents(1);
|
||||||
SDL_Thread *thread = SDL_CreateThread(&button_messagebox, "MessageBox", (void *)eventNumber);
|
SDL_Thread *thread = SDL_CreateThread(&button_messagebox, "MessageBox", (void *)eventNumber);
|
||||||
|
|
||||||
while (SDL_WaitEvent(&event)) {
|
while (SDL_WaitEvent(&event)) {
|
||||||
|
|
Loading…
Reference in New Issue