From af7bd7c4e9c704fa7554762afb1bcefde168bf4d Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 30 May 2026 12:20:50 +0200 Subject: [PATCH 1/2] Avoid lookup for widget callbacks, if they are disabled --- src/widgets.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/widgets.cpp b/src/widgets.cpp index 7d36a19..dbc18d3 100644 --- a/src/widgets.cpp +++ b/src/widgets.cpp @@ -132,6 +132,11 @@ static Widget *createWidget(Context &ctx, WidgetHandle parentId, const Rect &rec widget->mType = type; widget->mRect = rect; widget->mParent = setParent(ctx, widget, parentId); + if (widget->mParent == nullptr) { + assert(widget->mParent != nullptr); + delete widget; + widget = nullptr; + } return widget; } @@ -223,7 +228,11 @@ void Widgets::findSelectedWidget(int x, int y, Widget *currentChild, Widget **fo if (currentChild->mRect.isIn(x, y)) { *found = currentChild; for ( auto &child : currentChild->mChildren) { - if (child->mRect.isIn(x, y)){ + if (!child->isEnabled()) { + continue; + } + + if (child->mRect.isIn(x, y)) { findSelectedWidget(x, y, child, found); } } @@ -479,7 +488,8 @@ WidgetHandle Widgets::progressBar(WidgetHandle parentId, const Rect &rect, int f return child->mHandle; } -static void render(Context &ctx, const Widget *currentWidget) { +static void render(Context &ctx, const Widget *currentWidget) +{ if (currentWidget == nullptr) { return; } From 38c25cb80fafd286226a87fa6604c3ebd627224e Mon Sep 17 00:00:00 2001 From: Kim Kulling Date: Sat, 30 May 2026 12:21:56 +0200 Subject: [PATCH 2/2] Fix render function declaration formatting --- src/widgets.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/widgets.cpp b/src/widgets.cpp index dbc18d3..15d4fff 100644 --- a/src/widgets.cpp +++ b/src/widgets.cpp @@ -488,8 +488,7 @@ WidgetHandle Widgets::progressBar(WidgetHandle parentId, const Rect &rect, int f return child->mHandle; } -static void render(Context &ctx, const Widget *currentWidget) -{ +static void render(Context &ctx, const Widget *currentWidget) { if (currentWidget == nullptr) { return; }