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.
This commit is contained in:
parent
e132a80f2b
commit
d0ccb791f7
|
|
@ -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."""
|
||||
|
|
|
|||
Loading…
Reference in New Issue