From cb79bc521ab9722b6d6996a2c5ac09e30420dca9 Mon Sep 17 00:00:00 2001 From: Aintmee <85761348+Aintdev@users.noreply.github.com> Date: Mon, 14 Sep 2026 17:17:19 +0200 Subject: [PATCH] fix(widget): get_parent now returns pointer instead of reference this makes it more safe if, for example: _parent == nullptr because nullptr would've been derefrenced. --- Source/Widgets/ctui_widget.cpp | 4 ++-- Source/Widgets/ctui_widget.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Source/Widgets/ctui_widget.cpp b/Source/Widgets/ctui_widget.cpp index f1ebe3a..9421efe 100644 --- a/Source/Widgets/ctui_widget.cpp +++ b/Source/Widgets/ctui_widget.cpp @@ -14,9 +14,9 @@ namespace ctui return _absolute_bounds; } - const Widget& Widget::get_parent() const + const Widget* Widget::get_parent() const { - return *_parent; + return _parent; } void Widget::set_parent(Container* parent_ptr) diff --git a/Source/Widgets/ctui_widget.h b/Source/Widgets/ctui_widget.h index 71153bd..29ce240 100644 --- a/Source/Widgets/ctui_widget.h +++ b/Source/Widgets/ctui_widget.h @@ -51,7 +51,7 @@ namespace ctui { [[nodiscard]] const Rect& get_relative_bounds() const; [[nodiscard]] const Rect& get_absolute_bounds() const; - [[nodiscard]] const Widget& get_parent() const; + [[nodiscard]] const Widget* get_parent() const; void set_parent(Container* parent_ptr);