From ece0c0a5e7e0b18beb58ccd868bde54c7be64f78 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Fri, 22 Nov 2019 14:46:58 +0100 Subject: Tidy nullptr usage Move away from using 0 as pointer literal. Done using clang-tidy. This is not complete as run-clang-tidy can't handle all of qtbase in one go. Change-Id: I1076a21f32aac0dab078af6f175f7508145eece0 Reviewed-by: Friedemann Kleint Reviewed-by: Lars Knoll --- src/gui/text/qfontengine.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) (limited to 'src/gui/text/qfontengine.cpp') diff --git a/src/gui/text/qfontengine.cpp b/src/gui/text/qfontengine.cpp index 1668fac5a3..3ca9e9bbde 100644 --- a/src/gui/text/qfontengine.cpp +++ b/src/gui/text/qfontengine.cpp @@ -221,7 +221,7 @@ static bool qt_get_font_table_default(void *user_data, uint tag, uchar *buffer, #ifdef QT_BUILD_INTERNAL // for testing purpose only, not thread-safe! -static QList *enginesCollector = 0; +static QList *enginesCollector = nullptr; Q_AUTOTEST_EXPORT void QFontEngine_startCollectingEngines() { @@ -234,7 +234,7 @@ Q_AUTOTEST_EXPORT QList QFontEngine_stopCollectingEngines() Q_ASSERT(enginesCollector); QList ret = *enginesCollector; delete enginesCollector; - enginesCollector = 0; + enginesCollector = nullptr; return ret; } #endif // QT_BUILD_INTERNAL @@ -569,9 +569,9 @@ void QFontEngine::getGlyphPositions(const QGlyphLayout &glyphs, const QTransform void QFontEngine::getGlyphBearings(glyph_t glyph, qreal *leftBearing, qreal *rightBearing) { glyph_metrics_t gi = boundingBox(glyph); - if (leftBearing != 0) + if (leftBearing != nullptr) *leftBearing = gi.leftBearing().toReal(); - if (rightBearing != 0) + if (rightBearing != nullptr) *rightBearing = gi.rightBearing().toReal(); } @@ -1022,7 +1022,7 @@ QByteArray QFontEngine::getSfntTable(uint tag) const { QByteArray table; uint len = 0; - if (!getSfntTableData(tag, 0, &len)) + if (!getSfntTableData(tag, nullptr, &len)) return table; table.resize(len); if (!getSfntTableData(tag, reinterpret_cast(table.data()), &len)) @@ -1231,11 +1231,11 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy // version check quint16 version; if (!qSafeFromBigEndian(header, endPtr, &version) || version != 0) - return 0; + return nullptr; quint16 numTables; if (!qSafeFromBigEndian(header + 2, endPtr, &numTables)) - return 0; + return nullptr; const uchar *maps = table + 4; @@ -1255,11 +1255,11 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy for (int n = 0; n < numTables; ++n) { quint16 platformId; if (!qSafeFromBigEndian(maps + 8 * n, endPtr, &platformId)) - return 0; + return nullptr; quint16 platformSpecificId = 0; if (!qSafeFromBigEndian(maps + 8 * n + 2, endPtr, &platformSpecificId)) - return 0; + return nullptr; switch (platformId) { case 0: // Unicode @@ -1309,38 +1309,38 @@ const uchar *QFontEngine::getCMap(const uchar *table, uint tableSize, bool *isSy } } if(tableToUse < 0) - return 0; + return nullptr; resolveTable: *isSymbolFont = (symbolTable > -1); quint32 unicode_table = 0; if (!qSafeFromBigEndian(maps + 8 * tableToUse + 4, endPtr, &unicode_table)) - return 0; + return nullptr; if (!unicode_table) - return 0; + return nullptr; // get the header of the unicode table header = table + unicode_table; quint16 format; if (!qSafeFromBigEndian(header, endPtr, &format)) - return 0; + return nullptr; quint32 length; if (format < 8) { quint16 tmp; if (!qSafeFromBigEndian(header + 2, endPtr, &tmp)) - return 0; + return nullptr; length = tmp; } else { if (!qSafeFromBigEndian(header + 4, endPtr, &length)) - return 0; + return nullptr; } if (table + unicode_table + length > endPtr) - return 0; + return nullptr; *cmapSize = length; // To support symbol fonts that contain a unicode table for the symbol area @@ -1844,7 +1844,7 @@ QFontEngine *QFontEngineMulti::loadEngine(int at) return engine; } - return 0; + return nullptr; } glyph_t QFontEngineMulti::glyphIndex(uint ucs4) const @@ -1865,7 +1865,7 @@ glyph_t QFontEngineMulti::glyphIndex(uint ucs4) const const_cast(this)->ensureEngineAt(x); engine = m_engines.at(x); } - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == Box) continue; @@ -1934,7 +1934,7 @@ bool QFontEngineMulti::stringToCMap(const QChar *str, int len, if (!engine) continue; } - Q_ASSERT(engine != 0); + Q_ASSERT(engine != nullptr); if (engine->type() == Box) continue; @@ -2308,7 +2308,7 @@ QImage QFontEngineMulti::alphaRGBMapForGlyph(glyph_t glyph, QFixed subPixelPosit */ QFontEngine *QFontEngineMulti::createMultiFontEngine(QFontEngine *fe, int script) { - QFontEngine *engine = 0; + QFontEngine *engine = nullptr; QFontCache::Key key(fe->fontDef, script, /*multi = */true); QFontCache *fc = QFontCache::instance(); // We can't rely on the fontDef (and hence the cache Key) -- cgit v1.2.3