From 42981b421311f1cbb99620cfd323f9b533db7b71 Mon Sep 17 00:00:00 2001
From: Johannes Kung <johku144@student.liu.se>
Date: Mon, 10 Jun 2024 13:25:22 +0200
Subject: [PATCH] Fixed halt pop up

---
 src/simudator/gui/gui.py | 21 ++++++++-------------
 1 file changed, 8 insertions(+), 13 deletions(-)

diff --git a/src/simudator/gui/gui.py b/src/simudator/gui/gui.py
index 8e2348a..3169e88 100644
--- a/src/simudator/gui/gui.py
+++ b/src/simudator/gui/gui.py
@@ -487,19 +487,6 @@ class GUI(QMainWindow):
         if self.update_all_values:
             self.updateCpuListeners()
 
-        # If a breakpoint halted the program, inform the user
-        # Update other visuals and set the cpu to the correct state (not running)
-        if self.cpu.breakpoint_reached:
-            self.messageBox("Reached breakpoint: " + self.cpu.last_breakpoint.__str__())
-
-        # When the CPU is done we want to inform the user and update visuals
-        if self.cpu.should_halt():
-            # Only show halted message for larger steps that take time
-            # This is done so a user dosent have to close
-            # the message box after every small step
-            if steps > self.HALT_MESSAGE_THRESHOLD:
-                self.messageBox("The processor halted.")
-
         # A signal of 0 steps signifies end of execution, i.e. the CPU has 
         # halted or run the specified amount of ticks 
         # => Enable the relevant parts of the GUI again
@@ -508,6 +495,14 @@ class GUI(QMainWindow):
             self.setDisabledWhenRunning(False)
             self.updateCpuListeners()
 
+            # Inform user of reached break point
+            if self.cpu.breakpoint_reached:
+                self.messageBox("Reached breakpoint: " + self.cpu.last_breakpoint.__str__())
+
+            # Inform user of halt
+            if self.cpu.should_halt():
+                self.messageBox("The processor halted.")
+
     def stopToolBarButtonClick(self) -> None:
         """
         Tells the cpu to stop. It will then stop at an appropriate in its own thread.
-- 
GitLab