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/image/qbmphandler.cpp | 4 +- src/gui/image/qicon.cpp | 16 ++++---- src/gui/image/qiconloader.cpp | 2 +- src/gui/image/qimage.cpp | 46 +++++++++++------------ src/gui/image/qimage_conversions.cpp | 8 ++-- src/gui/image/qimageiohandler.cpp | 2 +- src/gui/image/qimagereader.cpp | 12 +++--- src/gui/image/qimagereaderwriterhelpers.cpp | 6 +-- src/gui/image/qimagewriter.cpp | 14 +++---- src/gui/image/qmovie.cpp | 2 +- src/gui/image/qpaintengine_pic.cpp | 6 +-- src/gui/image/qpicture.cpp | 22 +++++------ src/gui/image/qpixmap.cpp | 6 +-- src/gui/image/qpixmap_blitter.cpp | 8 ++-- src/gui/image/qpixmapcache.cpp | 14 +++---- src/gui/image/qplatformpixmap.cpp | 2 +- src/gui/image/qpnghandler.cpp | 58 ++++++++++++++--------------- src/gui/image/qxpmhandler.cpp | 4 +- 18 files changed, 116 insertions(+), 116 deletions(-) (limited to 'src/gui/image') diff --git a/src/gui/image/qbmphandler.cpp b/src/gui/image/qbmphandler.cpp index 7f8e072322..32b6131309 100644 --- a/src/gui/image/qbmphandler.cpp +++ b/src/gui/image/qbmphandler.cpp @@ -414,7 +414,7 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset, *p++ = tmp >> 4; } if ((((c & 3) + 1) & 2) == 2) - d->getChar(0); // align on word boundary + d->getChar(nullptr); // align on word boundary x += c; } } else { // encoded mode @@ -494,7 +494,7 @@ static bool read_dib_body(QDataStream &s, const BMP_INFOHDR &bi, qint64 offset, if (d->read((char *)p, b) != b) return false; if ((b & 1) == 1) - d->getChar(0); // align on word boundary + d->getChar(nullptr); // align on word boundary x += b; p += b; } diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index 84e387e317..19be066d23 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -132,7 +132,7 @@ static void qt_cleanup_icon_cache() if Qt::AA_UseHighDpiPixmaps is not set this function returns 1.0 to keep non-hihdpi aware code working. */ -static qreal qt_effective_device_pixel_ratio(QWindow *window = 0) +static qreal qt_effective_device_pixel_ratio(QWindow *window = nullptr) { if (!qApp->testAttribute(Qt::AA_UseHighDpiPixmaps)) return qreal(1.0); @@ -228,7 +228,7 @@ static QPixmapIconEngineEntry *bestSizeMatch( const QSize &size, QPixmapIconEngi QPixmapIconEngineEntry *QPixmapIconEngine::tryMatch(const QSize &size, QIcon::Mode mode, QIcon::State state) { - QPixmapIconEngineEntry *pe = 0; + QPixmapIconEngineEntry *pe = nullptr; for (int i = 0; i < pixmaps.count(); ++i) if (pixmaps.at(i).mode == mode && pixmaps.at(i).state == state) { if (pe) @@ -674,7 +674,7 @@ QFactoryLoader *qt_iconEngineFactoryLoader() Constructs a null icon. */ QIcon::QIcon() noexcept - : d(0) + : d(nullptr) { } @@ -682,7 +682,7 @@ QIcon::QIcon() noexcept Constructs an icon from a \a pixmap. */ QIcon::QIcon(const QPixmap &pixmap) - :d(0) + :d(nullptr) { addPixmap(pixmap); } @@ -723,7 +723,7 @@ QIcon::QIcon(const QIcon &other) complete list of the supported file formats. */ QIcon::QIcon(const QString &fileName) - : d(0) + : d(nullptr) { addFile(fileName); } @@ -838,7 +838,7 @@ QPixmap QIcon::pixmap(const QSize &size, Mode mode, State state) const { if (!d) return QPixmap(); - return pixmap(0, size, mode, state); + return pixmap(nullptr, size, mode, state); } /*! @@ -878,7 +878,7 @@ QSize QIcon::actualSize(const QSize &size, Mode mode, State state) const { if (!d) return QSize(); - return actualSize(0, size, mode, state); + return actualSize(nullptr, size, mode, state); } /*! @@ -1008,7 +1008,7 @@ void QIcon::detach() if (d->engine->isNull()) { if (!d->ref.deref()) delete d; - d = 0; + d = nullptr; return; } else if (d->ref.loadRelaxed() != 1) { QIconPrivate *x = new QIconPrivate(d->engine->clone()); diff --git a/src/gui/image/qiconloader.cpp b/src/gui/image/qiconloader.cpp index 27c82bc09f..e67b387981 100644 --- a/src/gui/image/qiconloader.cpp +++ b/src/gui/image/qiconloader.cpp @@ -714,7 +714,7 @@ QIconLoaderEngineEntry *QIconLoaderEngine::entryForSize(const QThemeIconInfo &in // Find the minimum distance icon int minimalSize = INT_MAX; - QIconLoaderEngineEntry *closestMatch = 0; + QIconLoaderEngineEntry *closestMatch = nullptr; for (int i = 0; i < numEntries; ++i) { QIconLoaderEngineEntry *entry = info.entries.at(i); int distance = directorySizeDistance(entry->dir, iconsize, scale); diff --git a/src/gui/image/qimage.cpp b/src/gui/image/qimage.cpp index 869e206524..99d64737c5 100644 --- a/src/gui/image/qimage.cpp +++ b/src/gui/image/qimage.cpp @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE static inline bool isLocked(QImageData *data) { - return data != 0 && data->is_locked; + return data != nullptr && data->is_locked; } #if defined(Q_CC_DEC) && defined(__alpha) && (__DECCXX_VER-0 >= 50190001) @@ -99,15 +99,15 @@ static int next_qimage_serial_number() } QImageData::QImageData() - : ref(0), width(0), height(0), depth(0), nbytes(0), devicePixelRatio(1.0), data(0), + : ref(0), width(0), height(0), depth(0), nbytes(0), devicePixelRatio(1.0), data(nullptr), format(QImage::Format_ARGB32), bytes_per_line(0), ser_no(next_qimage_serial_number()), detach_no(0), dpmx(qt_defaultDpiX() * 100 / qreal(2.54)), dpmy(qt_defaultDpiY() * 100 / qreal(2.54)), offset(0, 0), own_data(true), ro_data(false), has_alpha_clut(false), - is_cached(false), is_locked(false), cleanupFunction(0), cleanupInfo(0), - paintEngine(0) + is_cached(false), is_locked(false), cleanupFunction(nullptr), cleanupInfo(nullptr), + paintEngine(nullptr) { } @@ -170,7 +170,7 @@ QImageData::~QImageData() delete paintEngine; if (data && own_data) free(data); - data = 0; + data = nullptr; } #if defined(_M_ARM) @@ -746,7 +746,7 @@ bool QImageData::checkForAlphaPixels() const QImage::QImage() noexcept : QPaintDevice() { - d = 0; + d = nullptr; } /*! @@ -955,7 +955,7 @@ QImage::QImage(const uchar *data, int width, int height, int bytesPerLine, Forma QImage::QImage(const QString &fileName, const char *format) : QPaintDevice() { - d = 0; + d = nullptr; load(fileName, format); } @@ -981,10 +981,10 @@ extern bool qt_read_xpm_image_or_array(QIODevice *device, const char * const *so QImage::QImage(const char * const xpm[]) : QPaintDevice() { - d = 0; + d = nullptr; if (!xpm) return; - if (!qt_read_xpm_image_or_array(0, xpm, *this)) + if (!qt_read_xpm_image_or_array(nullptr, xpm, *this)) // Issue: Warning because the constructor may be ambigious qWarning("QImage::QImage(), XPM is not supported"); } @@ -1003,7 +1003,7 @@ QImage::QImage(const QImage &image) : QPaintDevice() { if (image.paintingActive() || isLocked(image.d)) { - d = 0; + d = nullptr; image.copy().swap(*this); } else { d = image.d; @@ -1593,13 +1593,13 @@ void QImage::setColor(int i, QRgb c) uchar *QImage::scanLine(int i) { if (!d) - return 0; + return nullptr; detach(); // In case detach() ran out of memory if (!d) - return 0; + return nullptr; return d->data + i * d->bytes_per_line; } @@ -1610,7 +1610,7 @@ uchar *QImage::scanLine(int i) const uchar *QImage::scanLine(int i) const { if (!d) - return 0; + return nullptr; Q_ASSERT(i >= 0 && i < height()); return d->data + i * d->bytes_per_line; @@ -1633,7 +1633,7 @@ const uchar *QImage::scanLine(int i) const const uchar *QImage::constScanLine(int i) const { if (!d) - return 0; + return nullptr; Q_ASSERT(i >= 0 && i < height()); return d->data + i * d->bytes_per_line; @@ -1653,12 +1653,12 @@ const uchar *QImage::constScanLine(int i) const uchar *QImage::bits() { if (!d) - return 0; + return nullptr; detach(); // In case detach ran out of memory... if (!d) - return 0; + return nullptr; return d->data; } @@ -1672,7 +1672,7 @@ uchar *QImage::bits() */ const uchar *QImage::bits() const { - return d ? d->data : 0; + return d ? d->data : nullptr; } @@ -1688,7 +1688,7 @@ const uchar *QImage::bits() const */ const uchar *QImage::constBits() const { - return d ? d->data : 0; + return d ? d->data : nullptr; } /*! @@ -3027,11 +3027,11 @@ QImage QImage::createHeuristicMask(bool clipTight) const while(!done) { done = true; ypn = m.scanLine(0); - ypc = 0; + ypc = nullptr; for (y = 0; y < h; y++) { ypp = ypc; ypc = ypn; - ypn = (y == h-1) ? 0 : m.scanLine(y+1); + ypn = (y == h-1) ? nullptr : m.scanLine(y+1); const QRgb *p = (const QRgb *)scanLine(y); for (x = 0; x < w; x++) { // slowness here - it's possible to do six of these tests @@ -3053,11 +3053,11 @@ QImage QImage::createHeuristicMask(bool clipTight) const if (!clipTight) { ypn = m.scanLine(0); - ypc = 0; + ypc = nullptr; for (y = 0; y < h; y++) { ypp = ypc; ypc = ypn; - ypn = (y == h-1) ? 0 : m.scanLine(y+1); + ypn = (y == h-1) ? nullptr : m.scanLine(y+1); const QRgb *p = (const QRgb *)scanLine(y); for (x = 0; x < w; x++) { if ((*p & 0x00ffffff) != background) { @@ -4122,7 +4122,7 @@ void QImage::setText(const QString &key, const QString &value) QPaintEngine *QImage::paintEngine() const { if (!d) - return 0; + return nullptr; if (!d->paintEngine) { QPaintDevice *paintDevice = const_cast(this); diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index 8f33a13b95..27088698ec 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -198,7 +198,7 @@ void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversio store = destLayout->storeFromRGB32; } QDitherInfo dither; - QDitherInfo *ditherPtr = 0; + QDitherInfo *ditherPtr = nullptr; if ((flags & Qt::PreferDither) && (flags & Qt::Dither_Mask) != Qt::ThresholdDither) ditherPtr = &dither; @@ -212,8 +212,8 @@ void convert_generic(QImageData *dest, const QImageData *src, Qt::ImageConversio buffer = reinterpret_cast(destData) + x; else l = qMin(l, BufferSize); - const uint *ptr = fetch(buffer, srcData, x, l, 0, ditherPtr); - store(destData, ptr, x, l, 0, ditherPtr); + const uint *ptr = fetch(buffer, srcData, x, l, nullptr, ditherPtr); + store(destData, ptr, x, l, nullptr, ditherPtr); x += l; } srcData += src->bytes_per_line; @@ -314,7 +314,7 @@ bool convert_generic_inplace(QImageData *data, QImage::Format dst_format, Qt::Im store = destLayout->storeFromRGB32; } QDitherInfo dither; - QDitherInfo *ditherPtr = 0; + QDitherInfo *ditherPtr = nullptr; if ((flags & Qt::PreferDither) && (flags & Qt::Dither_Mask) != Qt::ThresholdDither) ditherPtr = &dither; diff --git a/src/gui/image/qimageiohandler.cpp b/src/gui/image/qimageiohandler.cpp index a4f927a462..0c9083a16e 100644 --- a/src/gui/image/qimageiohandler.cpp +++ b/src/gui/image/qimageiohandler.cpp @@ -288,7 +288,7 @@ public: QImageIOHandlerPrivate::QImageIOHandlerPrivate(QImageIOHandler *q) { - device = 0; + device = nullptr; q_ptr = q; } diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index dff24b449a..5e3b608d20 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -179,10 +179,10 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, bool ignoresFormatAndExtension) { if (!autoDetectImageFormat && format.isEmpty()) - return 0; + return nullptr; QByteArray form = format.toLower(); - QImageIOHandler *handler = 0; + QImageIOHandler *handler = nullptr; QByteArray suffix; #ifndef QT_NO_IMAGEFORMATPLUGIN @@ -450,7 +450,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, qDebug("QImageReader::createReadHandler: no handlers found. giving up."); #endif // no handler: give up. - return 0; + return nullptr; } handler->setDevice(device); @@ -500,9 +500,9 @@ public: QImageReaderPrivate::QImageReaderPrivate(QImageReader *qq) : autoDetectImageFormat(true), ignoresFormatAndExtension(false) { - device = 0; + device = nullptr; deleteDevice = false; - handler = 0; + handler = nullptr; quality = -1; imageReaderError = QImageReader::UnknownError; autoTransform = UsePluginDefault; @@ -571,7 +571,7 @@ bool QImageReaderPrivate::initHandler() } // assign a handler - if (!handler && (handler = createReadHandlerHelper(device, format, autoDetectImageFormat, ignoresFormatAndExtension)) == 0) { + if (!handler && (handler = createReadHandlerHelper(device, format, autoDetectImageFormat, ignoresFormatAndExtension)) == nullptr) { imageReaderError = QImageReader::UnsupportedFormatError; errorString = QImageReader::tr("Unsupported image format"); return false; diff --git a/src/gui/image/qimagereaderwriterhelpers.cpp b/src/gui/image/qimagereaderwriterhelpers.cpp index a5b7fb6449..dd56d887a7 100644 --- a/src/gui/image/qimagereaderwriterhelpers.cpp +++ b/src/gui/image/qimagereaderwriterhelpers.cpp @@ -63,7 +63,7 @@ static void appendImagePluginFormats(QFactoryLoader *loader, const PluginKeyMap keyMap = loader->keyMap(); const PluginKeyMapConstIterator cend = keyMap.constEnd(); int i = -1; - QImageIOPlugin *plugin = 0; + QImageIOPlugin *plugin = nullptr; result->reserve(result->size() + keyMap.size()); for (PluginKeyMapConstIterator it = keyMap.constBegin(); it != cend; ++it) { if (it.key() != i) { @@ -71,7 +71,7 @@ static void appendImagePluginFormats(QFactoryLoader *loader, plugin = qobject_cast(loader->instance(i)); } const QByteArray key = it.value().toLatin1(); - if (plugin && (plugin->capabilities(0, key) & cap) != 0) + if (plugin && (plugin->capabilities(nullptr, key) & cap) != 0) result->append(key); } } @@ -92,7 +92,7 @@ static void appendImagePluginMimeTypes(QFactoryLoader *loader, const int keyCount = keys.size(); for (int k = 0; k < keyCount; ++k) { const QByteArray key = keys.at(k).toString().toLatin1(); - if (plugin && (plugin->capabilities(0, key) & cap) != 0) { + if (plugin && (plugin->capabilities(nullptr, key) & cap) != 0) { result->append(mimeTypes.at(k).toString().toLatin1()); if (resultKeys) resultKeys->append(key); diff --git a/src/gui/image/qimagewriter.cpp b/src/gui/image/qimagewriter.cpp index ec66588ddf..9dcc955fe2 100644 --- a/src/gui/image/qimagewriter.cpp +++ b/src/gui/image/qimagewriter.cpp @@ -139,7 +139,7 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device, { QByteArray form = format.toLower(); QByteArray suffix; - QImageIOHandler *handler = 0; + QImageIOHandler *handler = nullptr; #ifndef QT_NO_IMAGEFORMATPLUGIN typedef QMultiMap PluginKeyMap; @@ -226,7 +226,7 @@ static QImageIOHandler *createWriteHandlerHelper(QIODevice *device, #endif // QT_NO_IMAGEFORMATPLUGIN if (!handler) - return 0; + return nullptr; handler->setDevice(device); if (!testFormat.isEmpty()) @@ -270,9 +270,9 @@ public: */ QImageWriterPrivate::QImageWriterPrivate(QImageWriter *qq) { - device = 0; + device = nullptr; deleteDevice = false; - handler = 0; + handler = nullptr; quality = -1; compression = -1; gamma = 0.0; @@ -304,7 +304,7 @@ bool QImageWriterPrivate::canWriteHelper() errorString = QImageWriter::tr("Device not writable"); return false; } - if (!handler && (handler = createWriteHandlerHelper(device, format)) == 0) { + if (!handler && (handler = createWriteHandlerHelper(device, format)) == nullptr) { imageWriterError = QImageWriter::UnsupportedFormatError; errorString = QImageWriter::tr("Unsupported image format"); return false; @@ -403,7 +403,7 @@ void QImageWriter::setDevice(QIODevice *device) d->device = device; d->deleteDevice = false; delete d->handler; - d->handler = 0; + d->handler = nullptr; } /*! @@ -823,7 +823,7 @@ QString QImageWriter::errorString() const */ bool QImageWriter::supportsOption(QImageIOHandler::ImageOption option) const { - if (!d->handler && (d->handler = createWriteHandlerHelper(d->device, d->format)) == 0) { + if (!d->handler && (d->handler = createWriteHandlerHelper(d->device, d->format)) == nullptr) { d->imageWriterError = QImageWriter::UnsupportedFormatError; d->errorString = QImageWriter::tr("Unsupported image format"); return false; diff --git a/src/gui/image/qmovie.cpp b/src/gui/image/qmovie.cpp index 25fce050a1..79019d0fdf 100644 --- a/src/gui/image/qmovie.cpp +++ b/src/gui/image/qmovie.cpp @@ -272,7 +272,7 @@ public: /*! \internal */ QMoviePrivate::QMoviePrivate(QMovie *qq) - : reader(0), speed(100), movieState(QMovie::NotRunning), + : reader(nullptr), speed(100), movieState(QMovie::NotRunning), currentFrameNumber(-1), nextFrameNumber(0), greatestFrameNumber(-1), nextDelay(0), playCounter(-1), cacheMode(QMovie::CacheNone), haveReadAll(false), isFirstIteration(true) diff --git a/src/gui/image/qpaintengine_pic.cpp b/src/gui/image/qpaintengine_pic.cpp index 6a87a01a87..e89cac452a 100644 --- a/src/gui/image/qpaintengine_pic.cpp +++ b/src/gui/image/qpaintengine_pic.cpp @@ -73,14 +73,14 @@ QPicturePaintEngine::QPicturePaintEngine() : QPaintEngine(*(new QPicturePaintEnginePrivate), AllFeatures) { Q_D(QPicturePaintEngine); - d->pt = 0; + d->pt = nullptr; } QPicturePaintEngine::QPicturePaintEngine(QPaintEnginePrivate &dptr) : QPaintEngine(dptr, AllFeatures) { Q_D(QPicturePaintEngine); - d->pt = 0; + d->pt = nullptr; } QPicturePaintEngine::~QPicturePaintEngine() @@ -484,7 +484,7 @@ void QPicturePaintEngine::drawTextItem(const QPointF &p , const QTextItem &ti) #endif const QTextItemInt &si = static_cast(ti); - if (si.chars == 0) + if (si.chars == nullptr) QPaintEngine::drawTextItem(p, ti); // Draw as path if (d->pic_d->formatMajor >= 9) { diff --git a/src/gui/image/qpicture.cpp b/src/gui/image/qpicture.cpp index 978a07b9f9..3a32cc7f15 100644 --- a/src/gui/image/qpicture.cpp +++ b/src/gui/image/qpicture.cpp @@ -458,7 +458,7 @@ public: QFakeDevice() { dpi_x = qt_defaultDpiX(); dpi_y = qt_defaultDpiY(); } void setDpiX(int dpi) { dpi_x = dpi; } void setDpiY(int dpi) { dpi_y = dpi; } - QPaintEngine *paintEngine() const override { return 0; } + QPaintEngine *paintEngine() const override { return nullptr; } int metric(PaintDeviceMetric m) const override { switch(m) { @@ -709,11 +709,11 @@ bool QPicture::exec(QPainter *painter, QDataStream &s, int nrecords) QFontMetrics fm(fnt); QPointF pt(p.x(), p.y() - fm.ascent()); - qt_format_text(fnt, QRectF(pt, size), flags, /*opt*/0, - str, /*brect=*/0, /*tabstops=*/0, /*...*/0, /*tabarraylen=*/0, painter); + qt_format_text(fnt, QRectF(pt, size), flags, /*opt*/nullptr, + str, /*brect=*/nullptr, /*tabstops=*/0, /*...*/nullptr, /*tabarraylen=*/0, painter); } else { - qt_format_text(font, QRectF(p, QSizeF(1, 1)), Qt::TextSingleLine | Qt::TextDontClip, /*opt*/0, - str, /*brect=*/0, /*tabstops=*/0, /*...*/0, /*tabarraylen=*/0, painter); + qt_format_text(font, QRectF(p, QSizeF(1, 1)), Qt::TextSingleLine | Qt::TextDontClip, /*opt*/nullptr, + str, /*brect=*/nullptr, /*tabstops=*/0, /*...*/nullptr, /*tabarraylen=*/0, painter); } break; @@ -1369,11 +1369,11 @@ QPictureIO::QPictureIO(const QString &fileName, const char* format) void QPictureIO::init() { d = new QPictureIOData(); - d->parameters = 0; + d->parameters = nullptr; d->quality = -1; // default quality of the current format d->gamma=0.0f; d->iostat = 0; - d->iodev = 0; + d->iodev = nullptr; } /*! @@ -1467,7 +1467,7 @@ static QPictureHandler *get_picture_handler(const char *format) return list->at(i); } } - return 0; // no such handler + return nullptr; // no such handler } @@ -1887,7 +1887,7 @@ bool QPictureIO::read() if (picture_format.isEmpty()) { if (file.isOpen()) { // unknown format file.close(); - d->iodev = 0; + d->iodev = nullptr; } return false; } @@ -1913,7 +1913,7 @@ bool QPictureIO::read() if (file.isOpen()) { // picture was read using file file.close(); - d->iodev = 0; + d->iodev = nullptr; } return d->iostat == 0; // picture successfully read? } @@ -1957,7 +1957,7 @@ bool QPictureIO::write() (*h->write_picture)(this); if (file.isOpen()) { // picture was written using file file.close(); - d->iodev = 0; + d->iodev = nullptr; } return d->iostat == 0; // picture successfully written? } diff --git a/src/gui/image/qpixmap.cpp b/src/gui/image/qpixmap.cpp index b6e41f16a5..3fce64cb20 100644 --- a/src/gui/image/qpixmap.cpp +++ b/src/gui/image/qpixmap.cpp @@ -94,7 +94,7 @@ void QPixmap::doInit(int w, int h, int type) if ((w > 0 && h > 0) || type == QPlatformPixmap::BitmapType) data = QPlatformPixmap::create(w, h, (QPlatformPixmap::PixelType) type); else - data = 0; + data = nullptr; } /*! @@ -780,7 +780,7 @@ bool QPixmap::load(const QString &fileName, const char *format, Qt::ImageConvers bool QPixmap::loadFromData(const uchar *buf, uint len, const char *format, Qt::ImageConversionFlags flags) { - if (len == 0 || buf == 0) { + if (len == 0 || buf == nullptr) { data.reset(); return false; } @@ -1455,7 +1455,7 @@ int QPixmap::metric(PaintDeviceMetric metric) const */ QPaintEngine *QPixmap::paintEngine() const { - return data ? data->paintEngine() : 0; + return data ? data->paintEngine() : nullptr; } /*! diff --git a/src/gui/image/qpixmap_blitter.cpp b/src/gui/image/qpixmap_blitter.cpp index 649a25250c..aeed1e3b34 100644 --- a/src/gui/image/qpixmap_blitter.cpp +++ b/src/gui/image/qpixmap_blitter.cpp @@ -92,8 +92,8 @@ void QBlittablePlatformPixmap::setBlittable(QBlittable *blittable) void QBlittablePlatformPixmap::resize(int width, int height) { - m_blittable.reset(0); - m_engine.reset(0); + m_blittable.reset(nullptr); + m_engine.reset(nullptr); d = QGuiApplication::primaryScreen()->depth(); w = width; h = height; @@ -145,8 +145,8 @@ void QBlittablePlatformPixmap::fill(const QColor &color) // if we could just change the format, e.g. when going from // RGB32 -> ARGB8888. if (color.alpha() != 255 && !hasAlphaChannel()) { - m_blittable.reset(0); - m_engine.reset(0); + m_blittable.reset(nullptr); + m_engine.reset(nullptr); m_alpha = true; } diff --git a/src/gui/image/qpixmapcache.cpp b/src/gui/image/qpixmapcache.cpp index 483d6d79a2..9709df9e0c 100644 --- a/src/gui/image/qpixmapcache.cpp +++ b/src/gui/image/qpixmapcache.cpp @@ -126,7 +126,7 @@ static inline bool qt_pixmapcache_thread_test() /*! Constructs an empty Key object. */ -QPixmapCache::Key::Key() : d(0) +QPixmapCache::Key::Key() : d(nullptr) { } @@ -259,9 +259,9 @@ uint qHash(const QPixmapCache::Key &k) } QPMCache::QPMCache() - : QObject(0), + : QObject(nullptr), QCache(cache_limit_default), - keyArray(0), theid(0), ps(0), keyArraySize(0), freeKey(0), t(false) + keyArray(nullptr), theid(0), ps(0), keyArraySize(0), freeKey(0), t(false) { } QPMCache::~QPMCache() @@ -325,7 +325,7 @@ QPixmap *QPMCache::object(const QString &key) const QPixmapCache::Key cacheKey = cacheKeys.value(key); if (!cacheKey.d || !cacheKey.d->isValid) { const_cast(this)->cacheKeys.remove(key); - return 0; + return nullptr; } QPixmap *ptr = QCache::object(cacheKey); //We didn't find the pixmap in the cache, the key is not valid anymore @@ -453,7 +453,7 @@ void QPMCache::releaseKey(const QPixmapCache::Key &key) void QPMCache::clear() { free(keyArray); - keyArray = 0; + keyArray = nullptr; freeKey = 0; keyArraySize = 0; //Mark all keys as invalid @@ -539,7 +539,7 @@ bool QPixmapCache::find(const QString &key, QPixmap *pixmap) QPixmap *ptr = pm_cache()->object(key); if (ptr && pixmap) *pixmap = *ptr; - return ptr != 0; + return ptr != nullptr; } /*! @@ -561,7 +561,7 @@ bool QPixmapCache::find(const Key &key, QPixmap *pixmap) QPixmap *ptr = pm_cache()->object(key); if (ptr && pixmap) *pixmap = *ptr; - return ptr != 0; + return ptr != nullptr; } /*! diff --git a/src/gui/image/qplatformpixmap.cpp b/src/gui/image/qplatformpixmap.cpp index a2e01147c4..493f55514e 100644 --- a/src/gui/image/qplatformpixmap.cpp +++ b/src/gui/image/qplatformpixmap.cpp @@ -266,7 +266,7 @@ QImage QPlatformPixmap::toImage(const QRect &rect) const QImage* QPlatformPixmap::buffer() { - return 0; + return nullptr; } diff --git a/src/gui/image/qpnghandler.cpp b/src/gui/image/qpnghandler.cpp index d6caf6773a..251f09fe52 100644 --- a/src/gui/image/qpnghandler.cpp +++ b/src/gui/image/qpnghandler.cpp @@ -109,7 +109,7 @@ public: }; QPngHandlerPrivate(QPngHandler *qq) - : gamma(0.0), fileGamma(0.0), quality(50), compression(50), colorSpaceState(Undefined), png_ptr(0), info_ptr(0), end_info(0), state(Ready), q(qq) + : gamma(0.0), fileGamma(0.0), quality(50), compression(50), colorSpaceState(Undefined), png_ptr(nullptr), info_ptr(nullptr), end_info(nullptr), state(Ready), q(qq) { } float gamma; @@ -134,18 +134,18 @@ public: struct AllocatedMemoryPointers { AllocatedMemoryPointers() - : row_pointers(0), accRow(0), inRow(0), outRow(0) + : row_pointers(nullptr), accRow(nullptr), inRow(nullptr), outRow(nullptr) { } void deallocate() { delete [] row_pointers; - row_pointers = 0; + row_pointers = nullptr; delete [] accRow; - accRow = 0; + accRow = nullptr; delete [] inRow; - inRow = 0; + inRow = nullptr; delete [] outRow; - outRow = 0; + outRow = nullptr; } png_byte **row_pointers; @@ -245,13 +245,13 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scal png_uint_32 height = 0; int bit_depth = 0; int color_type = 0; - png_bytep trans_alpha = 0; - png_color_16p trans_color_p = 0; + png_bytep trans_alpha = nullptr; + png_color_16p trans_color_p = nullptr; int num_trans; - png_colorp palette = 0; + png_colorp palette = nullptr; int num_palette; int interlace_method = PNG_INTERLACE_LAST; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_method, 0, 0); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, &interlace_method, nullptr, nullptr); png_set_interlace_handling(png_ptr); if (color_type == PNG_COLOR_TYPE_GRAY) { @@ -343,7 +343,7 @@ void setup_qt(QImage& image, png_structp png_ptr, png_infop info_ptr, QSize scal if (bit_depth != 1) png_set_packing(png_ptr); png_read_update_info(png_ptr, info_ptr); - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr); QImage::Format format = bit_depth == 1 ? QImage::Format_Mono : QImage::Format_Indexed8; if (image.size() != QSize(width, height) || image.format() != format) { image = QImage(width, height, format); @@ -452,7 +452,7 @@ static void read_image_scaled(QImage *outImage, png_structp png_ptr, png_infop i int bit_depth = 0; int color_type = 0; int unit_type = PNG_OFFSET_PIXEL; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr); png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, &unit_type); uchar *data = outImage->bits(); int bpl = outImage->bytesPerLine(); @@ -478,7 +478,7 @@ static void read_image_scaled(QImage *outImage, png_structp png_ptr, png_infop i amp.accRow[i] = rval*amp.inRow[i]; // Accumulate the next input rows for (rval = iysz-rval; rval > 0; rval-=oysz) { - png_read_row(png_ptr, amp.inRow, NULL); + png_read_row(png_ptr, amp.inRow, nullptr); quint32 fact = qMin(oysz, quint32(rval)); for (quint32 i=0; i < ibw; i++) amp.accRow[i] += fact*amp.inRow[i]; @@ -558,11 +558,11 @@ void QPngHandlerPrivate::readPngTexts(png_info *info) bool QPngHandlerPrivate::readPngHeader() { state = Error; - png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,0,0,0); + png_ptr = png_create_read_struct(PNG_LIBPNG_VER_STRING,nullptr,nullptr,nullptr); if (!png_ptr) return false; - png_set_error_fn(png_ptr, 0, 0, qt_png_warning); + png_set_error_fn(png_ptr, nullptr, nullptr, qt_png_warning); #if defined(PNG_SET_OPTION_SUPPORTED) && defined(PNG_MAXIMUM_INFLATE_WINDOW) // Trade off a little bit of memory for better compatibility with existing images @@ -572,21 +572,21 @@ bool QPngHandlerPrivate::readPngHeader() info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { - png_destroy_read_struct(&png_ptr, 0, 0); - png_ptr = 0; + png_destroy_read_struct(&png_ptr, nullptr, nullptr); + png_ptr = nullptr; return false; } end_info = png_create_info_struct(png_ptr); if (!end_info) { - png_destroy_read_struct(&png_ptr, &info_ptr, 0); - png_ptr = 0; + png_destroy_read_struct(&png_ptr, &info_ptr, nullptr); + png_ptr = nullptr; return false; } if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - png_ptr = 0; + png_ptr = nullptr; return false; } @@ -670,7 +670,7 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage) if (setjmp(png_jmpbuf(png_ptr))) { png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - png_ptr = 0; + png_ptr = nullptr; amp.deallocate(); state = Error; return false; @@ -689,7 +689,7 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage) if (outImage->isNull()) { png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - png_ptr = 0; + png_ptr = nullptr; amp.deallocate(); state = Error; return false; @@ -706,7 +706,7 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage) int bit_depth = 0; int color_type = 0; int unit_type = PNG_OFFSET_PIXEL; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr); png_get_oFFs(png_ptr, info_ptr, &offset_x, &offset_y, &unit_type); uchar *data = outImage->bits(); int bpl = outImage->bytesPerLine(); @@ -747,7 +747,7 @@ bool QPngHandlerPrivate::readPngImage(QImage *outImage) outImage->setText(readTexts.at(i), readTexts.at(i+1)); png_destroy_read_struct(&png_ptr, &info_ptr, &end_info); - png_ptr = 0; + png_ptr = nullptr; amp.deallocate(); state = Ready; @@ -767,7 +767,7 @@ QImage::Format QPngHandlerPrivate::readImageFormat() int bit_depth = 0, color_type = 0; png_colorp palette; int num_palette; - png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, 0, 0, 0); + png_get_IHDR(png_ptr, info_ptr, &width, &height, &bit_depth, &color_type, nullptr, nullptr, nullptr); if (color_type == PNG_COLOR_TYPE_GRAY) { // Black & White or grayscale if (bit_depth == 1 && png_get_channels(png_ptr, info_ptr) == 1) { @@ -910,16 +910,16 @@ bool QPNGImageWriter::writeImage(const QImage& image, int compression_in, const png_structp png_ptr; png_infop info_ptr; - png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,0,0,0); + png_ptr = png_create_write_struct(PNG_LIBPNG_VER_STRING,nullptr,nullptr,nullptr); if (!png_ptr) { return false; } - png_set_error_fn(png_ptr, 0, 0, qt_png_warning); + png_set_error_fn(png_ptr, nullptr, nullptr, qt_png_warning); info_ptr = png_create_info_struct(png_ptr); if (!info_ptr) { - png_destroy_write_struct(&png_ptr, 0); + png_destroy_write_struct(&png_ptr, nullptr); return false; } @@ -1022,7 +1022,7 @@ bool QPNGImageWriter::writeImage(const QImage& image, int compression_in, const png_set_PLTE(png_ptr, info_ptr, palette, num_palette); if (num_trans) { - png_set_tRNS(png_ptr, info_ptr, trans, num_trans, 0); + png_set_tRNS(png_ptr, info_ptr, trans, num_trans, nullptr); } } diff --git a/src/gui/image/qxpmhandler.cpp b/src/gui/image/qxpmhandler.cpp index cf105b250a..f9424b62bb 100644 --- a/src/gui/image/qxpmhandler.cpp +++ b/src/gui/image/qxpmhandler.cpp @@ -1175,7 +1175,7 @@ QXpmHandler::QXpmHandler() bool QXpmHandler::readHeader() { state = Error; - if (!read_xpm_header(device(), 0, index, buffer, &cpp, &ncols, &width, &height)) + if (!read_xpm_header(device(), nullptr, index, buffer, &cpp, &ncols, &width, &height)) return false; state = ReadHeader; return true; @@ -1191,7 +1191,7 @@ bool QXpmHandler::readImage(QImage *image) return false; } - if (!read_xpm_body(device(), 0, index, buffer, cpp, ncols, width, height, *image)) { + if (!read_xpm_body(device(), nullptr, index, buffer, cpp, ncols, width, height, *image)) { state = Error; return false; } -- cgit v1.2.3