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 double invocation of App._stop when using App.stop and App.run #8736

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

CoreTaxxe
Copy link

Fixes #2397 and #4577

Previosly on_stop - or App._stop in general - would be triggered twice if an App instance was used in combination with App.run and App.stop. This was due to App.run invoking App._stop on its own as well.

My proposed fix keeps this behaviour as is but changes App.stop to not call App._stop directly but instead use stopTouchApp or EventLoop.close to have thenApp.run invoke App._stop

This should not cause any issues since App._stop is only ever invoked by App.run, App.async_run and previously App.stop as far as I am aware and running App.run still yield in the same results even if App.stop is never called by the user. The only change in behaviour would be using App.stop without ever calling App.run which shouldn't ever be the case anyways.

This also voids the second stopTouchApp call in App._stop

MRE

from kivy.app import App
from kivy.lang import Builder

root = Builder.load_string('''
Button:
    text: 'Exit'
    on_release: app.stop()
''')


class TestApp(App):
    def build(self):
        return root

    def on_stop(self):
        print('stopping')


if __name__ == '__main__':
    TestApp().run()

Maintainer merge checklist

  • Title is descriptive/clear for inclusion in release notes.
  • Applied a Component: xxx label.
  • Applied the api-deprecation or api-break label.
  • Applied the release-highlight label to be highlighted in release notes.
  • Added to the milestone version it was merged into.
  • Unittests are included in PR.
  • Properly documented, including versionadded, versionchanged as needed.

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.

on_stop dispatched twice when calling app.stop()
1 participant