fix(core): 修复网络模块子线程未及时销毁导致的程序崩溃

This commit is contained in:
DLmaster361
2025-06-01 19:52:22 +08:00
parent 4725a30165
commit 2d72ca66a4
7 changed files with 50 additions and 21 deletions

View File

@@ -41,27 +41,26 @@ class _SoundPlayer(QObject):
self.sounds_path = Config.app_path / "resources/sounds"
def play(self, sound_name: str, parent: QObject = None):
def play(self, sound_name: str):
if not Config.get(Config.voice_Enabled):
return
if (self.sounds_path / f"both/{sound_name}.wav").exists():
self.play_voice(self.sounds_path / f"both/{sound_name}.wav", parent)
self.play_voice(self.sounds_path / f"both/{sound_name}.wav")
elif (
self.sounds_path / Config.get(Config.voice_Type) / f"{sound_name}.wav"
).exists():
self.play_voice(
self.sounds_path / Config.get(Config.voice_Type) / f"{sound_name}.wav",
parent,
self.sounds_path / Config.get(Config.voice_Type) / f"{sound_name}.wav"
)
def play_voice(self, sound_path: Path, parent: QObject):
def play_voice(self, sound_path: Path):
effect = QSoundEffect(self if parent is None else parent)
effect = QSoundEffect(self)
effect.setVolume(1)
effect.setSource(QUrl.fromLocalFile(sound_path))
effect.play()