diff --git a/src/app/script/layer_class.cpp b/src/app/script/layer_class.cpp index a8f0872a2..8a4bb06d9 100644 --- a/src/app/script/layer_class.cpp +++ b/src/app/script/layer_class.cpp @@ -331,7 +331,9 @@ int Layer_set_parent(lua_State* L) return luaL_error(L, "the given parent is not a layer group or sprite"); } - if (parent == layer) + if (!parent) + return luaL_error(L, "parent cannot be nil"); + else if (parent == layer) return luaL_error(L, "the parent of a layer cannot be the layer itself"); // TODO Why? should we be able to do this? It would require some hard work: