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 all ScreenManagers sharing the same transition #5370

Merged
merged 3 commits into from
Sep 7, 2017

Conversation

Cheaterman
Copy link
Contributor

All ScreenManagers share the same SlideTransition instance by default, which can cause some timing issues and other weirdness (and is more generally a bad idea). This PR fixes the issue.

All ScreenManagers share the same SlideTransition instance by default, which can cause some timing issues and other weirdness (and is more generally a bad idea). This PR fixes the issue.
If the ScreenManager's "on_current" is called before self.transition is set, it will crash because on_current tries self.transition.stop(). This fixes the issue by forcing the transition to be set by the time event bindings are done.
@@ -964,6 964,7 @@ def _get_screen_names(self):
'''

def __init__(self, **kwargs):
self.transition = SlideTransition()
Copy link
Contributor

Choose a reason for hiding this comment

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

I would suggest using:

if 'transition' not in kwargs:
    kwargs['transition'] = SlideTransition()

This way if transition keyword is used in creating of ScreenManager instance then default SlideTransition instance doesn't get created.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed my good friend, thanks for the idea! :-)

@@ -964,6 964,8 @@ def _get_screen_names(self):
'''

def __init__(self, **kwargs):
if 'transition' not in kwargs:
self.transition = SlideTransition()
Copy link
Contributor

@KeyWeeUsr KeyWeeUsr Sep 6, 2017

Choose a reason for hiding this comment

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

I'd perhaps choose to rewrite only the kwargs part and not put it directly into the instance because the transition is a Kivy property and those are evaluated from kwargs in the super() call to any EventDispatcher instance afaik. However when tested, the assignment triggers on_transition correctly, sooo.. still looks good to me :)

Edit: ah, @pythonic64 apparently suggested the same approach, my bad.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, that's what he suggested, but I felt like we didn't need that much indirection to simply set a variable, and I discussed with tshirtman in meatspace and we reached the same conclusion, so there you have it :-) if you still feel setting kwargs is a better idea, I can amend my PR of course!

Copy link
Contributor

@KeyWeeUsr KeyWeeUsr Sep 6, 2017

Choose a reason for hiding this comment

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

Well, it doesn't break the on_* event, so it should be ok. I'll wait for the CI and merge.

@KeyWeeUsr KeyWeeUsr merged commit 3c529f9 into kivy:master Sep 7, 2017
@KeyWeeUsr
Copy link
Contributor

Thanks 🍡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants