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:
parent
af983dba42
commit
a11681918a
1 changed files with 9 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue