Assert that engine isn't nullptr before dereferencing
Various checks for "engine" in the previous code suggested that engine might be nullptr by the time we want to populate the out-parameters. This must not be the case, and QFontDatabase::load asserts already that a valid engine is loaded and returned. Fix static analyzer warning 7f68daa282c72e8cc172c681eb02f559 by asserting it here as well. As a drive-by, change the tested out-parameter to the last one in the list of optional parameters. Pick-to: 6.1 Change-Id: I3d9ff0f5f7c4740014301c073480d14fef54e2fb Reviewed-by: Jonas Karlsson <jonas.karlsson@qt.io> Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
parent
777053cfff
commit
6c3599460c
@ -2351,8 +2351,8 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix
|
|||||||
font = font.resolve(fnt);
|
font = font.resolve(fnt);
|
||||||
}
|
}
|
||||||
engine = font.d->engineForScript(script);
|
engine = font.d->engineForScript(script);
|
||||||
if (engine)
|
Q_ASSERT(engine);
|
||||||
engine->ref.ref();
|
engine->ref.ref();
|
||||||
|
|
||||||
QTextCharFormat::VerticalAlignment valign = f.verticalAlignment();
|
QTextCharFormat::VerticalAlignment valign = f.verticalAlignment();
|
||||||
if (valign == QTextCharFormat::AlignSuperScript || valign == QTextCharFormat::AlignSubScript) {
|
if (valign == QTextCharFormat::AlignSuperScript || valign == QTextCharFormat::AlignSubScript) {
|
||||||
@ -2382,9 +2382,8 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix
|
|||||||
engine = feCache.prevFontEngine;
|
engine = feCache.prevFontEngine;
|
||||||
else {
|
else {
|
||||||
engine = font.d->engineForScript(script);
|
engine = font.d->engineForScript(script);
|
||||||
|
Q_ASSERT(engine);
|
||||||
if (engine)
|
engine->ref.ref();
|
||||||
engine->ref.ref();
|
|
||||||
if (feCache.prevFontEngine)
|
if (feCache.prevFontEngine)
|
||||||
releaseCachedFontEngine(feCache.prevFontEngine);
|
releaseCachedFontEngine(feCache.prevFontEngine);
|
||||||
feCache.prevFontEngine = engine;
|
feCache.prevFontEngine = engine;
|
||||||
@ -2402,7 +2401,10 @@ QFontEngine *QTextEngine::fontEngine(const QScriptItem &si, QFixed *ascent, QFix
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ascent) {
|
if (leading) {
|
||||||
|
Q_ASSERT(engine);
|
||||||
|
Q_ASSERT(ascent);
|
||||||
|
Q_ASSERT(descent);
|
||||||
*ascent = engine->ascent();
|
*ascent = engine->ascent();
|
||||||
*descent = engine->descent();
|
*descent = engine->descent();
|
||||||
*leading = engine->leading();
|
*leading = engine->leading();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user