From ef2210b57c67fc43726da2c4b6086c01930525c8 Mon Sep 17 00:00:00 2001 From: omigamedev Date: Sat, 31 Aug 2019 17:20:09 +0200 Subject: [PATCH] task Node::destroy --- src/node.cpp | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/src/node.cpp b/src/node.cpp index 297a3e2..4bd66bf 100644 --- a/src/node.cpp +++ b/src/node.cpp @@ -58,22 +58,27 @@ void Node::watch(std::function observer) void Node::destroy() { - m_destroyed = true; - mouse_release(); - key_release(); - for (auto& c : m_children) - c->destroy(); - for (auto p = m_parent; p; p = p->m_parent) - if (p->child_mouse_focus.get() == this) - p->child_mouse_focus = nullptr; - //App::I->ui_task([&] - //{ - // auto cp = m_children; - // for (auto& c : cp) - // c->destroy(); - // remove_all_children(); - // remove_from_parent(); - //}); + //m_destroyed = true; + //mouse_release(); + //key_release(); + //for (auto& c : m_children) + // c->destroy(); + //for (auto p = m_parent; p; p = p->m_parent) + // if (p->child_mouse_focus.get() == this) + // p->child_mouse_focus = nullptr; + App::I->ui_task([&] + { + mouse_release(); + key_release(); + auto cp = m_children; + for (auto& c : cp) + c->destroy(); + for (auto p = m_parent; p; p = p->m_parent) + if (p->child_mouse_focus.get() == this) + p->child_mouse_focus = nullptr; + remove_all_children(); + remove_from_parent(); + }); } Node* Node::root()