diff options
author | Konstantin Ritt <ritt.ks@gmail.com> | 2015-02-15 02:44:54 +0400 |
---|---|---|
committer | Konstantin Ritt <ritt.ks@gmail.com> | 2015-02-20 00:20:26 +0000 |
commit | 4429f7510c61b35ee38d6abe3bc925e8d388d842 (patch) | |
tree | d1b5a21ba4d34a02fe2a50785cddb59666caf374 /src/plugins/platforms | |
parent | 1214e59e734f689cf738f8e6f0964555f4433505 (diff) |
Guarantee there is always a valid HFONT to get metrics for
Change-Id: I69d72803f994a5455b607c4f94f87c1c782eb0a4
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
Diffstat (limited to 'src/plugins/platforms')
-rw-r--r-- | src/plugins/platforms/windows/qwindowsfontdatabase.cpp | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index ef74ef35f5..56adae8ffb 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -1674,8 +1674,10 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, HFONT hfont = 0; hfont = CreateFontIndirect(&lf); - if (!hfont) + if (!hfont) { qErrnoWarning("%s: CreateFontIndirect failed", __FUNCTION__); + hfont = QWindowsFontDatabase::systemFont(); + } bool ttf = false; int avWidth = 0; @@ -1689,18 +1691,17 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request, SelectObject(data->hdc, oldObj); if (!useDirectWrite) { - if (hfont && (!ttf || request.stretch != 100)) { + if (!ttf || request.stretch != 100) { DeleteObject(hfont); if (!res) qErrnoWarning("%s: GetTextMetrics failed", __FUNCTION__); lf.lfWidth = avWidth * request.stretch/100; hfont = CreateFontIndirect(&lf); - if (!hfont) + if (!hfont) { qErrnoWarning("%s: CreateFontIndirect with stretch failed", __FUNCTION__); + hfont = QWindowsFontDatabase::systemFont(); + } } - - if (!hfont) - hfont = QWindowsFontDatabase::systemFont(); } #if !defined(QT_NO_DIRECTWRITE) |