LibCore: Make EventReceiver ref counting use atomics

This removes a race in ImageDecoder's make_decode_image_job(), where the
ref count of `this` is mutated from separate threads in the callbacks.
This commit is contained in:
Andreas Kling 2024-12-26 11:50:25 +01:00 committed by Andreas Kling
parent 3913e9f948
commit 4eda7b5646
Notes: github-actions[bot] 2024-12-26 16:24:16 +00:00

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2021, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2018-2024, Andreas Kling <andreas@ladybird.org>
* Copyright (c) 2022, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
@ -7,6 +7,7 @@
#pragma once
#include <AK/AtomicRefCounted.h>
#include <AK/ByteString.h>
#include <AK/Forward.h>
#include <AK/Function.h>
@ -50,7 +51,7 @@ public: \
}
class EventReceiver
: public RefCounted<EventReceiver>
: public AtomicRefCounted<EventReceiver>
, public Weakable<EventReceiver> {
// NOTE: No C_OBJECT macro for Core::EventReceiver itself.