From e1270d7bd79fc2d5ac1a1a5822bc8bc60438a430 Mon Sep 17 00:00:00 2001 From: Ponali Date: Wed, 15 Oct 2025 13:49:38 +0200 Subject: [PATCH] fixed a bug in modload that lets modules get loaded twice through dependencies if two modules contain a dependency to the same module, that dependency will load *twice*, which shouldn't normally happen --- halyde/kernel/modload.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/halyde/kernel/modload.lua b/halyde/kernel/modload.lua index 5423b44..bbd4e6e 100644 --- a/halyde/kernel/modload.lua +++ b/halyde/kernel/modload.lua @@ -16,8 +16,14 @@ if not moduleList then end local modules = {} local moduleTypes = {} +local modulesLoaded = {} local function loadModule(modName) + if table.find(modulesLoaded, modName) then + log.kernel.warn(string.format("[modload: %s] Module was already loaded - skipping", modName)) + return + end + local moduleData = modules[modName] table.remove(moduleList, table.find(moduleList, modName)) if not moduleData then @@ -48,6 +54,7 @@ local function loadModule(modName) log.kernel.info(string.format("[modload: %s] Loading module", modName)) if moduleData.init then -- I have no idea why this would not exist, but it's a failsafe moduleData.init() + table.insert(modulesLoaded, modName) end end