Sdk/Canvas: Fix crash at Canvas destruction
This commit is contained in:
parent
5865679891
commit
e1e290808a
|
|
@ -89,6 +89,7 @@ namespace Ndk
|
|||
inline BaseWidget();
|
||||
|
||||
inline void DestroyChild(BaseWidget* widget);
|
||||
void DestroyChildren();
|
||||
inline void NotifyParentResized(const Nz::Vector2f& newSize);
|
||||
inline void UpdateCanvasIndex(std::size_t index);
|
||||
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ namespace Ndk
|
|||
inline Canvas(WorldHandle world, Nz::EventHandler& eventHandler);
|
||||
Canvas(const Canvas&) = delete;
|
||||
Canvas(Canvas&&) = delete;
|
||||
~Canvas() = default;
|
||||
inline ~Canvas();
|
||||
|
||||
inline const WorldHandle& GetWorld() const;
|
||||
|
||||
|
|
|
|||
|
|
@ -22,6 +22,12 @@ namespace Ndk
|
|||
m_textEnteredSlot.Connect(eventHandler.OnTextEntered, this, &Canvas::OnTextEntered);
|
||||
}
|
||||
|
||||
inline Canvas::~Canvas()
|
||||
{
|
||||
// Destroy children explicitly because they signal us when getting destroyed, and that can't happend after our own destruction
|
||||
DestroyChildren();
|
||||
}
|
||||
|
||||
inline const WorldHandle& Canvas::GetWorld() const
|
||||
{
|
||||
return m_world;
|
||||
|
|
|
|||
|
|
@ -165,4 +165,9 @@ namespace Ndk
|
|||
|
||||
m_children.erase(it);
|
||||
}
|
||||
|
||||
void BaseWidget::DestroyChildren()
|
||||
{
|
||||
m_children.clear();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue