diff options
author | Timothy Flynn <trflynn89@pm.me> | 2023-03-18 10:39:37 -0400 |
---|---|---|
committer | Jelle Raaijmakers <jelle@gmta.nl> | 2023-03-18 19:50:45 +0100 |
commit | db2ba5f1d9234b51a547ce01c3da8ecd5006ee87 (patch) | |
tree | f373c2bbafe8b1f52724eec7b90ad42883537e53 /Userland/Libraries/LibWeb/HTML/EventNames.cpp | |
parent | 0d0b87fd46453e533e6f73a7fd3c13fc9655e85c (diff) | |
download | serenity-db2ba5f1d9234b51a547ce01c3da8ecd5006ee87.zip |
LibWeb: Initialize static web strings during main-thread VM creation
These are currently initialized in a [[gnu::constructor]], which has a
weird initialization order. These constructors are invoked before main()
and, incidentally, before any user-defined default constructors of the
static strings they are initializing.
This will become an issue when these strings are ported to FlyString,
which has a user-defined default constructor. In that scenario, when the
FlyString constructor is executed after the [[gnu::constructor]], the
strings will be "reset" to the empty string.
Instead of relying on a non-standard compiler extension here, let's just
initialize these strings explicitly during main-thread VM creation, as
this now happens in WebContent's main().
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/EventNames.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/EventNames.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/EventNames.cpp b/Userland/Libraries/LibWeb/HTML/EventNames.cpp index f0c0d2e58d..2824b90778 100644 --- a/Userland/Libraries/LibWeb/HTML/EventNames.cpp +++ b/Userland/Libraries/LibWeb/HTML/EventNames.cpp @@ -12,11 +12,10 @@ namespace Web::HTML::EventNames { ENUMERATE_HTML_EVENTS #undef __ENUMERATE_HTML_EVENT -[[gnu::constructor]] static void initialize() +ErrorOr<void> initialize_strings() { static bool s_initialized = false; - if (s_initialized) - return; + VERIFY(!s_initialized); #define __ENUMERATE_HTML_EVENT(name) \ name = #name; @@ -24,6 +23,7 @@ ENUMERATE_HTML_EVENTS #undef __ENUMERATE_HTML_EVENT s_initialized = true; + return {}; } } |