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

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 and others added 3 commits June 22, 2019 14:45
* 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
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.

2 participants