summaryrefslogtreecommitdiffstats
path: root/src/plugins
diff options
context:
space:
mode:
authorKonstantin Ritt <ritt.ks@gmail.com>2014-11-24 06:53:02 +0400
committerKonstantin Ritt <ritt.ks@gmail.com>2015-02-02 21:36:32 +0000
commitd6e117e1d8b1b39311a5042fde762c475e884326 (patch)
tree69c3291b6988ae84be670e373432161c7e89e47a /src/plugins
parentbaaf8f0156c9b02f6091460e53f2793c3502d3a5 (diff)
Don't remember if passed HFONT was a stock object
According to GetStockObject() function docs at MSDN: > It is not necessary (but it is not harmful) to delete > stock objects by calling DeleteObject. Change-Id: I755dc84c8b86ba2806e97ae41b3025aa3e633ae7 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r--src/plugins/platforms/windows/qwindowsfontdatabase.cpp12
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.cpp17
-rw-r--r--src/plugins/platforms/windows/qwindowsfontengine.h3
3 files changed, 9 insertions, 23 deletions
diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
index c5fd910fb0..724d0e7aaf 100644
--- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp
@@ -1675,7 +1675,6 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
- bool stockFont = false;
bool preferClearTypeAA = false;
HFONT hfont = 0;
@@ -1696,7 +1695,6 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
if (!hfont)
qErrnoWarning("%s: CreateFontIndirect failed", __FUNCTION__);
- stockFont = (hfont == 0);
bool ttf = false;
int avWidth = 0;
BOOL res;
@@ -1720,15 +1718,11 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
}
#ifndef Q_OS_WINCE
- if (hfont == 0) {
+ if (hfont == 0)
hfont = (HFONT)GetStockObject(ANSI_VAR_FONT);
- stockFont = true;
- }
#else
- if (hfont == 0) {
+ if (hfont == 0)
hfont = (HFONT)GetStockObject(SYSTEM_FONT);
- stockFont = true;
- }
#endif
}
@@ -1762,7 +1756,7 @@ QFontEngine *QWindowsFontDatabase::createEngine(const QFontDef &request,
QFontEngine *fe = 0;
if (!useDirectWrite) {
- QWindowsFontEngine *few = new QWindowsFontEngine(request.family, hfont, stockFont, lf, data);
+ QWindowsFontEngine *few = new QWindowsFontEngine(request.family, hfont, lf, data);
if (preferClearTypeAA)
few->glyphFormat = QFontEngine::Format_A32;
few->initFontInfo(request, dpi);
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.cpp b/src/plugins/platforms/windows/qwindowsfontengine.cpp
index 33600766d8..6df07a7c67 100644
--- a/src/plugins/platforms/windows/qwindowsfontengine.cpp
+++ b/src/plugins/platforms/windows/qwindowsfontengine.cpp
@@ -264,14 +264,13 @@ int QWindowsFontEngine::getGlyphIndexes(const QChar *str, int numChars, QGlyphLa
*/
QWindowsFontEngine::QWindowsFontEngine(const QString &name,
- HFONT _hfont, bool stockFontIn, LOGFONT lf,
+ HFONT _hfont, LOGFONT lf,
const QSharedPointer<QWindowsFontEngineData> &fontEngineData)
: QFontEngine(Win),
m_fontEngineData(fontEngineData),
_name(name),
hfont(_hfont),
m_logfont(lf),
- stockFont(stockFontIn),
ttf(0),
hasOutline(0),
lw(0),
@@ -325,10 +324,8 @@ QWindowsFontEngine::~QWindowsFontEngine()
// make sure we aren't by accident still selected
SelectObject(m_fontEngineData->hdc, (HFONT)GetStockObject(SYSTEM_FONT));
- if (!stockFont) {
- if (!DeleteObject(hfont))
- qErrnoWarning("%s: QFontEngineWin: failed to delete non-stock font... failed", __FUNCTION__);
- }
+ if (!DeleteObject(hfont))
+ qErrnoWarning("%s: QFontEngineWin: failed to delete font...", __FUNCTION__);
qCDebug(lcQpaFonts) << __FUNCTION__ << _name;
if (!uniqueFamilyName.isEmpty()) {
@@ -1365,14 +1362,10 @@ QFontEngine *QWindowsMultiFontEngine::loadEngine(int at)
// Get here if original font is not DirectWrite or DirectWrite creation failed for some
// reason
HFONT hfont = CreateFontIndirect(&lf);
-
- bool stockFont = false;
- if (hfont == 0) {
+ if (hfont == 0)
hfont = (HFONT)GetStockObject(ANSI_VAR_FONT);
- stockFont = true;
- }
- return new QWindowsFontEngine(fam, hfont, stockFont, lf, data);
+ return new QWindowsFontEngine(fam, hfont, lf, data);
}
bool QWindowsFontEngine::supportsTransformation(const QTransform &transform) const
diff --git a/src/plugins/platforms/windows/qwindowsfontengine.h b/src/plugins/platforms/windows/qwindowsfontengine.h
index cb496a59f1..5b412eba78 100644
--- a/src/plugins/platforms/windows/qwindowsfontengine.h
+++ b/src/plugins/platforms/windows/qwindowsfontengine.h
@@ -63,7 +63,7 @@ class QWindowsFontEngine : public QFontEngine
friend class QWindowsMultiFontEngine;
public:
- QWindowsFontEngine(const QString &name, HFONT, bool, LOGFONT,
+ QWindowsFontEngine(const QString &name, HFONT hfont, LOGFONT lf,
const QSharedPointer<QWindowsFontEngineData> &fontEngineData);
~QWindowsFontEngine();
@@ -139,7 +139,6 @@ private:
QString uniqueFamilyName;
const HFONT hfont;
const LOGFONT m_logfont;
- uint stockFont : 1;
uint ttf : 1;
uint hasOutline : 1;
uint hasUnreliableOutline : 1;