mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-09-11 05:25:32 +03:00
LibCore+Ladybird: Don't store timer_id in Core::TimerEvent
This commit is contained in:
parent
cdc0c9f094
commit
21097d1c9e
Notes:
sideshowbarker
2024-07-17 02:55:44 +09:00
Author: https://github.com/DanShaders Commit: https://github.com/SerenityOS/serenity/commit/21097d1c9e Pull-request: https://github.com/SerenityOS/serenity/pull/23149 Reviewed-by: https://github.com/ADKaster ✅
@ -72,7 +72,7 @@ int CFEventLoopManager::register_timer(Core::EventReceiver& receiver, int interv
|
||||
}
|
||||
}
|
||||
|
||||
Core::TimerEvent event(timer_id);
|
||||
Core::TimerEvent event;
|
||||
receiver->dispatch_event(event);
|
||||
});
|
||||
|
||||
|
@ -80,13 +80,13 @@ void EventLoopImplementationQt::post_event(Core::EventReceiver& receiver, Nonnul
|
||||
wake();
|
||||
}
|
||||
|
||||
static void qt_timer_fired(int timer_id, Core::TimerShouldFireWhenNotVisible should_fire_when_not_visible, Core::EventReceiver& object)
|
||||
static void qt_timer_fired(Core::TimerShouldFireWhenNotVisible should_fire_when_not_visible, Core::EventReceiver& object)
|
||||
{
|
||||
if (should_fire_when_not_visible == Core::TimerShouldFireWhenNotVisible::No) {
|
||||
if (!object.is_visible_for_timer_purposes())
|
||||
return;
|
||||
}
|
||||
Core::TimerEvent event(timer_id);
|
||||
Core::TimerEvent event;
|
||||
object.dispatch_event(event);
|
||||
}
|
||||
|
||||
@ -98,11 +98,11 @@ int EventLoopManagerQt::register_timer(Core::EventReceiver& object, int millisec
|
||||
timer->setSingleShot(!should_reload);
|
||||
auto timer_id = thread_data.timer_id_allocator.allocate();
|
||||
auto weak_object = object.make_weak_ptr();
|
||||
QObject::connect(timer, &QTimer::timeout, [timer_id, should_fire_when_not_visible, weak_object = move(weak_object)] {
|
||||
QObject::connect(timer, &QTimer::timeout, [should_fire_when_not_visible, weak_object = move(weak_object)] {
|
||||
auto object = weak_object.strong_ref();
|
||||
if (!object)
|
||||
return;
|
||||
qt_timer_fired(timer_id, should_fire_when_not_visible, *object);
|
||||
qt_timer_fired(should_fire_when_not_visible, *object);
|
||||
});
|
||||
timer->start();
|
||||
thread_data.timers.set(timer_id, move(timer));
|
||||
|
@ -66,17 +66,12 @@ private:
|
||||
|
||||
class TimerEvent final : public Event {
|
||||
public:
|
||||
explicit TimerEvent(int timer_id)
|
||||
explicit TimerEvent()
|
||||
: Event(Event::Timer)
|
||||
, m_timer_id(timer_id)
|
||||
{
|
||||
}
|
||||
|
||||
~TimerEvent() = default;
|
||||
|
||||
int timer_id() const { return m_timer_id; }
|
||||
|
||||
private:
|
||||
int m_timer_id;
|
||||
};
|
||||
|
||||
enum class NotificationType {
|
||||
|
@ -244,7 +244,7 @@ try_select_again:
|
||||
}
|
||||
|
||||
if (owner)
|
||||
ThreadEventQueue::current().post_event(*owner, make<TimerEvent>(timer.timer_id));
|
||||
ThreadEventQueue::current().post_event(*owner, make<TimerEvent>());
|
||||
if (timer.should_reload) {
|
||||
timer.reload(now);
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user