mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00:00
Ladybird+LibCore: Use QCoreApplication to drive the main Qt event loop
Using QEventLoop works for everything but it breaks *one* little feature that we care about: automatically quitting the app when all windows have been closed. That only works if you drive the outermost main event loop with a QCoreApplication instead of a QEventLoop. This is unfortunate, as it complicates our API a little bit, but I'm sure we can think of a way to make this nicer someday. In order for QCoreApplication::exec() to process our own ThreadEventQueue, we now have a zero-timer that we kick whenever new events are posted to the thread queue.
This commit is contained in:
parent
0f22dfa634
commit
c21eb30a2b
9 changed files with 79 additions and 25 deletions
|
@ -35,6 +35,8 @@ public:
|
|||
virtual void register_notifier(Core::Notifier&) override;
|
||||
virtual void unregister_notifier(Core::Notifier&) override;
|
||||
|
||||
virtual void did_post_event() override;
|
||||
|
||||
// FIXME: These APIs only exist for obscure use-cases inside SerenityOS. Try to get rid of them.
|
||||
virtual void unquit() override { }
|
||||
virtual bool was_exit_requested() const override { return false; }
|
||||
|
@ -42,12 +44,15 @@ public:
|
|||
virtual int register_signal(int, Function<void(int)>) override { return 0; }
|
||||
virtual void unregister_signal(int) override { }
|
||||
|
||||
protected:
|
||||
EventLoopImplementationQt();
|
||||
void set_main_loop() { m_main_loop = true; }
|
||||
|
||||
private:
|
||||
EventLoopImplementationQt();
|
||||
bool is_main_loop() const { return m_main_loop; }
|
||||
|
||||
QEventLoop m_event_loop;
|
||||
Optional<int> m_exit_code;
|
||||
QTimer m_process_core_events_timer;
|
||||
bool m_main_loop { false };
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue