We are currently migrating Bugzilla to GitHub issues.
Any changes made to the bug tracker now will be lost, so please do not post new bugs or make changes to them.
When we're done, all bug URLs will redirect to their equivalent location on the new bug tracker.

Bug 2564 - SDL_PushEvent return success value(1) when actual fault
Summary: SDL_PushEvent return success value(1) when actual fault
Status: RESOLVED INVALID
Alias: None
Product: SDL
Classification: Unclassified
Component: events (show other bugs)
Version: HG 2.1
Hardware: x86_64 Windows 7
: P2 normal
Assignee: Sam Lantinga
QA Contact: Sam Lantinga
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2014-05-29 20:50 UTC by Dmitry
Modified: 2014-06-22 17:01 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry 2014-05-29 20:50:20 UTC
This code example demonstrate bug:

#include <SDL.h>
#include <iostream>

int main(int argc, char** argv)
{
    SDL_Init(SDL_INIT_EVERYTHING);
    SDL_UserEvent myEvent;
    myEvent.code = 0;
    SDL_Event event;
    SDL_PushEvent(reinterpret_cast<SDL_Event*>(&myEvent));
    SDL_PollEvent(&event);
    if (event.user.code == 0)
        std::cout << "OK";
    return 0;
}

"OK" message does not appear because missing assignment
Event.type = SDL_USEREVENT; (without this Event.type can have any value)
But nevertheless SDL_PushEvent return success value (1).

Probably this is my misunderstanding, but I think that this is a bug.
Comment 1 Sam Lantinga 2014-06-22 17:00:41 UTC
It works for me here, you're just missing a newline:
std::cout << "OK" << std::endl;
Comment 2 Sam Lantinga 2014-06-22 17:01:53 UTC
Also, you need to specify the event type. Unlike C++, in C there are no default constructors for structures so you need to explicitly initialize every field in them.