mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 20:25:07 +00:00
LibCore+Ladybird: Don't store timer_id in Core::TimerEvent
This commit is contained in:
parent
cdc0c9f094
commit
21097d1c9e
4 changed files with 8 additions and 13 deletions
|
@ -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);
|
receiver->dispatch_event(event);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -80,13 +80,13 @@ void EventLoopImplementationQt::post_event(Core::EventReceiver& receiver, Nonnul
|
||||||
wake();
|
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 (should_fire_when_not_visible == Core::TimerShouldFireWhenNotVisible::No) {
|
||||||
if (!object.is_visible_for_timer_purposes())
|
if (!object.is_visible_for_timer_purposes())
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Core::TimerEvent event(timer_id);
|
Core::TimerEvent event;
|
||||||
object.dispatch_event(event);
|
object.dispatch_event(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,11 +98,11 @@ int EventLoopManagerQt::register_timer(Core::EventReceiver& object, int millisec
|
||||||
timer->setSingleShot(!should_reload);
|
timer->setSingleShot(!should_reload);
|
||||||
auto timer_id = thread_data.timer_id_allocator.allocate();
|
auto timer_id = thread_data.timer_id_allocator.allocate();
|
||||||
auto weak_object = object.make_weak_ptr();
|
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();
|
auto object = weak_object.strong_ref();
|
||||||
if (!object)
|
if (!object)
|
||||||
return;
|
return;
|
||||||
qt_timer_fired(timer_id, should_fire_when_not_visible, *object);
|
qt_timer_fired(should_fire_when_not_visible, *object);
|
||||||
});
|
});
|
||||||
timer->start();
|
timer->start();
|
||||||
thread_data.timers.set(timer_id, move(timer));
|
thread_data.timers.set(timer_id, move(timer));
|
||||||
|
|
|
@ -66,17 +66,12 @@ private:
|
||||||
|
|
||||||
class TimerEvent final : public Event {
|
class TimerEvent final : public Event {
|
||||||
public:
|
public:
|
||||||
explicit TimerEvent(int timer_id)
|
explicit TimerEvent()
|
||||||
: Event(Event::Timer)
|
: Event(Event::Timer)
|
||||||
, m_timer_id(timer_id)
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
~TimerEvent() = default;
|
~TimerEvent() = default;
|
||||||
|
|
||||||
int timer_id() const { return m_timer_id; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
int m_timer_id;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class NotificationType {
|
enum class NotificationType {
|
||||||
|
|
|
@ -244,7 +244,7 @@ try_select_again:
|
||||||
}
|
}
|
||||||
|
|
||||||
if (owner)
|
if (owner)
|
||||||
ThreadEventQueue::current().post_event(*owner, make<TimerEvent>(timer.timer_id));
|
ThreadEventQueue::current().post_event(*owner, make<TimerEvent>());
|
||||||
if (timer.should_reload) {
|
if (timer.should_reload) {
|
||||||
timer.reload(now);
|
timer.reload(now);
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue