From 0036a220be62c2445fa19c52bfb3fff48c8d42ba Mon Sep 17 00:00:00 2001 From: Justin Mitchell Date: Mon, 15 Jun 2026 16:39:32 -0400 Subject: [PATCH] Split Rect constructor into default and explicit ctors Separate the default constructor from the parameterized constructor to allow value-initialization of Rect arrays without routing through an explicit constructor. The parameterized constructor remains explicit to prevent implicit int-to-Rect conversions. Member variables now use in-class initializers. --- src/components/themes/BaseTheme.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/components/themes/BaseTheme.h b/src/components/themes/BaseTheme.h index e0dd7003..31bba4f0 100644 --- a/src/components/themes/BaseTheme.h +++ b/src/components/themes/BaseTheme.h @@ -10,12 +10,16 @@ class GfxRenderer; struct RecentBook; struct Rect { - int x; - int y; - int width; - int height; + int x = 0; + int y = 0; + int width = 0; + int height = 0; - explicit Rect(int x = 0, int y = 0, int width = 0, int height = 0) : x(x), y(y), width(width), height(height) {} + // Non-explicit zero-init default ctor so value-initialization (e.g. arrays of + // structs embedding a Rect) does not route through an explicit constructor. + // The parameterized ctor stays explicit to block implicit int->Rect. + Rect() = default; + explicit Rect(int x, int y = 0, int width = 0, int height = 0) : x(x), y(y), width(width), height(height) {} // Logical-coordinate point hit-test (used for touch target hit-testing). bool contains(int px, int py) const { return px >= x && px < x + width && py >= y && py < y + height; }