Utils: fix crash on hiding a tooltip

Closing the tip label indirectly calls ToolTip::hideTipImmediately via
its eventFilter that closes the tool tip on any FocusIn/Out event on the
application. Since m_tip is reset in hideTipImmediately the outer call
crashes when this nullptr gets dereferenced. Avoid this crash by
resetting m_tip before closing the tip label.

Fixes: QTCREATORBUG-30738
Change-Id: Id3e690141be196db8ac6c4dab3d97627c0657140
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2024-04-25 10:01:29 +02:00
parent 8b682ac7f5
commit 7a47cf0a11

View File

@@ -288,9 +288,11 @@ void ToolTip::hideTipWithDelay()
void ToolTip::hideTipImmediately()
{
if (m_tip) {
m_tip->close();
m_tip->deleteLater();
m_tip = nullptr;
TipLabel *tip = m_tip.data();
m_tip.clear();
tip->close();
tip->deleteLater();
}
m_showTimer.stop();
m_hideDelayTimer.stop();