Skip to content

Commit 206517e

Browse files
Merge pull request #416 from AndreWohnsland/dev
Fix addon proper reloading on update
2 parents 0a9a33a + d5d13eb commit 206517e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/programs/addons.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import importlib
66
import json
77
import re
8+
import sys
89
import threading
910
import time
1011
from dataclasses import fields
@@ -287,7 +288,13 @@ def remove_addon(self, addon: AddonData) -> None:
287288
if addon.name in self.addon_thread_ids:
288289
del self.addon_thread_ids[addon.name]
289290
addon_file = ADDON_FOLDER / addon.file_name
291+
290292
addon_file.unlink(missing_ok=True)
293+
294+
# Remove the module from sys.modules to allow fresh import
295+
module_name = f"addons.{addon_file.stem}"
296+
if module_name in sys.modules:
297+
del sys.modules[module_name]
291298
importlib.invalidate_caches()
292299

293300
def reload_addon(self, addon_data: AddonData) -> None:

0 commit comments

Comments
 (0)