From 185039f21a566750b63e19b4f590267df85b31bd Mon Sep 17 00:00:00 2001 From: scawful Date: Sun, 26 Nov 2023 16:23:36 -0500 Subject: [PATCH] Controller cleanup pointer check --- src/app/core/controller.cc | 2 +- src/app/core/controller.h | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/app/core/controller.cc b/src/app/core/controller.cc index 05475dc9..4e80b72c 100644 --- a/src/app/core/controller.cc +++ b/src/app/core/controller.cc @@ -150,8 +150,8 @@ void Controller::OnInput() { void Controller::OnLoad() { PRINT_IF_ERROR(master_editor_.Update()); } void Controller::DoRender() const { - SDL_RenderClear(renderer_.get()); ImGui::Render(); + SDL_RenderClear(renderer_.get()); ImGui_ImplSDLRenderer2_RenderDrawData(ImGui::GetDrawData()); SDL_RenderPresent(renderer_.get()); } diff --git a/src/app/core/controller.h b/src/app/core/controller.h index 95739ffd..3a6b9f86 100644 --- a/src/app/core/controller.h +++ b/src/app/core/controller.h @@ -33,8 +33,16 @@ class Controller : public ExperimentFlags { private: struct sdl_deleter { - void operator()(SDL_Window *p) const { SDL_DestroyWindow(p); } - void operator()(SDL_Renderer *p) const { SDL_DestroyRenderer(p); } + void operator()(SDL_Window *p) const { + if (p) { + SDL_DestroyWindow(p); + } + } + void operator()(SDL_Renderer *p) const { + if (p) { + SDL_DestroyRenderer(p); + } + } void operator()(SDL_Texture *p) const { SDL_DestroyTexture(p); } };