Test for nullptr before dereferencing the screen

Touch event processing might still be ongoing even after the screen
has been disconnected. If that screen was also the primary screen, we
would dereference nullptr.

Check for nullptr to avoid potential crashes during shutdown.

Fixes: QTBUG-95192
Pick-to: 6.2 5.15
Change-Id: I49ccd30c4126fe12cf5bb675e532e6e59b40b9c1
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
This commit is contained in:
Volker Hilsheimer 2021-12-07 14:36:33 +01:00
parent e65c29fffc
commit 30b0b72453
2 changed files with 2 additions and 2 deletions

View File

@ -757,7 +757,7 @@ QRect QEvdevTouchScreenData::screenGeometry() const
if (m_screen)
screen = m_screen;
}
return QHighDpi::toNativePixels(screen->geometry(), screen);
return screen ? QHighDpi::toNativePixels(screen->geometry(), screen) : QRect();
}
void QEvdevTouchScreenData::reportPoints()

View File

@ -84,7 +84,7 @@ QRect QLibInputTouch::screenGeometry(DeviceState *state)
if (m_screen)
screen = m_screen;
}
return QHighDpi::toNativePixels(screen->geometry(), screen);
return screen ? QHighDpi::toNativePixels(screen->geometry(), screen) : QRect();
}
QPointF QLibInputTouch::getPos(libinput_event_touch *e)