From 834202aeb9a47c544ab4e61deb813de50bc03946 Mon Sep 17 00:00:00 2001 From: Timothy Flynn Date: Tue, 10 Jan 2023 06:28:20 -0500 Subject: LibWeb: Move setting of Web object prototypes to initialize() This needs to happen before prototype/constructor intitialization can be made lazy. Otherwise, GC could run during the C++ constructor and try to collect the object currently being created. --- Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp | 7 ++++++- Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'Userland/Libraries/LibWeb/RequestIdleCallback') diff --git a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp index 9fa2c62674..b0d6fb123d 100644 --- a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp +++ b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.cpp @@ -21,7 +21,12 @@ IdleDeadline::IdleDeadline(JS::Realm& realm, bool did_timeout) : PlatformObject(realm) , m_did_timeout(did_timeout) { - set_prototype(&Bindings::cached_web_prototype(realm, "IdleDeadline")); +} + +void IdleDeadline::initialize(JS::Realm& realm) +{ + Base::initialize(realm); + set_prototype(&Bindings::ensure_web_prototype(realm, "IdleDeadline")); } IdleDeadline::~IdleDeadline() = default; diff --git a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h index 23d546889b..d703a9c620 100644 --- a/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h +++ b/Userland/Libraries/LibWeb/RequestIdleCallback/IdleDeadline.h @@ -24,6 +24,8 @@ public: private: IdleDeadline(JS::Realm&, bool did_timeout); + virtual void initialize(JS::Realm&) override; + bool m_did_timeout { false }; }; -- cgit v1.2.3