From a11681918aad2e6906790da7939db700488359fb Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Wed, 26 Oct 2022 19:20:32 +0200 Subject: [PATCH] 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. --- src/osd.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/osd.cpp b/src/osd.cpp index 01d8331c95..da62eca0cd 100644 --- a/src/osd.cpp +++ b/src/osd.cpp @@ -11,6 +11,7 @@ #include "workspace.h" #include +#include 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);