Sanity check FPS Display to prevent crash

This commit is contained in:
Agent X 2024-07-22 12:43:59 -04:00
parent c509dab0cf
commit 7a9d32551c
2 changed files with 3 additions and 4 deletions

View file

@ -283,7 +283,6 @@ static void djui_base_render_border(struct DjuiBase* base) {
//////////// ////////////
bool djui_base_render(struct DjuiBase* base) { bool djui_base_render(struct DjuiBase* base) {
if (base == NULL) { return false; }
if (!base->visible) { return false; } if (!base->visible) { return false; }
if (base->on_render_pre != NULL) { if (base->on_render_pre != NULL) {

View file

@ -1,5 +1,5 @@
#include "djui.h" #include "djui.h"
#include "../pc_main.h" #include "pc/pc_main.h"
struct DjuiFpsDisplay { struct DjuiFpsDisplay {
struct DjuiText *text; struct DjuiText *text;
@ -9,7 +9,7 @@ struct DjuiFpsDisplay {
struct DjuiFpsDisplay *sFpsDisplay = NULL; struct DjuiFpsDisplay *sFpsDisplay = NULL;
void djui_fps_display_update(u16 fps) { void djui_fps_display_update(u16 fps) {
if (configShowFPS) { if (configShowFPS && sFpsDisplay != NULL) {
char fpsText[30] = ""; char fpsText[30] = "";
snprintf(fpsText, 30, "\\#dcdcdc\\FPS: \\#ffffff\\%d", fps); snprintf(fpsText, 30, "\\#dcdcdc\\FPS: \\#ffffff\\%d", fps);
djui_text_set_text(sFpsDisplay->text, fpsText); djui_text_set_text(sFpsDisplay->text, fpsText);
@ -17,7 +17,7 @@ void djui_fps_display_update(u16 fps) {
} }
void djui_fps_display_render(void) { void djui_fps_display_render(void) {
if (configShowFPS) { if (configShowFPS && sFpsDisplay != NULL) {
djui_rect_render(&sFpsDisplay->base); djui_rect_render(&sFpsDisplay->base);
djui_base_render(&sFpsDisplay->base); djui_base_render(&sFpsDisplay->base);
} }