OSD: Fix OSD::show from the non-main thread

If it's issued from a different thread, pass it to the main one so it's
eventually displayed.
Otherwise, it would just crash kwin.
This commit is contained in:
Aleix Pol 2022-10-26 19:20:32 +02:00 committed by Aleix Pol Gonzalez
parent af983dba42
commit a11681918a

View file

@ -11,6 +11,7 @@
#include "workspace.h"
#include <QQmlEngine>
#include <QThread>
namespace KWin
{
@ -37,6 +38,14 @@ void show(const QString &message, const QString &iconName, int timeout)
// FIXME: only supported on Wayland
return;
}
if (QThread::currentThread() != qGuiApp->thread()) {
QTimer::singleShot(0, QCoreApplication::instance(), [message, iconName, timeout] {
show(message, iconName, timeout);
});
return;
}
auto notification = osd();
notification->setIconName(iconName);
notification->setMessage(message);