mirror of
https://github.com/fergalmoran/ladybird.git
synced 2026-01-06 16:45:03 +00:00
Kernel: Switch singletons to use new Singleton class
MemoryManager cannot use the Singleton class because MemoryManager::initialize is called before the global constructors are run. That caused the Singleton to be re-initialized, causing it to create another MemoryManager instance. Fixes #3226
This commit is contained in:
@@ -26,6 +26,7 @@
|
||||
|
||||
#include <AK/Assertions.h>
|
||||
#include <AK/ByteBuffer.h>
|
||||
#include <AK/Singleton.h>
|
||||
#include <AK/StringView.h>
|
||||
#include <AK/Types.h>
|
||||
#include <Kernel/Arch/i386/CPU.h>
|
||||
@@ -335,11 +336,15 @@ void KeyboardDevice::handle_irq(const RegisterState&)
|
||||
}
|
||||
}
|
||||
|
||||
static KeyboardDevice* s_the;
|
||||
static AK::Singleton<KeyboardDevice> s_the;
|
||||
|
||||
void KeyboardDevice::initialize()
|
||||
{
|
||||
s_the.ensure_instance();
|
||||
}
|
||||
|
||||
KeyboardDevice& KeyboardDevice::the()
|
||||
{
|
||||
ASSERT(s_the);
|
||||
return *s_the;
|
||||
}
|
||||
|
||||
@@ -347,8 +352,6 @@ KeyboardDevice::KeyboardDevice()
|
||||
: IRQHandler(IRQ_KEYBOARD)
|
||||
, CharacterDevice(85, 1)
|
||||
{
|
||||
s_the = this;
|
||||
|
||||
// Empty the buffer of any pending data.
|
||||
// I don't care what you've been pressing until now!
|
||||
while (IO::in8(I8042_STATUS) & I8042_BUFFER_FULL)
|
||||
|
||||
Reference in New Issue
Block a user