Fix QHighDPiScaling initialization issues

Call QHighDpiScaling::updateHighDpiScaling() in init_plaform(),
after the platform integration has been created and most platforms
have populated the screen list. Keep the existing udpate call for
the platforms that don't, but guard against calling it twice.

Task-number: QTBUG-47947
Change-Id: Ib73bea7c4ab42e7acf6532f3a3100e1fc29acc2c
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@theqtcompany.com>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@theqtcompany.com>
This commit is contained in:
Morten Johan Sørvig 2015-10-02 15:56:04 +02:00
parent a681b90418
commit 45bb9c29e8
2 changed files with 14 additions and 3 deletions

View File

@ -129,6 +129,8 @@ QWindow *QGuiApplicationPrivate::currentMouseWindow = 0;
Qt::ApplicationState QGuiApplicationPrivate::applicationState = Qt::ApplicationInactive;
bool QGuiApplicationPrivate::highDpiScalingUpdated = false;
QPlatformIntegration *QGuiApplicationPrivate::platform_integration = 0;
QPlatformTheme *QGuiApplicationPrivate::platform_theme = 0;
@ -1051,6 +1053,13 @@ static void init_platform(const QString &pluginArgument, const QString &platform
return;
}
// Many platforms have created QScreens at this point. Finish initializing
// QHighDpiScaling to be prepared for early calls to qt_defaultDpi().
if (QGuiApplication::primaryScreen()) {
QGuiApplicationPrivate::highDpiScalingUpdated = true;
QHighDpiScaling::updateHighDpiScaling();
}
// Create the platform theme:
// 1) Fetch the platform name from the environment if present.
@ -1220,9 +1229,10 @@ void QGuiApplicationPrivate::eventDispatcherReady()
platform_integration->initialize();
// Do this here in order to play nice with platforms that add screens only
// in initialize().
QHighDpiScaling::updateHighDpiScaling();
// All platforms should have added screens at this point. Finish
// QHighDpiScaling initialization if it has not been done so already.
if (!QGuiApplicationPrivate::highDpiScalingUpdated)
QHighDpiScaling::updateHighDpiScaling();
}
void QGuiApplicationPrivate::init()

View File

@ -202,6 +202,7 @@ public:
static QWindow *currentMouseWindow;
static QWindow *currentMousePressWindow;
static Qt::ApplicationState applicationState;
static bool highDpiScalingUpdated;
#ifndef QT_NO_CLIPBOARD
static QClipboard *qt_clipboard;