From 51aaa1f6034a4f6b6dd3edcfd4c0140b575af6a3 Mon Sep 17 00:00:00 2001 From: mani Date: Tue, 6 Jan 2026 01:15:50 +0100 Subject: [PATCH] Remove remaining problematic module-level addon access - Remove module-level addon variable in kodi_utils.py - Load addon locally in add_menu_directory_item() where needed - Load addon locally in SHOW_SETTINGS mode in functions.py - Keep __addon__ fallback in functions.py for non-critical uses (__addondir__, addon_id, PLUGINPATH) which have safe fallback values - loghandler.py already has proper exception handling around __pluginpath__ usage --- resources/lib/functions.py | 3 ++- resources/lib/kodi_utils.py | 6 +----- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/resources/lib/functions.py b/resources/lib/functions.py index 31284e0..a4d95c1 100644 --- a/resources/lib/functions.py +++ b/resources/lib/functions.py @@ -125,7 +125,8 @@ def main_entry_point(): elif mode == "CLONE_SKIN": clone_default_skin() elif mode == "SHOW_SETTINGS": - __addon__.openSettings() + addon = xbmcaddon.Addon() + addon.openSettings() window = xbmcgui.getCurrentWindowId() if window == 10000: log.debug( diff --git a/resources/lib/kodi_utils.py b/resources/lib/kodi_utils.py index a7553f1..b2be06d 100644 --- a/resources/lib/kodi_utils.py +++ b/resources/lib/kodi_utils.py @@ -11,11 +11,6 @@ import xbmcaddon from .lazylogger import LazyLogger log = LazyLogger(__name__) -try: - addon = xbmcaddon.Addon() -except Exception: - # During installation/update, addon might not be fully registered yet - addon = None class HomeWindow: @@ -45,6 +40,7 @@ def add_menu_directory_item(label, path, folder=True, art=None, properties=None) li = xbmcgui.ListItem(label, path=path, offscreen=True) if art is None: art = {} + addon = xbmcaddon.Addon() art["thumb"] = addon.getAddonInfo('icon') if properties is not None: li.setProperties(properties)