macOS: Ignore update requests for offline displays

Accessing a display that's offline may cause crashes,
so to be on the safe side we skip update requests in
this situation.

Task-number: QTBUG-102021
Change-Id: I6b48b6722bccde628e510c538943d14f2b0271e5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 5909e33d1dea34daef271598eb1c9dd06a238801)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2022-06-13 15:03:56 +02:00 committed by Qt Cherry-pick Bot
parent 68f1d34a77
commit 2933c7effc

View File

@ -280,6 +280,11 @@ void QCocoaScreen::requestUpdate()
{ {
Q_ASSERT(m_displayId); Q_ASSERT(m_displayId);
if (!isOnline()) {
qCDebug(lcQpaScreenUpdates) << this << "is not online. Ignoring update request";
return;
}
if (!m_displayLink) { if (!m_displayLink) {
CVDisplayLinkCreateWithCGDisplay(m_displayId, &m_displayLink); CVDisplayLinkCreateWithCGDisplay(m_displayId, &m_displayLink);
CVDisplayLinkSetOutputCallback(m_displayLink, [](CVDisplayLinkRef, const CVTimeStamp*, CVDisplayLinkSetOutputCallback(m_displayLink, [](CVDisplayLinkRef, const CVTimeStamp*,