diff --git a/Userland/Libraries/LibCore/EventLoop.cpp b/Userland/Libraries/LibCore/EventLoop.cpp index 43200a1ef3..eb1b745294 100644 --- a/Userland/Libraries/LibCore/EventLoop.cpp +++ b/Userland/Libraries/LibCore/EventLoop.cpp @@ -374,8 +374,17 @@ bool connect_to_inspector_server() #endif } +#define VERIFY_EVENT_LOOP_INITIALIZED() \ + do { \ + if (!s_event_loop_stack) { \ + warnln("EventLoop static API was called without prior EventLoop init!"); \ + VERIFY_NOT_REACHED(); \ + } \ + } while (0) + EventLoop& EventLoop::current() { + VERIFY_EVENT_LOOP_INITIALIZED(); return s_event_loop_stack->last(); } @@ -628,6 +637,7 @@ void EventLoop::unregister_signal(int handler_id) void EventLoop::notify_forked(ForkEvent event) { + VERIFY_EVENT_LOOP_INITIALIZED(); switch (event) { case ForkEvent::Child: s_main_event_loop.with_locked([]([[maybe_unused]] auto*& main_event_loop) { main_event_loop = nullptr; }); @@ -815,6 +825,7 @@ Optional