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

Widget image unload crash #384

Merged
merged 3 commits into from Aug 12, 2019

Conversation

@avanwinkle
Copy link
Collaborator

commented Aug 12, 2019

FIX FOR #375

When using a image: load: mode_start configuration to load image assets on mode start and unload on mode end, a Widget hosting the Image will crash MC.

widgets/image.py

def prepare_for_removal(self) -> None:
  """Prepare the widget to be removed."""
  super().prepare_for_removal()
  self._image.image.anim_reset(False)

By the time prepare_for_removal() is called, the Image asset has already been unloaded from the image widget so self._image.image is None, which causes a crash:
AttributeError: 'NoneType' object has no attribute 'anim_reset'

This PR works around the error by wrapping the prepare_for_removal() with an exception catch and ignore it on AttributeError.

def prepare_for_removal(self) -> None:
  """Prepare the widget to be removed."""
  super().prepare_for_removal()
  # stop any animations
  try:
    self._image.image.anim_reset(False)
  # If the image was already unloaded from memory
  except AttributeError:
    pass
avanwinkle added 3 commits Jun 22, 2019
Merge branch 'dev' into widget-image-unload-crash
* dev: (80 commits)
  add some more tests
  add test for slide_player and conditionals
  handle events from MPF
  remove fishy test. we got integration tests for that
  move parse_conditional_template out of hot loop
  fix machine variables in integration test
  0.53.0-dev.8
  Fix enabled function due to change in SDL audio
  Re-cythonize .c files
  Fix sound about to finish notification bug
  Remove duplicate declarations
  Fix audio test
  make linter happy
  Fix proper indent level
  0.53.0-dev.7
  Restore linux builds
  Remove encrypted pypi password from script
  update pypi username
  Remove unneeded SDL2_ttf library
  Fix rename_wheels calling dir
  ...

@jabdoa2 jabdoa2 merged commit 27bf350 into missionpinball:dev Aug 12, 2019

1 of 2 checks passed

continuous-integration/travis-ci/pr The Travis CI build could not complete due to an error
Details
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.