SDL_PushEvent incorrect return

The return type for SDL_PushEvent is incorrect according to the
documentation (not sure if it’s the code or docs that should be
fixed?) The documentation states “Returns 0 on success or -1 if the
event couldn’t be pushed.”

SDL_PushEvent falls through to a couple functions, eventually
returning the value from SDL_AddEvent…

static int SDL_AddEvent(SDL_Event event)
{
int tail, added;

if ( tail == SDL_EventQ.head ) {
/
Overflow, drop event */
added = 0;
} else {

added = 1;
}
return(added);
}

this means SDL_PushEvent returns 1 on success and 0 on failure.
either the docs need fixing or…

int SDL_PushEvent(SDL_Event *event)
{
int added;
added = SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0);
return (added == 1) ? 0 : -1;
}

The return type for SDL_PushEvent is incorrect according to the
documentation (not sure if it’s the code or docs that should be
fixed?) The documentation states “Returns 0 on success or -1 if the
event couldn’t be pushed.”

Check CVS, this should already be fixed.

Thanks,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Sam Lantinga wrote:

The return type for SDL_PushEvent is incorrect according to the
documentation (not sure if it’s the code or docs that should be
fixed?) The documentation states “Returns 0 on success or -1 if the
event couldn’t be pushed.”

Check CVS, this should already be fixed.

looks incorrect in cvs. i noticed the last cvs entry log for
events.c was “The documented error return value for SDL_WaitEvent()
is 0”. were you remembering this and thinking it was SDL_PushEvent?
cvs code is:

int SDL_PushEvent(SDL_Event *event)
{
return(SDL_PeepEvents(event, 1, SDL_ADDEVENT, 0));
}

and SDL_PeepEvents is returning the number of events added. heh,
just to be sure i checked the cvs version of the docs to make sure
that’s not what you meant. docs still say 0 is success :]

and SDL_PeepEvents is returning the number of events added. heh,
just to be sure i checked the cvs version of the docs to make sure
that’s not what you meant. docs still say 0 is success :]

I have patched the CVS version to match the documentation (my first CVS
checkin! Yay! :slight_smile: ).

–ryan.

and SDL_PeepEvents is returning the number of events added. heh,
just to be sure i checked the cvs version of the docs to make sure
that’s not what you meant. docs still say 0 is success :]

I have patched the CVS version to match the documentation (my first CVS
checkin! Yay! :slight_smile: ).

Cool! :slight_smile:
BTW, it’s possible for SDL_PeepEvents() to return -1. I’ve fixed it in CVS.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

IMHO this is not a good fix. I suspect you are going to break a lot of
existing code. The documentation should have been changed to match the
code, not the other way around. The fact that the documentation is wrong
is actually pretty well documented in the online version of the docs at
the documentation project (http://sdldoc.csn.ul.ie/sdlpushevent.php).
Since this is an open source problem anyone who has run into the problem
will have looked at the code to figure out what is wrong (UTSL). Changes
the code breaks compatibility for no good reason. The former behaviour
of PushEvent was just fine, it was just not properly documented. Please,
correct the documentation, not the code.

	Bob Pendleton

Sam Lantinga wrote:>>>and SDL_PeepEvents is returning the number of events added. heh,

just to be sure i checked the cvs version of the docs to make sure
that’s not what you meant. docs still say 0 is success :]

I have patched the CVS version to match the documentation (my first CVS
checkin! Yay! :slight_smile: ).

Cool! :slight_smile:
BTW, it’s possible for SDL_PeepEvents() to return -1. I’ve fixed it in CVS.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


±-----------------------------------------+

  • Bob Pendleton, an experienced C/C++/Java +
  • UNIX/Linux programmer, researcher, and +
  • system architect, is seeking full time, +
  • consulting, or contract employment. +
  • Resume: http://www.jump.net/~bobp +
  • Email: @Bob_Pendleton +
    ±-----------------------------------------+

IMHO this is not a good fix. I suspect you are going to break a lot of
existing code. The documentation should have been changed to match the
code, not the other way around. The fact that the documentation is wrong
is actually pretty well documented in the online version of the docs at
the documentation project (http://sdldoc.csn.ul.ie/sdlpushevent.php).
Since this is an open source problem anyone who has run into the problem
will have looked at the code to figure out what is wrong (UTSL). Changes
the code breaks compatibility for no good reason. The former behaviour
of PushEvent was just fine, it was just not properly documented. Please,
correct the documentation, not the code.

That’s a really good point, especially for a stable release.
Ryan, what do you think?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Perhaps make it a runtime settable flag on sdl, like USE_CORRECT_BLAH_BEHAVIOR,
so that programmers who like the behavior can get it in theirs without affecting
existing ones that obviously wouldn’t set this?On Tue, Jun 04, 2002 at 02:02:17PM -0700, Sam Lantinga wrote:

IMHO this is not a good fix. I suspect you are going to break a lot of
existing code. The documentation should have been changed to match the
code, not the other way around. The fact that the documentation is wrong
is actually pretty well documented in the online version of the docs at
the documentation project (http://sdldoc.csn.ul.ie/sdlpushevent.php).
Since this is an open source problem anyone who has run into the problem
will have looked at the code to figure out what is wrong (UTSL). Changes
the code breaks compatibility for no good reason. The former behaviour
of PushEvent was just fine, it was just not properly documented. Please,
correct the documentation, not the code.

That’s a really good point, especially for a stable release.
Ryan, what do you think?

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment

Perhaps make it a runtime settable flag on sdl, like USE_CORRECT_BLAH_BEHAVIOR,
so that programmers who like the behavior can get it in theirs without affecting
existing ones that obviously wouldn’t set this?

No, we’ll just fix it one way or the other.
I’m leaning towards fixing the docs.

See ya,
-Sam Lantinga, Software Engineer, Blizzard Entertainment