From efabf55eae2d4b41db09c2cd9baf704ce45a9794 Mon Sep 17 00:00:00 2001 From: jknapp Date: Sat, 3 Jan 2026 17:57:12 -0800 Subject: [PATCH] Fix macro not executing correctly on first run after save MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The commands list was stored as a shallow copy, meaning the individual command dicts were shared references with the CommandBuilder widget. When the dialog closed, these shared objects could be affected. Fix: Use copy.deepcopy() when storing commands in add_macro() and update_macro() to ensure the macro manager has its own independent copy of all command data. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 --- macro_manager.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/macro_manager.py b/macro_manager.py index cfda352..a180a58 100644 --- a/macro_manager.py +++ b/macro_manager.py @@ -1,5 +1,6 @@ # Macro management and execution with command sequence support +import copy import json import os import uuid @@ -163,11 +164,11 @@ class MacroManager: # Process image if provided image_path_reference = self._process_image(image_path) if image_path else "" - # Create macro data + # Create macro data (deep copy commands to avoid reference issues) macro_data = { "name": name, "type": "sequence", - "commands": commands, + "commands": copy.deepcopy(commands), "category": category, "image_path": image_path_reference, "last_used": 0 @@ -197,11 +198,11 @@ class MacroManager: else: image_path_reference = macro.get("image_path", "") - # Update macro data + # Update macro data (deep copy commands to avoid reference issues) self.macros[macro_id] = { "name": name, "type": "sequence", - "commands": commands, + "commands": copy.deepcopy(commands), "category": category, "image_path": image_path_reference, "last_used": macro.get("last_used", 0)