bilelmoussaoui / Hardcode-Tray

Fixes Hardcoded tray icons in Linux
Other
863 stars 63 forks source link

Garbage collection of temporary PNG files causes script to crash #639

Closed althonos closed 4 years ago

althonos commented 4 years ago

Specifications

Expected behavior and actual behavior

Running harcode-tray fails with the following traceback:

Welcome to Hardcode-Tray!
Hardcode-Tray replaces some icons on the binary files of some applications. 
Please close all the running applications before running Hardcode-Tray script.
Desktop Environment: Other
Scaling Factor: 1
Icon Size: 22
Icon Theme: Numix-Circle
Conversion Tool: Inkscape
To Do: All
Applying now..

Caprine             [######..............................] 1/6 16.7% 0.79s
Dropbox             [############........................] 2/6 33.3% 1.10s
Megasync            [##################..................] 3/6 50.0% 0.00s
Traceback (most recent call last):
  File "/usr/bin/hardcode-tray", line 121, in <module>
    App.execute()
[...]
  File "/usr/lib/python3.8/site-packages/HardcodeTray/utils.py", line 215, in get_pngbytes
    png_bytes = App.svg().to_bin(icon_for_replace,
  File "/usr/lib/python3.8/site-packages/HardcodeTray/modules/svg/svg.py", line 91, in to_bin
    with open(outfile, 'rb') as temppng:
FileNotFoundError: [Errno 2] No such file or directory: '/tmp/tmpge1lsq1f'

I tracked the problem down to the PNG temporary file being deleted if the Garbage Collector decides to deallocate the NamedTemporaryFile that is inlined in HardcodeTray.svg.svg

I'll open a PR to fix the issue.