Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix event.custom_event first call #2071

Merged
merged 2 commits into from Sep 4, 2020
Merged

Fix event.custom_event first call #2071

merged 2 commits into from Sep 4, 2020

Conversation

MightyJosip
Copy link
Contributor

@MightyJosip MightyJosip commented Sep 4, 2020

This should fix #2070.

In pygame 2.0.0.dev3 (#1151) return value used to be:

int _custom_event = PGE_USEREVENT + 1;
    int result = _custom_event + 1;
    return PyInt_FromLong(result);

So at the end if default user event is 10, 12 would be returned. To fix this (it should return 11) the following was done in dev4 (#1275)

int _custom_event = PGE_USEREVENT;
   return PyInt_FromLong(_custom_event++);

It updated custom event value only AFTER returning it. Fix could be done even with replacing _custom_event++ with _custom_event++, but I decided to go with returning the old initialization of _custom_event

Copy link
Contributor

@MyreMylar MyreMylar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍 🎉

@MyreMylar MyreMylar merged commit 43a1f34 into master Sep 4, 2020
@notpygame notpygame deleted the custom_event branch September 18, 2020 07:40
@notpygame notpygame changed the title Fix custom_event first call Fix event.custom_event first call Sep 18, 2020
@notpygame notpygame added the event pygame.event label Sep 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
event pygame.event
Projects
None yet
Development

Successfully merging this pull request may close these issues.

pygame.event.custom_type() returns conflicting value on first call
3 participants