| Summary: | SDL_PushEvent return success value(1) when actual fault | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Dmitry <dmitriykuchevskiy> |
| Component: | events | Assignee: | Sam Lantinga <slouken> |
| Status: | RESOLVED INVALID | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | ||
| Version: | HG 2.1 | ||
| Hardware: | x86_64 | ||
| OS: | Windows 7 | ||
It works for me here, you're just missing a newline: std::cout << "OK" << std::endl; 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. |
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.