From 813ab817057f6d27883d1ba393b8ff3233d3653d Mon Sep 17 00:00:00 2001 From: Martin <martin.hogstedt@hotmail.com> Date: Fri, 5 Jul 2024 09:35:58 +0200 Subject: [PATCH] fixed index out of range error in the memory graphic module by removing hard coded value and replacing it with the correct dynamic value --- .../gui/module_graphics_item/integer_memory_graphic.py | 2 +- src/simudator/gui/module_graphics_item/memory_graphic.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/simudator/gui/module_graphics_item/integer_memory_graphic.py b/src/simudator/gui/module_graphics_item/integer_memory_graphic.py index a177b62..c746c08 100644 --- a/src/simudator/gui/module_graphics_item/integer_memory_graphic.py +++ b/src/simudator/gui/module_graphics_item/integer_memory_graphic.py @@ -248,6 +248,6 @@ class IntegerMemoryTable(MemoryTable): # -7 + 16 % 16 = 9 = 1001 = -7 value = (value + max_value) % max_value - index = row * 4 + col + index = row * self._column_size + col state['memory'][index] = value self._memory.set_state(state) diff --git a/src/simudator/gui/module_graphics_item/memory_graphic.py b/src/simudator/gui/module_graphics_item/memory_graphic.py index c4a944d..1016a3b 100644 --- a/src/simudator/gui/module_graphics_item/memory_graphic.py +++ b/src/simudator/gui/module_graphics_item/memory_graphic.py @@ -35,7 +35,7 @@ class MemoryWindow(QWidget): An instance of the Memory base class. edit_buttons: bool A bool deciding whether or not to add buttons to the widget - for toggling between setting the memory contents to + for toggling between setting the memory contents to editable or not. """ @@ -196,7 +196,7 @@ class MemoryTable(QTableWidget): value = item.text() if value == "": return - index = row * 4 + col + index = row * self._column_size + col state['memory'][index] = value self._memory.set_state(state) -- GitLab