From af9ebe5fe8907e301717a0456093a38736249817 Mon Sep 17 00:00:00 2001 From: nedko Date: Mon, 15 Dec 2025 16:19:44 +0200 Subject: [PATCH] Added some runtime protections. Fixed minor things. --- Widgets/WidgetRect.cpp | 5 +++++ Widgets/WidgetRect.h | 2 +- Widgets/WidgetText.cpp | 5 +++++ Widgets/WidgetText.h | 1 - 4 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Widgets/WidgetRect.cpp b/Widgets/WidgetRect.cpp index f92971c..f0fb7da 100644 --- a/Widgets/WidgetRect.cpp +++ b/Widgets/WidgetRect.cpp @@ -26,6 +26,11 @@ m_radius(radius) void WidgetRect::draw() { + if (nullptr == m_surface) + { + return; + } + // Clear surface SDL_FillRect(m_surface, nullptr, SDL_MapRGBA(m_surface->format, 255, 255, 255, SDL_ALPHA_TRANSPARENT)); diff --git a/Widgets/WidgetRect.h b/Widgets/WidgetRect.h index bfd45ee..a6c0dce 100644 --- a/Widgets/WidgetRect.h +++ b/Widgets/WidgetRect.h @@ -31,7 +31,7 @@ public: static std::unique_ptr builder(const nlohmann::json& j); -private: +protected: // x, y - center of circle // quadrant - 1--4 void draw_circle_corner(int x, int y, int quadrant); diff --git a/Widgets/WidgetText.cpp b/Widgets/WidgetText.cpp index 640fb53..4d02891 100644 --- a/Widgets/WidgetText.cpp +++ b/Widgets/WidgetText.cpp @@ -170,6 +170,11 @@ void WidgetText::set_color(SDL_Color text_color) void WidgetText::draw() { + if (nullptr == m_surface) + { + return; + } + // Clear surface SDL_FillRect(m_surface, nullptr, SDL_MapRGBA(m_surface->format, 255, 255, 255, SDL_ALPHA_TRANSPARENT)); diff --git a/Widgets/WidgetText.h b/Widgets/WidgetText.h index b7ab8b4..58170ef 100644 --- a/Widgets/WidgetText.h +++ b/Widgets/WidgetText.h @@ -2,7 +2,6 @@ #define WIDGET_TEXT_H_ #include "Widget.h" -#include #include