mirror of
https://github.com/hyprwm/Hyprland
synced 2024-11-22 20:45:59 +01:00
eventloop: don't call lost timers
This commit is contained in:
parent
375e77e398
commit
2bcc8d303f
2 changed files with 5 additions and 1 deletions
|
@ -31,7 +31,7 @@ void CEventLoopManager::enterLoop(wl_display* display, wl_event_loop* wlEventLoo
|
||||||
|
|
||||||
void CEventLoopManager::onTimerFire() {
|
void CEventLoopManager::onTimerFire() {
|
||||||
for (auto& t : m_sTimers.timers) {
|
for (auto& t : m_sTimers.timers) {
|
||||||
if (t->passed() && !t->cancelled())
|
if (t.strongRef() > 1 /* if it's 1, it was lost. Don't call it. */ && t->passed() && !t->cancelled())
|
||||||
t->call(t);
|
t->call(t);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,6 +62,8 @@ static void timespecAddNs(timespec* pTimespec, int64_t delta) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void CEventLoopManager::nudgeTimers() {
|
void CEventLoopManager::nudgeTimers() {
|
||||||
|
// remove timers that have gone missing
|
||||||
|
std::erase_if(m_sTimers.timers, [](const auto& t) { return t.strongRef() <= 1; });
|
||||||
|
|
||||||
long nextTimerUs = 10 * 1000 * 1000; // 10s
|
long nextTimerUs = 10 * 1000 * 1000; // 10s
|
||||||
|
|
||||||
|
|
|
@ -12,6 +12,8 @@ class CEventLoopManager {
|
||||||
CEventLoopManager();
|
CEventLoopManager();
|
||||||
|
|
||||||
void enterLoop(wl_display* display, wl_event_loop* wlEventLoop);
|
void enterLoop(wl_display* display, wl_event_loop* wlEventLoop);
|
||||||
|
|
||||||
|
// Note: will remove the timer if the ptr is lost.
|
||||||
void addTimer(SP<CEventLoopTimer> timer);
|
void addTimer(SP<CEventLoopTimer> timer);
|
||||||
void removeTimer(SP<CEventLoopTimer> timer);
|
void removeTimer(SP<CEventLoopTimer> timer);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue