From f7c4d19df66c602d74795e98ce2ee4390d06fbb4 Mon Sep 17 00:00:00 2001 From: Yuqian Yang Date: Mon, 17 Nov 2025 13:52:52 +0800 Subject: Harden delete after free. --- include/cru/ui/controls/Control.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'include/cru/ui/controls/Control.h') diff --git a/include/cru/ui/controls/Control.h b/include/cru/ui/controls/Control.h index 684bc960..94de4cdc 100644 --- a/include/cru/ui/controls/Control.h +++ b/include/cru/ui/controls/Control.h @@ -1,12 +1,14 @@ #pragma once #include "../Base.h" #include "../DeleteLater.h" +#include "../events/KeyEventArgs.h" +#include "../events/MouseWheelEventArgs.h" #include "../events/UiEvents.h" +#include "../render/MeasureRequirement.h" #include "../render/RenderObject.h" #include "../style/StyleRuleSet.h" -#include "cru/ui/events/KeyEventArgs.h" -#include "cru/ui/events/MouseWheelEventArgs.h" -#include "cru/ui/render/MeasureRequirement.h" + +#include namespace cru::ui::controls { @@ -19,7 +21,9 @@ namespace cru::ui::controls { * - RemoveChild(Control* child) * The last two methods are totally for convenient control tree management. */ -class CRU_UI_API Control : public Object, public DeleteLaterImpl { +class CRU_UI_API Control : public Object, + public DeleteLaterImpl, + public SelfResolvable { friend class RootControl; CRU_DEFINE_CLASS_LOG_TAG("Control") @@ -41,6 +45,7 @@ class CRU_UI_API Control : public Object, public DeleteLaterImpl { Control* GetParent() const { return parent_; } void SetParent(Control* parent); + bool HasAncestor(Control* control); virtual void ForEachChild(const std::function& predicate) = 0; -- cgit v1.2.3