This commit is contained in:
2026-04-12 12:09:13 +02:00
parent 88a3d2f67b
commit 564122df0a
2 changed files with 22 additions and 11 deletions

View File

@@ -397,13 +397,8 @@ class MainWindow(QMainWindow):
from local.file_watcher import get_watcher
def on_file_change(event_type, path, song_id):
# QMetaObject.invokeMethod er den korrekte måde at kalde
# en slot fra en ikke-GUI-tråd
from PyQt6.QtCore import QMetaObject, Qt
QMetaObject.invokeMethod(
self._reload_timer, "start",
Qt.ConnectionType.QueuedConnection
)
# Brug signal — den eneste 100% thread-safe metode på Windows
self._file_changed_signal.emit()
watcher = get_watcher(on_change=on_file_change)
watcher.start()
@@ -436,7 +431,8 @@ class MainWindow(QMainWindow):
QTimer.singleShot(200, self._reload_library)
# Signal til at opdatere biblioteket fra baggrundstråd
_library_loaded = __import__('PyQt6.QtCore', fromlist=['pyqtSignal']).pyqtSignal(list)
_library_loaded = __import__('PyQt6.QtCore', fromlist=['pyqtSignal']).pyqtSignal(list)
_file_changed_signal = __import__('PyQt6.QtCore', fromlist=['pyqtSignal']).pyqtSignal()
def _reload_library(self):
"""Hent sange fra DB i baggrundstråd — thread-safe via signal."""