diff --git a/docs/classes/element.html b/docs/classes/element.html index b47c802..63dab19 100644 --- a/docs/classes/element.html +++ b/docs/classes/element.html @@ -426,7 +426,7 @@
generated by LDoc 1.4.3 -Last updated 2017-04-12 03:37:15 +Last updated 2017-04-13 08:11:30
diff --git a/docs/classes/window.html b/docs/classes/window.html index 1a13454..7299b5d 100644 --- a/docs/classes/window.html +++ b/docs/classes/window.html @@ -144,7 +144,7 @@
generated by LDoc 1.4.3 -Last updated 2017-04-12 03:37:15 +Last updated 2017-04-13 08:11:30
diff --git a/docs/index.html b/docs/index.html index 11bd9a2..b77e276 100644 --- a/docs/index.html +++ b/docs/index.html @@ -84,7 +84,7 @@
generated by LDoc 1.4.3 -Last updated 2017-04-12 03:37:15 +Last updated 2017-04-13 08:11:30
diff --git a/docs/modules/Element.html b/docs/modules/Element.html index 876ccca..7de58d4 100644 --- a/docs/modules/Element.html +++ b/docs/modules/Element.html @@ -491,7 +491,7 @@
generated by LDoc 1.4.3 -Last updated 2017-04-12 03:37:15 +Last updated 2017-04-13 08:11:30
diff --git a/docs/modules/main.html b/docs/modules/main.html index 107af7c..f2e7c8e 100644 --- a/docs/modules/main.html +++ b/docs/modules/main.html @@ -105,7 +105,7 @@
generated by LDoc 1.4.3 -Last updated 2017-04-12 03:37:15 +Last updated 2017-04-13 08:11:30
diff --git a/docs/modules/pop.html b/docs/modules/pop.html index 1f436c8..6d3054c 100644 --- a/docs/modules/pop.html +++ b/docs/modules/pop.html @@ -758,7 +758,7 @@ table.insert element.parent, element.parent\removeChild(element),
generated by LDoc 1.4.3 -Last updated 2017-04-12 03:37:15 +Last updated 2017-04-13 08:11:30
diff --git a/docs/modules/util.html b/docs/modules/util.html index 4a5fad1..f6547a6 100644 --- a/docs/modules/util.html +++ b/docs/modules/util.html @@ -126,7 +126,7 @@
generated by LDoc 1.4.3 -Last updated 2017-04-12 03:37:15 +Last updated 2017-04-13 08:11:30
diff --git a/elements/element.lua b/elements/element.lua index 7eef533..2bfa6d6 100644 --- a/elements/element.lua +++ b/elements/element.lua @@ -122,20 +122,25 @@ do for i = #self.child, 1, -1 do self.child[i]:delete() end - for i = 1, #self.parent.child do - if self.parent.child[i] == self then - table.remove(self.parent.child, i) - break + if self.parent then + for i = 1, #self.parent.child do + if self.parent.child[i] == self then + table.remove(self.parent.child, i) + break + end end end - for i = 1, #self.parent.data.child do - if self.parent.data.child[i] == self.data then - table.remove(self.parent.data.child, i) - break + if self.parent then + for i = 1, #self.parent.data.child do + if self.parent.data.child[i] == self.data then + table.remove(self.parent.data.child, i) + break + end end end self.parent = nil self.data.parent = nil + self = nil end } _base_0.__index = _base_0 diff --git a/elements/element.moon b/elements/element.moon index bcd5582..58028ba 100644 --- a/elements/element.moon +++ b/elements/element.moon @@ -92,7 +92,7 @@ class element dx = @data.x - dx dy = @data.y - dy for child in *@child - child\move dx, dy + child\move dx, dy return @ @@ -144,7 +144,7 @@ class element --- @treturn element self move: (x=0, y=0) => for child in *@child - child\move x, y + child\move x, y @data.x += x @data.y += y @@ -152,20 +152,22 @@ class element --- Deletes references to this element and then deletes it. delete: => - for i=#@child, 1, -1 - @child[i]\delete! + for i=#@child, 1, -1 + @child[i]\delete! - for i=1, #@parent.child - if @parent.child[i] == @ - table.remove @parent.child, i - break + if @parent + for i=1, #@parent.child + if @parent.child[i] == @ + table.remove @parent.child, i + break - for i=1, #@parent.data.child - if @parent.data.child[i] == @data - table.remove @parent.data.child, i - break + if @parent + for i=1, #@parent.data.child + if @parent.data.child[i] == @data + table.remove @parent.data.child, i + break - @parent = nil - @data.parent = nil -- should be for all @ -> nil - --@ = nil <- or that, does that work? Idk - -- DO NOT DELETE @data though, it could still be in use + @parent = nil + @data.parent = nil -- should be for all @ -> nil MAYBE + @ = nil + -- DO NOT DELETE @data though, it could still be in use