View Single Post
Old 07-19-2022, 02:52 PM   #452
JimmXinu
Plugin Developer
JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.JimmXinu ought to be getting tired of karma fortunes by now.
 
JimmXinu's Avatar
 
Posts: 7,006
Karma: 4604635
Join Date: Dec 2011
Location: Midwest USA
Device: Kobo Clara Colour running KOReader
New Test Version Posted

2022-07-19
- Look for icon.png without images/ first.

FYI, I'm not sure this is going to be the final solution.

In Cal6, the get_icons(icon_name,plugin_name) does retrieval from resources/images, from a theme and then, if not in either, retrieval from the plugin zip.

In past, the plugin code removed the 'images/' before looking in resources/images for custom icons, but kept it for looking inside the plugin zip.

Moving the icon.png up from the images/ dir inside the plugin zip didn't work when I tried it in Cal5. As I recall, there were reasons it was in images/, but I don't remember why exactly.

Regardless, it would require retesting on the all supported old versions of Calibre, in all the plugins I support. I'm not doing that, sorry.

This appears to work as expected:
Code:
...
        if not icon or icon.isNull():
            icon = get_icons(icon_name.replace('images/',''),plugin_name)
        if not icon or icon.isNull():
            icon = get_icons(icon_name,plugin_name)
    return icon
Except that Cal6 explicitly reports not finding 'icon.png' (without images/) all the time in the debug log if it's not found in resources/images or theme (we know it's not to be found in plugin zip):
Code:
Traceback (most recent call last):
  File "C:\Users\user\Desktop\nook\calibre\src\calibre\customize\zipplugin.py", line 50, in get_resources
  File "zipfile.py", line 1464, in read
  File "zipfile.py", line 1503, in open
  File "zipfile.py", line 1430, in getinfo
KeyError: "There is no item named 'icon.png' in the archive"
It's not raising the exception, it's just printing the stack trace to debug.

But it happens quite a bit, and I run calibre in debug 99.9% of the time.

I could cache icons in the plugin, but then they wouldn't change if you change themes. Which isn't something that works consistently for me anyway?

Last edited by JimmXinu; 07-31-2022 at 10:44 AM. Reason: Remove obsolete test version
JimmXinu is offline   Reply With Quote