mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:37:35 +00:00
Ladybird: Allow posting events to the Qt event loop from other threads
Previously, a QTimer was used to start processing of our event queue in the main Qt event loop. Unfortunately, QTimers are not thread-safe, and disallow starting of a timer from a different thread than it was created in. Instead, use a dummy QObject to post a custom QEvent to the main loop from whatever thread we like, and process our event queue when it is received by our dummy object.
This commit is contained in:
parent
6131d879f7
commit
78e1defbfe
6 changed files with 72 additions and 7 deletions
22
Ladybird/EventLoopImplementationQtEventTarget.h
Normal file
22
Ladybird/EventLoopImplementationQtEventTarget.h
Normal file
|
@ -0,0 +1,22 @@
|
|||
/*
|
||||
* Copyright (c) 2023, Gregory Bertilson <zaggy1024@gmail.com>
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-2-Clause
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <QEvent>
|
||||
|
||||
#include "EventLoopImplementationQt.h"
|
||||
|
||||
namespace Ladybird {
|
||||
|
||||
class EventLoopImplementationQtEventTarget final : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual bool event(QEvent* event) override;
|
||||
};
|
||||
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue