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
This commit is contained in:
Ponali
2025-10-15 13:49:38 +02:00
parent f1877f6338
commit e1270d7bd7
+7
View File
@@ -16,8 +16,14 @@ if not moduleList then
end end
local modules = {} local modules = {}
local moduleTypes = {} local moduleTypes = {}
local modulesLoaded = {}
local function loadModule(modName) 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] local moduleData = modules[modName]
table.remove(moduleList, table.find(moduleList, modName)) table.remove(moduleList, table.find(moduleList, modName))
if not moduleData then if not moduleData then
@@ -48,6 +54,7 @@ local function loadModule(modName)
log.kernel.info(string.format("[modload: %s] Loading module", 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 if moduleData.init then -- I have no idea why this would not exist, but it's a failsafe
moduleData.init() moduleData.init()
table.insert(modulesLoaded, modName)
end end
end end