From 58c14c4a7edcecdd9d58b682a9360c83e2274ec5 Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Mon, 18 Sep 2017 11:49:52 +0200 Subject: Replace Q_NULLPTR with nullptr where possible Remaining uses of Q_NULLPTR are in: src/corelib/global/qcompilerdetection.h (definition and documentation of Q_NULLPTR) tests/manual/qcursor/qcursorhighdpi/main.cpp (a test executable compilable both under Qt4 and Qt5) Change-Id: If6b074d91486e9b784138f4514f5c6d072acda9a Reviewed-by: Ville Voutilainen Reviewed-by: Lars Knoll Reviewed-by: Olivier Goffart (Woboq GmbH) --- src/testlib/qsignalspy.h | 2 +- src/testlib/qtest.h | 2 +- src/testlib/qtest_gui.h | 14 +++++++------- src/testlib/qtestaccessible.h | 8 ++++---- src/testlib/qtestcase.cpp | 8 ++++---- src/testlib/qtestcase.h | 14 +++++++------- src/testlib/qtesteventloop.h | 6 +++--- src/testlib/qtestsystem.h | 6 +++--- src/testlib/qtesttable.cpp | 6 +++--- src/testlib/qtesttouch.h | 16 ++++++++-------- 10 files changed, 41 insertions(+), 41 deletions(-) (limited to 'src/testlib') diff --git a/src/testlib/qsignalspy.h b/src/testlib/qsignalspy.h index f05dd95565..d9a0f4496b 100644 --- a/src/testlib/qsignalspy.h +++ b/src/testlib/qsignalspy.h @@ -88,7 +88,7 @@ public: } if (!QMetaObject::connect(obj, sigIndex, this, memberOffset, - Qt::DirectConnection, Q_NULLPTR)) { + Qt::DirectConnection, nullptr)) { qWarning("QSignalSpy: QMetaObject::connect returned false. Unable to connect."); return; } diff --git a/src/testlib/qtest.h b/src/testlib/qtest.h index ca045120d5..a5df27e3b9 100644 --- a/src/testlib/qtest.h +++ b/src/testlib/qtest.h @@ -263,7 +263,7 @@ inline bool qCompare(QList const &t1, QList const &t2, const char *actual, delete [] val2; } } - return compare_helper(isOk, msg, Q_NULLPTR, Q_NULLPTR, actual, expected, file, line); + return compare_helper(isOk, msg, nullptr, nullptr, actual, expected, file, line); } template <> diff --git a/src/testlib/qtest_gui.h b/src/testlib/qtest_gui.h index 4e9ce0d0f6..f56aa60949 100644 --- a/src/testlib/qtest_gui.h +++ b/src/testlib/qtest_gui.h @@ -164,24 +164,24 @@ inline bool qCompare(QImage const &t1, QImage const &t2, qsnprintf(msg, 1024, "Compared QImages differ.\n" " Actual (%s).isNull(): %d\n" " Expected (%s).isNull(): %d", actual, t1Null, expected, t2Null); - return compare_helper(false, msg, Q_NULLPTR, Q_NULLPTR, actual, expected, file, line); + return compare_helper(false, msg, nullptr, nullptr, actual, expected, file, line); } if (t1Null && t2Null) - return compare_helper(true, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, actual, expected, file, line); + return compare_helper(true, nullptr, nullptr, nullptr, actual, expected, file, line); if (t1.width() != t2.width() || t1.height() != t2.height()) { qsnprintf(msg, 1024, "Compared QImages differ in size.\n" " Actual (%s): %dx%d\n" " Expected (%s): %dx%d", actual, t1.width(), t1.height(), expected, t2.width(), t2.height()); - return compare_helper(false, msg, Q_NULLPTR, Q_NULLPTR, actual, expected, file, line); + return compare_helper(false, msg, nullptr, nullptr, actual, expected, file, line); } if (t1.format() != t2.format()) { qsnprintf(msg, 1024, "Compared QImages differ in format.\n" " Actual (%s): %d\n" " Expected (%s): %d", actual, t1.format(), expected, t2.format()); - return compare_helper(false, msg, Q_NULLPTR, Q_NULLPTR, actual, expected, file, line); + return compare_helper(false, msg, nullptr, nullptr, actual, expected, file, line); } return compare_helper(t1 == t2, "Compared values are not the same", toString(t1), toString(t2), actual, expected, file, line); @@ -198,17 +198,17 @@ inline bool qCompare(QPixmap const &t1, QPixmap const &t2, const char *actual, c qsnprintf(msg, 1024, "Compared QPixmaps differ.\n" " Actual (%s).isNull(): %d\n" " Expected (%s).isNull(): %d", actual, t1Null, expected, t2Null); - return compare_helper(false, msg, Q_NULLPTR, Q_NULLPTR, actual, expected, file, line); + return compare_helper(false, msg, nullptr, nullptr, actual, expected, file, line); } if (t1Null && t2Null) - return compare_helper(true, Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, actual, expected, file, line); + return compare_helper(true, nullptr, nullptr, nullptr, actual, expected, file, line); if (t1.width() != t2.width() || t1.height() != t2.height()) { qsnprintf(msg, 1024, "Compared QPixmaps differ in size.\n" " Actual (%s): %dx%d\n" " Expected (%s): %dx%d", actual, t1.width(), t1.height(), expected, t2.width(), t2.height()); - return compare_helper(false, msg, Q_NULLPTR, Q_NULLPTR, actual, expected, file, line); + return compare_helper(false, msg, nullptr, nullptr, actual, expected, file, line); } return qCompare(t1.toImage(), t2.toImage(), actual, expected, file, line); } diff --git a/src/testlib/qtestaccessible.h b/src/testlib/qtestaccessible.h index 464f87fb5c..0470d15ed7 100644 --- a/src/testlib/qtestaccessible.h +++ b/src/testlib/qtestaccessible.h @@ -132,7 +132,7 @@ public: static void cleanup() { delete instance(); - instance() = Q_NULLPTR; + instance() = nullptr; } static void clearEvents() { eventList().clear(); } static EventList events() { return eventList(); } @@ -167,8 +167,8 @@ private: ~QTestAccessibility() { - QAccessible::installUpdateHandler(Q_NULLPTR); - QAccessible::installRootObjectHandler(Q_NULLPTR); + QAccessible::installUpdateHandler(nullptr); + QAccessible::installRootObjectHandler(nullptr); } static void rootObjectHandler(QObject *object) @@ -273,7 +273,7 @@ private: static QTestAccessibility *&instance() { - static QTestAccessibility *ta = Q_NULLPTR; + static QTestAccessibility *ta = nullptr; return ta; } diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index fd68bbe461..7e7f016bf6 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -1387,7 +1387,7 @@ void TestMethods::invokeTests(QObject *testObject) const if (!QTestResult::skipCurrentTest() && !previousFailed) { for (int i = 0, count = int(m_methods.size()); i < count; ++i) { - const char *data = Q_NULLPTR; + const char *data = nullptr; if (i < QTest::testTags.size() && !QTest::testTags.at(i).isEmpty()) data = qstrdup(QTest::testTags.at(i).toLatin1().constData()); const bool ok = invokeTest(i, data, watchDog.data()); @@ -1532,7 +1532,7 @@ class DebugSymbolResolver Q_DISABLE_COPY(DebugSymbolResolver) public: struct Symbol { - Symbol() : name(Q_NULLPTR), address(0) {} + Symbol() : name(nullptr), address(0) {} const char *name; // Must be freed by caller. DWORD64 address; @@ -1580,11 +1580,11 @@ void DebugSymbolResolver::cleanup() if (m_dbgHelpLib) FreeLibrary(m_dbgHelpLib); m_dbgHelpLib = 0; - m_symFromAddr = Q_NULLPTR; + m_symFromAddr = nullptr; } DebugSymbolResolver::DebugSymbolResolver(HANDLE process) - : m_process(process), m_dbgHelpLib(0), m_symFromAddr(Q_NULLPTR) + : m_process(process), m_dbgHelpLib(0), m_symFromAddr(nullptr) { bool success = false; m_dbgHelpLib = LoadLibraryW(L"dbghelp.dll"); diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h index b738043cb7..20e6f022b4 100644 --- a/src/testlib/qtestcase.h +++ b/src/testlib/qtestcase.h @@ -248,7 +248,7 @@ namespace QTest template // Fallback inline typename std::enable_if::Value, char*>::type toString(const T &) { - return Q_NULLPTR; + return nullptr; } } // namespace Internal @@ -271,14 +271,14 @@ namespace QTest Q_TESTLIB_EXPORT char *toString(const char *); Q_TESTLIB_EXPORT char *toString(const void *); - Q_TESTLIB_EXPORT void qInit(QObject *testObject, int argc = 0, char **argv = Q_NULLPTR); + Q_TESTLIB_EXPORT void qInit(QObject *testObject, int argc = 0, char **argv = nullptr); Q_TESTLIB_EXPORT int qRun(); Q_TESTLIB_EXPORT void qCleanup(); - Q_TESTLIB_EXPORT int qExec(QObject *testObject, int argc = 0, char **argv = Q_NULLPTR); + Q_TESTLIB_EXPORT int qExec(QObject *testObject, int argc = 0, char **argv = nullptr); Q_TESTLIB_EXPORT int qExec(QObject *testObject, const QStringList &arguments); - Q_TESTLIB_EXPORT void setMainSourcePath(const char *file, const char *builddir = Q_NULLPTR); + Q_TESTLIB_EXPORT void setMainSourcePath(const char *file, const char *builddir = nullptr); Q_TESTLIB_EXPORT bool qVerify(bool statement, const char *statementStr, const char *description, const char *file, int line); @@ -286,7 +286,7 @@ namespace QTest Q_TESTLIB_EXPORT void qSkip(const char *message, const char *file, int line); Q_TESTLIB_EXPORT bool qExpectFail(const char *dataIndex, const char *comment, TestFailMode mode, const char *file, int line); - Q_TESTLIB_EXPORT void qWarn(const char *message, const char *file = Q_NULLPTR, int line = 0); + Q_TESTLIB_EXPORT void qWarn(const char *message, const char *file = nullptr, int line = 0); Q_TESTLIB_EXPORT void ignoreMessage(QtMsgType type, const char *message); #ifndef QT_NO_REGULAREXPRESSION Q_TESTLIB_EXPORT void ignoreMessage(QtMsgType type, const QRegularExpression &messagePattern); @@ -295,8 +295,8 @@ namespace QTest #if QT_CONFIG(temporaryfile) Q_TESTLIB_EXPORT QSharedPointer qExtractTestData(const QString &dirName); #endif - Q_TESTLIB_EXPORT QString qFindTestData(const char* basepath, const char* file = Q_NULLPTR, int line = 0, const char* builddir = Q_NULLPTR); - Q_TESTLIB_EXPORT QString qFindTestData(const QString& basepath, const char* file = Q_NULLPTR, int line = 0, const char* builddir = Q_NULLPTR); + Q_TESTLIB_EXPORT QString qFindTestData(const char* basepath, const char* file = nullptr, int line = 0, const char* builddir = nullptr); + Q_TESTLIB_EXPORT QString qFindTestData(const QString& basepath, const char* file = nullptr, int line = 0, const char* builddir = nullptr); Q_TESTLIB_EXPORT void *qData(const char *tagName, int typeId); Q_TESTLIB_EXPORT void *qGlobalData(const char *tagName, int typeId); diff --git a/src/testlib/qtesteventloop.h b/src/testlib/qtesteventloop.h index bcf4a4be2d..81c0b9126c 100644 --- a/src/testlib/qtesteventloop.h +++ b/src/testlib/qtesteventloop.h @@ -56,8 +56,8 @@ class Q_TESTLIB_EXPORT QTestEventLoop : public QObject Q_OBJECT public: - inline QTestEventLoop(QObject *aParent = Q_NULLPTR) - : QObject(aParent), inLoop(false), _timeout(false), timerId(-1), loop(Q_NULLPTR) {} + inline QTestEventLoop(QObject *aParent = nullptr) + : QObject(aParent), inLoop(false), _timeout(false), timerId(-1), loop(nullptr) {} inline void enterLoopMSecs(int ms); inline void enterLoop(int secs) { enterLoopMSecs(secs * 1000); } @@ -103,7 +103,7 @@ inline void QTestEventLoop::enterLoopMSecs(int ms) loop = &l; l.exec(); - loop = Q_NULLPTR; + loop = nullptr; } inline void QTestEventLoop::exitLoop() diff --git a/src/testlib/qtestsystem.h b/src/testlib/qtestsystem.h index f38a156936..dc6e481bb2 100644 --- a/src/testlib/qtestsystem.h +++ b/src/testlib/qtestsystem.h @@ -62,7 +62,7 @@ namespace QTest int remaining = ms; do { QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); - QCoreApplication::sendPostedEvents(Q_NULLPTR, QEvent::DeferredDelete); + QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); remaining = timer.remainingTime(); if (remaining <= 0) break; @@ -78,7 +78,7 @@ namespace QTest int remaining = timeout; while (!window->isActive() && remaining > 0) { QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); - QCoreApplication::sendPostedEvents(Q_NULLPTR, QEvent::DeferredDelete); + QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); QTest::qSleep(10); remaining = timer.remainingTime(); } @@ -105,7 +105,7 @@ namespace QTest int remaining = timeout; while (!window->isExposed() && remaining > 0) { QCoreApplication::processEvents(QEventLoop::AllEvents, remaining); - QCoreApplication::sendPostedEvents(Q_NULLPTR, QEvent::DeferredDelete); + QCoreApplication::sendPostedEvents(nullptr, QEvent::DeferredDelete); QTest::qSleep(10); remaining = timer.remainingTime(); } diff --git a/src/testlib/qtesttable.cpp b/src/testlib/qtesttable.cpp index 1afe2f7af5..953495a18a 100644 --- a/src/testlib/qtesttable.cpp +++ b/src/testlib/qtesttable.cpp @@ -58,7 +58,7 @@ public: } struct Element { - Element() : name(Q_NULLPTR), type(0) {} + Element() : name(nullptr), type(0) {} Element(const char *n, int t) : name(n), type(t) {} const char *name; @@ -130,12 +130,12 @@ int QTestTable::elementTypeId(int index) const const char *QTestTable::dataTag(int index) const { - return size_t(index) < d->elementList.size() ? d->elementList[index].name : Q_NULLPTR; + return size_t(index) < d->elementList.size() ? d->elementList[index].name : nullptr; } QTestData *QTestTable::testData(int index) const { - return size_t(index) < d->dataList.size() ? d->dataList[index] : Q_NULLPTR; + return size_t(index) < d->dataList.size() ? d->dataList[index] : nullptr; } class NamePredicate : public std::unary_function diff --git a/src/testlib/qtesttouch.h b/src/testlib/qtesttouch.h index bda185bfee..bdb6d5b629 100644 --- a/src/testlib/qtesttouch.h +++ b/src/testlib/qtesttouch.h @@ -75,21 +75,21 @@ namespace QTest if (commitWhenDestroyed) commit(); } - QTouchEventSequence& press(int touchId, const QPoint &pt, QWindow *window = Q_NULLPTR) + QTouchEventSequence& press(int touchId, const QPoint &pt, QWindow *window = nullptr) { QTouchEvent::TouchPoint &p = point(touchId); p.setScreenPos(mapToScreen(window, pt)); p.setState(Qt::TouchPointPressed); return *this; } - QTouchEventSequence& move(int touchId, const QPoint &pt, QWindow *window = Q_NULLPTR) + QTouchEventSequence& move(int touchId, const QPoint &pt, QWindow *window = nullptr) { QTouchEvent::TouchPoint &p = point(touchId); p.setScreenPos(mapToScreen(window, pt)); p.setState(Qt::TouchPointMoved); return *this; } - QTouchEventSequence& release(int touchId, const QPoint &pt, QWindow *window = Q_NULLPTR) + QTouchEventSequence& release(int touchId, const QPoint &pt, QWindow *window = nullptr) { QTouchEvent::TouchPoint &p = point(touchId); p.setScreenPos(mapToScreen(window, pt)); @@ -104,21 +104,21 @@ namespace QTest } #ifdef QT_WIDGETS_LIB - QTouchEventSequence& press(int touchId, const QPoint &pt, QWidget *widget = Q_NULLPTR) + QTouchEventSequence& press(int touchId, const QPoint &pt, QWidget *widget = nullptr) { QTouchEvent::TouchPoint &p = point(touchId); p.setScreenPos(mapToScreen(widget, pt)); p.setState(Qt::TouchPointPressed); return *this; } - QTouchEventSequence& move(int touchId, const QPoint &pt, QWidget *widget = Q_NULLPTR) + QTouchEventSequence& move(int touchId, const QPoint &pt, QWidget *widget = nullptr) { QTouchEvent::TouchPoint &p = point(touchId); p.setScreenPos(mapToScreen(widget, pt)); p.setState(Qt::TouchPointMoved); return *this; } - QTouchEventSequence& release(int touchId, const QPoint &pt, QWidget *widget = Q_NULLPTR) + QTouchEventSequence& release(int touchId, const QPoint &pt, QWidget *widget = nullptr) { QTouchEvent::TouchPoint &p = point(touchId); p.setScreenPos(mapToScreen(widget, pt)); @@ -151,14 +151,14 @@ namespace QTest private: #ifdef QT_WIDGETS_LIB QTouchEventSequence(QWidget *widget, QTouchDevice *aDevice, bool autoCommit) - : targetWidget(widget), targetWindow(Q_NULLPTR), device(aDevice), commitWhenDestroyed(autoCommit) + : targetWidget(widget), targetWindow(nullptr), device(aDevice), commitWhenDestroyed(autoCommit) { } #endif QTouchEventSequence(QWindow *window, QTouchDevice *aDevice, bool autoCommit) : #ifdef QT_WIDGETS_LIB - targetWidget(Q_NULLPTR), + targetWidget(nullptr), #endif targetWindow(window), device(aDevice), commitWhenDestroyed(autoCommit) { -- cgit v1.2.3