macOS: Add logging of screen add/remove/changes

Change-Id: Ic9c9ac307441dde98bb43d656466a03805746917
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
This commit is contained in:
Tor Arne Vestbø 2017-10-26 10:06:10 +02:00
parent 2b7cf045bf
commit 8ba1f91d4e
3 changed files with 27 additions and 0 deletions

View File

@ -222,6 +222,8 @@ QCocoaIntegration::Options QCocoaIntegration::options() const
return mOptions;
}
Q_LOGGING_CATEGORY(lcCocoaScreen, "qt.qpa.cocoa.screens");
/*!
\brief Synchronizes the screen list, adds new screens, removes deleted ones
*/
@ -261,9 +263,11 @@ void QCocoaIntegration::updateScreens()
if (screen) {
remainingScreens.remove(screen);
screen->updateGeometry();
qCDebug(lcCocoaScreen) << "Updated properties of" << screen;
} else {
screen = new QCocoaScreen(i);
mScreens.append(screen);
qCDebug(lcCocoaScreen) << "Adding" << screen;
screenAdded(screen);
}
siblings << screen;
@ -280,6 +284,7 @@ void QCocoaIntegration::updateScreens()
mScreens.removeOne(screen);
// Prevent stale references to NSScreen during destroy
screen->m_screenIndex = -1;
qCDebug(lcCocoaScreen) << "Removing" << screen;
destroyScreen(screen);
}
}

View File

@ -102,6 +102,10 @@ public:
QList<QPlatformScreen *> m_siblings;
};
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug debug, const QCocoaScreen *screen);
#endif
QT_END_NAMESPACE
#endif

View File

@ -275,4 +275,22 @@ QCocoaScreen *QCocoaScreen::primaryScreen()
return static_cast<QCocoaScreen *>(QGuiApplication::primaryScreen()->handle());
}
#ifndef QT_NO_DEBUG_STREAM
QDebug operator<<(QDebug debug, const QCocoaScreen *screen)
{
QDebugStateSaver saver(debug);
debug.nospace();
debug << "QCocoaScreen(" << (const void *)screen;
if (screen) {
debug << ", index=" << screen->m_screenIndex;
debug << ", native=" << screen->nativeScreen();
debug << ", geometry=" << screen->geometry();
debug << ", dpr=" << screen->devicePixelRatio();
debug << ", name=" << screen->name();
}
debug << ')';
return debug;
}
#endif // !QT_NO_DEBUG_STREAM
QT_END_NAMESPACE