mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2026-11-18 01:38:08 -06:00
DolphinQt: Fix crash from stale timer event in ToolTipWidget
LLM generated explaination for the LLM generated commit: A queued QTimerEvent can be dispatched after the timer was already killed (Qt recycles timer ids), e.g. when a slider is dragged and enter/leave events fire in rapid succession. In that case m_timer_id is empty and dereferencing it in timerEvent() asserts on 'this->_M_is_engaged()' in debug builds, while in release builds it passes a garbage timer id to killTimer(). Only process the event if it matches the timer we are tracking, which also prevents showing a balloon for a stale event.
This commit is contained in:
@@ -6,6 +6,7 @@
|
||||
#include <optional>
|
||||
|
||||
#include <QString>
|
||||
#include <QTimerEvent>
|
||||
|
||||
#include "DolphinQt/Config/ToolTipControls/BalloonTip.h"
|
||||
|
||||
@@ -57,12 +58,14 @@ private:
|
||||
|
||||
void timerEvent(QTimerEvent* const event) override
|
||||
{
|
||||
this->killTimer(*m_timer_id);
|
||||
m_timer_id.reset();
|
||||
|
||||
BalloonTip::ShowBalloon(m_title, m_description,
|
||||
this->parentWidget()->mapToGlobal(GetToolTipPosition()), this);
|
||||
if (m_timer_id == event->timerId())
|
||||
{
|
||||
this->killTimer(*m_timer_id);
|
||||
m_timer_id.reset();
|
||||
|
||||
BalloonTip::ShowBalloon(m_title, m_description,
|
||||
this->parentWidget()->mapToGlobal(GetToolTipPosition()), this);
|
||||
}
|
||||
Derived::timerEvent(event);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user