mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 12:38:12 +00:00
LibGUI: Make event receivers be weak pointers.
This commit is contained in:
parent
9624b54703
commit
95cfa49f1b
4 changed files with 23 additions and 24 deletions
|
@ -5,6 +5,7 @@
|
|||
#include <AK/HashMap.h>
|
||||
#include <AK/OwnPtr.h>
|
||||
#include <AK/Vector.h>
|
||||
#include <AK/WeakPtr.h>
|
||||
#include <WindowServer/WSAPITypes.h>
|
||||
|
||||
class GObject;
|
||||
|
@ -18,7 +19,7 @@ public:
|
|||
|
||||
int exec();
|
||||
|
||||
void post_event(GObject* receiver, OwnPtr<GEvent>&&);
|
||||
void post_event(GObject& receiver, OwnPtr<GEvent>&&);
|
||||
|
||||
static GEventLoop& main();
|
||||
|
||||
|
@ -56,7 +57,7 @@ private:
|
|||
void get_next_timer_expiration(timeval&);
|
||||
|
||||
struct QueuedEvent {
|
||||
GObject* receiver { nullptr };
|
||||
WeakPtr<GObject> receiver;
|
||||
OwnPtr<GEvent> event;
|
||||
};
|
||||
Vector<QueuedEvent> m_queued_events;
|
||||
|
@ -75,7 +76,7 @@ private:
|
|||
int interval { 0 };
|
||||
timeval fire_time;
|
||||
bool should_reload { false };
|
||||
GObject* owner { nullptr };
|
||||
WeakPtr<GObject> owner;
|
||||
|
||||
void reload();
|
||||
bool has_expired() const;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue