From f7c4165aa44ac54828fbd566c027462ad4959023 Mon Sep 17 00:00:00 2001 From: Robert Jelic <36573031+NoryiE@users.noreply.github.com> Date: Sat, 10 May 2025 23:41:05 +0200 Subject: [PATCH] Fix in Container and added Program:stop() --- src/elements/Container.lua | 1 + src/elements/Program.lua | 13 +++++++++++++ 2 files changed, 14 insertions(+) diff --git a/src/elements/Container.lua b/src/elements/Container.lua index 32b0350..92f0f5c 100644 --- a/src/elements/Container.lua +++ b/src/elements/Container.lua @@ -301,6 +301,7 @@ end --- @param child table The child to remove --- @return Container self The container instance function Container:removeChild(child) + if child == nil then return self end for i,v in ipairs(self._values.children) do if v.get("id") == child.get("id") then table.remove(self._values.children, i) diff --git a/src/elements/Program.lua b/src/elements/Program.lua index e189ce5..64820c6 100644 --- a/src/elements/Program.lua +++ b/src/elements/Program.lua @@ -184,6 +184,19 @@ function Program:execute(path, env, addEnvironment) return self end +--- Stops the program +--- @shortDescription Stops the program +--- @return Program self The Program instance +function Program:stop() + local program = self.get("program") + if program then + program:stop() + self.set("running", false) + self.set("program", nil) + end + return self +end + --- Sends an event to the program --- @shortDescription Sends an event to the program --- @param event string The event to send