From 8c18d4f3c8718960ff6acbbd581b182b4f99eb7e Mon Sep 17 00:00:00 2001
From: TheJackiMonster <thejackimonster@gmail.com>
Date: Tue, 19 Jul 2022 15:22:11 +0200
Subject: [PATCH] Make button safer to use

Signed-off-by: TheJackiMonster <thejackimonster@gmail.com>
---
 projects/fire_works/src/main.cpp | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/projects/fire_works/src/main.cpp b/projects/fire_works/src/main.cpp
index ebfa88d7..7f96170c 100644
--- a/projects/fire_works/src/main.cpp
+++ b/projects/fire_works/src/main.cpp
@@ -832,7 +832,14 @@ int main(int argc, const char **argv) {
 		gui.beginGUI();
 		ImGui::Begin("Settings");
 		
-		if (ImGui::Button("Reset")) {
+		bool resetTime = ImGui::Button("Reset");
+		
+		ImGui::End();
+		gui.endGUI();
+		
+		core.endFrame(windowHandle);
+		
+		if (resetTime) {
 			start = std::chrono::system_clock::now();
 			
 			particleBuffer.fill(particles);
@@ -843,11 +850,6 @@ int main(int argc, const char **argv) {
 			
 			memset(smokeIndices, 0, smokeIndexBuffer.getSize());
 		}
-		
-		ImGui::End();
-		gui.endGUI();
-		
-		core.endFrame(windowHandle);
 	}
 	
 	smokeIndexBuffer.unmap();
-- 
GitLab