Merge PR #6510: FIX(client): Fix crash on mono pos. audio warning from audio thread

This commit is contained in:
Davide Beatrici 2024-08-20 19:22:09 +02:00 committed by GitHub
commit 4985b18d6b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 10 additions and 1 deletions

View File

@ -415,7 +415,7 @@ void AudioOutput::initializeMixer(const unsigned int *chanmasks, bool forceheadp
qWarning("AudioOutput: Initialized %d channel %d hz mixer", iChannels, iMixerFreq);
if (Global::get().s.bPositionalAudio && iChannels == 1) {
Global::get().l->logOrDefer(Log::Warning, tr("Positional audio cannot work with mono output devices!"));
Log::logOrDefer(Log::Warning, tr("Positional audio cannot work with mono output devices!"));
}
}

View File

@ -707,6 +707,15 @@ QString Log::validHtml(const QString &html, QTextCursor *tc) {
void Log::log(MsgType mt, const QString &console, const QString &terse, bool ownMessage, const QString &overrideTTS,
bool ignoreTTS) {
if (QThread::currentThread() != thread()) {
// Invoke in main thread in order to keep the Qt gods on our side by not calling any UI
// functions from a separate thread (can lead to program crashes)
QMetaObject::invokeMethod(this, "log", Qt::QueuedConnection, Q_ARG(Log::MsgType, mt),
Q_ARG(const QString &, console), Q_ARG(const QString &, terse),
Q_ARG(bool, ownMessage), Q_ARG(const QString &, overrideTTS), Q_ARG(bool, ignoreTTS));
return;
}
QDateTime dt = QDateTime::currentDateTime();
int ignore = qmIgnore.value(mt);