mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 20:37:34 +00:00
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
1 changed files with 6 additions and 5 deletions
|
@ -28,6 +28,7 @@
|
||||||
#include <AK/IDAllocator.h>
|
#include <AK/IDAllocator.h>
|
||||||
#include <AK/JsonObject.h>
|
#include <AK/JsonObject.h>
|
||||||
#include <AK/JsonValue.h>
|
#include <AK/JsonValue.h>
|
||||||
|
#include <AK/NeverDestroyed.h>
|
||||||
#include <AK/Time.h>
|
#include <AK/Time.h>
|
||||||
#include <LibCore/Event.h>
|
#include <LibCore/Event.h>
|
||||||
#include <LibCore/EventLoop.h>
|
#include <LibCore/EventLoop.h>
|
||||||
|
@ -73,7 +74,7 @@ struct EventLoop::Private {
|
||||||
|
|
||||||
static EventLoop* s_main_event_loop;
|
static EventLoop* s_main_event_loop;
|
||||||
static Vector<EventLoop*>* s_event_loop_stack;
|
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 HashMap<int, NonnullOwnPtr<EventLoopTimer>>* s_timers;
|
||||||
static HashTable<Notifier*>* s_notifiers;
|
static HashTable<Notifier*>* s_notifiers;
|
||||||
int EventLoop::s_wake_pipe_fds[2];
|
int EventLoop::s_wake_pipe_fds[2];
|
||||||
|
@ -85,7 +86,7 @@ class RPCClient : public Object {
|
||||||
public:
|
public:
|
||||||
explicit RPCClient(RefPtr<LocalSocket> socket)
|
explicit RPCClient(RefPtr<LocalSocket> socket)
|
||||||
: m_socket(move(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);
|
s_rpc_clients.set(m_client_id, this);
|
||||||
add_child(*m_socket);
|
add_child(*m_socket);
|
||||||
|
@ -201,7 +202,7 @@ public:
|
||||||
void shutdown()
|
void shutdown()
|
||||||
{
|
{
|
||||||
s_rpc_clients.remove(m_client_id);
|
s_rpc_clients.remove(m_client_id);
|
||||||
s_id_allocator.deallocate(m_client_id);
|
s_id_allocator->deallocate(m_client_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -524,7 +525,7 @@ int EventLoop::register_timer(Object& object, int milliseconds, bool should_relo
|
||||||
timer->reload(now);
|
timer->reload(now);
|
||||||
timer->should_reload = should_reload;
|
timer->should_reload = should_reload;
|
||||||
timer->fire_when_not_visible = fire_when_not_visible;
|
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;
|
timer->timer_id = timer_id;
|
||||||
s_timers->set(timer_id, move(timer));
|
s_timers->set(timer_id, move(timer));
|
||||||
return timer_id;
|
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)
|
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);
|
auto it = s_timers->find(timer_id);
|
||||||
if (it == s_timers->end())
|
if (it == s_timers->end())
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue