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/sql/kernel/qsqldatabase.cpp | 6 +++--- src/sql/kernel/qsqldriver.cpp | 2 +- src/sql/models/qsqlrelationaltablemodel.cpp | 14 +++++++------- 3 files changed, 11 insertions(+), 11 deletions(-) (limited to 'src/sql') diff --git a/src/sql/kernel/qsqldatabase.cpp b/src/sql/kernel/qsqldatabase.cpp index 01726d79ef..32338c1fe2 100644 --- a/src/sql/kernel/qsqldatabase.cpp +++ b/src/sql/kernel/qsqldatabase.cpp @@ -84,7 +84,7 @@ Q_GLOBAL_STATIC(QConnectionDict, dbDict) class QSqlDatabasePrivate { public: - QSqlDatabasePrivate(QSqlDatabase *d, QSqlDriver *dr = 0): + QSqlDatabasePrivate(QSqlDatabase *d, QSqlDriver *dr = nullptr): ref(1), q(d), driver(dr), @@ -178,7 +178,7 @@ DriverDict &QSqlDatabasePrivate::driverDict() QSqlDatabasePrivate *QSqlDatabasePrivate::shared_null() { static QSqlNullDriver dr; - static QSqlDatabasePrivate n(NULL, &dr); + static QSqlDatabasePrivate n(nullptr, &dr); return &n; } @@ -702,7 +702,7 @@ void QSqlDatabasePrivate::init(const QString &type) qWarning("QSqlDatabase: %s driver not loaded", type.toLatin1().data()); qWarning("QSqlDatabase: available drivers: %s", QSqlDatabase::drivers().join(QLatin1Char(' ')).toLatin1().data()); - if (QCoreApplication::instance() == 0) + if (QCoreApplication::instance() == nullptr) qWarning("QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins"); driver = shared_null()->driver; } diff --git a/src/sql/kernel/qsqldriver.cpp b/src/sql/kernel/qsqldriver.cpp index e0ddc4ca84..fcd3c70a04 100644 --- a/src/sql/kernel/qsqldriver.cpp +++ b/src/sql/kernel/qsqldriver.cpp @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE static QString prepareIdentifier(const QString &identifier, QSqlDriver::IdentifierType type, const QSqlDriver *driver) { - Q_ASSERT( driver != NULL ); + Q_ASSERT( driver != nullptr ); QString ret = identifier; if (!driver->isIdentifierEscaped(identifier, type)) { ret = driver->escapeIdentifier(identifier, type); diff --git a/src/sql/models/qsqlrelationaltablemodel.cpp b/src/sql/models/qsqlrelationaltablemodel.cpp index 34be010474..20adec6a3b 100644 --- a/src/sql/models/qsqlrelationaltablemodel.cpp +++ b/src/sql/models/qsqlrelationaltablemodel.cpp @@ -137,7 +137,7 @@ class QRelatedTableModel; struct QRelation { public: - QRelation(): model(0), m_parent(0), m_dictInitialized(false) {} + QRelation(): model(nullptr), m_parent(nullptr), m_dictInitialized(false) {} void init(QSqlRelationalTableModel *parent, const QSqlRelation &relation); void populateModel(); @@ -161,7 +161,7 @@ struct QRelation class QRelatedTableModel : public QSqlTableModel { public: - QRelatedTableModel(QRelation *rel, QObject *parent = 0, QSqlDatabase db = QSqlDatabase()); + QRelatedTableModel(QRelation *rel, QObject *parent = nullptr, QSqlDatabase db = QSqlDatabase()); bool select() override; private: bool firstSelect; @@ -174,7 +174,7 @@ private: */ void QRelation::init(QSqlRelationalTableModel *parent, const QSqlRelation &relation) { - Q_ASSERT(parent != NULL); + Q_ASSERT(parent != nullptr); m_parent = parent; rel = relation; } @@ -183,7 +183,7 @@ void QRelation::populateModel() { if (!isValid()) return; - Q_ASSERT(m_parent != NULL); + Q_ASSERT(m_parent != nullptr); if (!model) { model = new QRelatedTableModel(this, m_parent, m_parent->database()); @@ -202,7 +202,7 @@ void QRelation::populateDictionary() if (!isValid()) return; - if (model == NULL) + if (model == nullptr) populateModel(); QSqlRecord record; @@ -234,13 +234,13 @@ void QRelation::clearDictionary() void QRelation::clear() { delete model; - model = 0; + model = nullptr; clearDictionary(); } bool QRelation::isValid() { - return (rel.isValid() && m_parent != NULL); + return (rel.isValid() && m_parent != nullptr); } -- cgit v1.2.3