EventLoop: Don't destroy ID allocator (#1403)
The ID allocator is destroyed before a timer in HackStudio is is unregistered leading to an access violation. Fixes #1382.
This commit is contained in:
parent
e07f50c398
commit
81c6f72134
Notes:
sideshowbarker
2024-07-19 08:47:27 +09:00
Author: https://github.com/muscar Commit: https://github.com/SerenityOS/serenity/commit/81c6f72134e Pull-request: https://github.com/SerenityOS/serenity/pull/1403
1 changed files with 6 additions and 5 deletions
|
@ -28,6 +28,7 @@
|
|||
#include <AK/IDAllocator.h>
|
||||
#include <AK/JsonObject.h>
|
||||
#include <AK/JsonValue.h>
|
||||
#include <AK/NeverDestroyed.h>
|
||||
#include <AK/Time.h>
|
||||
#include <LibCore/Event.h>
|
||||
#include <LibCore/EventLoop.h>
|
||||
|
@ -73,7 +74,7 @@ struct EventLoop::Private {
|
|||
|
||||
static EventLoop* s_main_event_loop;
|
||||
static Vector<EventLoop*>* s_event_loop_stack;
|
||||
static IDAllocator s_id_allocator;
|
||||
static NeverDestroyed<IDAllocator> s_id_allocator;
|
||||
static HashMap<int, NonnullOwnPtr<EventLoopTimer>>* s_timers;
|
||||
static HashTable<Notifier*>* s_notifiers;
|
||||
int EventLoop::s_wake_pipe_fds[2];
|
||||
|
@ -85,7 +86,7 @@ class RPCClient : public Object {
|
|||
public:
|
||||
explicit RPCClient(RefPtr<LocalSocket> socket)
|
||||
: m_socket(move(socket))
|
||||
, m_client_id(s_id_allocator.allocate())
|
||||
, m_client_id(s_id_allocator->allocate())
|
||||
{
|
||||
s_rpc_clients.set(m_client_id, this);
|
||||
add_child(*m_socket);
|
||||
|
@ -201,7 +202,7 @@ public:
|
|||
void shutdown()
|
||||
{
|
||||
s_rpc_clients.remove(m_client_id);
|
||||
s_id_allocator.deallocate(m_client_id);
|
||||
s_id_allocator->deallocate(m_client_id);
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -524,7 +525,7 @@ int EventLoop::register_timer(Object& object, int milliseconds, bool should_relo
|
|||
timer->reload(now);
|
||||
timer->should_reload = should_reload;
|
||||
timer->fire_when_not_visible = fire_when_not_visible;
|
||||
int timer_id = s_id_allocator.allocate();
|
||||
int timer_id = s_id_allocator->allocate();
|
||||
timer->timer_id = timer_id;
|
||||
s_timers->set(timer_id, move(timer));
|
||||
return timer_id;
|
||||
|
@ -532,7 +533,7 @@ int EventLoop::register_timer(Object& object, int milliseconds, bool should_relo
|
|||
|
||||
bool EventLoop::unregister_timer(int timer_id)
|
||||
{
|
||||
s_id_allocator.deallocate(timer_id);
|
||||
s_id_allocator->deallocate(timer_id);
|
||||
auto it = s_timers->find(timer_id);
|
||||
if (it == s_timers->end())
|
||||
return false;
|
||||
|
|
Loading…
Add table
Reference in a new issue