From d0ccb791f7e6946679dff7db7998ffaaf8e2fe0c Mon Sep 17 00:00:00 2001 From: LemonNexus Date: Sun, 15 Feb 2026 00:47:10 +0000 Subject: [PATCH] fix: Fix hotkey thread-safety issue in Skill Scanner BUG: TypeError when using F12 hotkey - invokeMethod syntax was wrong for PyQt6. FIX: 1. Added hotkey_triggered = pyqtSignal() at class level 2. Connected signal to _scan_page_for_multi in initialize() 3. _hotkey_scan() now just emits the signal (thread-safe) 4. Signal ensures scan runs on main Qt thread This is the proper Qt way to handle cross-thread communication. The hotkey callback runs in keyboard library's thread, but the scan must run in Qt's main thread to update UI safely. --- plugins/skill_scanner/plugin.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/plugins/skill_scanner/plugin.py b/plugins/skill_scanner/plugin.py index bb724c6..f4690aa 100644 --- a/plugins/skill_scanner/plugin.py +++ b/plugins/skill_scanner/plugin.py @@ -150,6 +150,9 @@ class SkillScannerPlugin(BasePlugin): description = "Uses core OCR and Log services" hotkey = "ctrl+shift+s" + # Signal for thread-safe hotkey scanning + hotkey_triggered = pyqtSignal() + def initialize(self): """Setup skill scanner.""" self.data_file = Path("data/skill_tracker.json") @@ -164,6 +167,9 @@ class SkillScannerPlugin(BasePlugin): self.current_scan_session = {} # Skills collected in current multi-page scan self.pages_scanned = 0 + # Connect hotkey signal + self.hotkey_triggered.connect(self._scan_page_for_multi) + # Subscribe to skill gain events from core Log service try: from core.plugin_api import get_api @@ -756,12 +762,9 @@ class SkillScannerPlugin(BasePlugin): self.auto_scan_active = False def _hotkey_scan(self): - """Scan triggered by F12 hotkey.""" - from PyQt6.QtCore import QMetaObject, Qt, Q_ARG - QMetaObject.invokeMethod( - self, "_scan_page_for_multi", - Qt.ConnectionType.QueuedConnection - ) + """Scan triggered by F12 hotkey - thread safe via signal.""" + # Emit signal to safely call from hotkey thread + self.hotkey_triggered.emit() def _check_for_page_change(self): """Auto-detect page changes by monitoring page number area."""