TeaM-TL / FotoKilof

GUI for ImageMagick and Wand
MIT License
306 stars 17 forks source link

crash on startup when last used image path does not exist anymore #108

Closed bastidest closed 3 years ago

bastidest commented 3 years ago

Describe the bug After updating from version 3.7.1 to 3.7.6, I was unable to start the application. Immediately on startup an exception is thrown:

Traceback (most recent call last):
  File "/usr/bin/fotokilof", line 33, in <module>
    sys.exit(load_entry_point('FotoKilof==3.7.6', 'gui_scripts', 'fotokilof')())
  File "/usr/bin/fotokilof", line 25, in importlib_load_entry_point
    return next(matches).load()
  File "/usr/lib/python3.9/importlib/metadata.py", line 77, in load
    module = import_module(match.group('module'))
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/usr/lib/python3.9/site-packages/src/__main__.py", line 2246, in <module>
    crop_tool_hide_show()
  File "/usr/lib/python3.9/site-packages/src/__main__.py", line 1368, in crop_tool_hide_show
    preview_orig()
  File "/usr/lib/python3.9/site-packages/src/__main__.py", line 1197, in preview_orig
    preview_picture = preview.preview_pillow(file_in_path.get(),
  File "/usr/lib/python3.9/site-packages/src/preview.py", line 131, in preview_pillow
    image_resized = image.resize((width_resize, height_resize))
UnboundLocalError: local variable 'image' referenced before assignment

The last known (non-existing) image is opened here, causing an exception, causing the image variable to be unassigned. https://github.com/TeaM-TL/FotoKilof/blob/f23bf8a3064c40e49fb15803ea3a616fa7e6485a/src/preview.py#L112

Further on, image is referenced, causing a crash: https://github.com/TeaM-TL/FotoKilof/blob/f23bf8a3064c40e49fb15803ea3a616fa7e6485a/src/preview.py#L131

To Reproduce Steps to reproduce the behavior:

  1. start the application and open any file
  2. close the application and delete the opened file
  3. start the application
  4. crash

Expected behavior The application should startup independent of the previously opened file existing or not.

TeaM-TL commented 3 years ago

Thank you. I will try to fix it asap

TeaM-TL commented 3 years ago

fixed in 3.7.7

TeaM-TL commented 3 years ago

fixed crash when crop was active. fixed in 3.7.8