diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-07 13:05:48 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2020-10-07 23:02:47 +0200 |
commit | 564b59d903683b14c75b72a3e93367717f201def (patch) | |
tree | 03ffe749d83dce84429a7db484bf92795047036f /src/corelib | |
parent | b5fc1e4e2643e73d3b44c483d159529f8deb8af1 (diff) |
Another round of replacing 0 with nullptr
This time based on grepping to also include documentation, tests and
examples previously missed by the automatic tool.
Change-Id: Ied1703f4bcc470fbc275f759ed5b7c588a5c4e9f
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/corelib')
26 files changed, 39 insertions, 39 deletions
diff --git a/src/corelib/doc/snippets/code/doc_src_properties.cpp b/src/corelib/doc/snippets/code/doc_src_properties.cpp index 47dff630f8..5a5627abfd 100644 --- a/src/corelib/doc/snippets/code/doc_src_properties.cpp +++ b/src/corelib/doc/snippets/code/doc_src_properties.cpp @@ -106,7 +106,7 @@ class MyClass : public QObject Q_PROPERTY(Priority priority READ priority WRITE setPriority NOTIFY priorityChanged) public: - MyClass(QObject *parent = 0); + MyClass(QObject *parent = nullptr); ~MyClass(); enum Priority { High, Low, VeryHigh, VeryLow }; diff --git a/src/corelib/doc/snippets/eventfilters/filterobject.h b/src/corelib/doc/snippets/eventfilters/filterobject.h index 354aa4ff5c..d249743a15 100644 --- a/src/corelib/doc/snippets/eventfilters/filterobject.h +++ b/src/corelib/doc/snippets/eventfilters/filterobject.h @@ -58,7 +58,7 @@ class FilterObject : public QObject Q_OBJECT public: - FilterObject(QObject *parent = 0); + FilterObject(QObject *parent = nullptr); bool eventFilter(QObject *object, QEvent *event) override; void setFilteredObject(QObject *object); diff --git a/src/corelib/doc/snippets/qsortfilterproxymodel-details/main.cpp b/src/corelib/doc/snippets/qsortfilterproxymodel-details/main.cpp index 2a7b310716..a79f07c3ae 100644 --- a/src/corelib/doc/snippets/qsortfilterproxymodel-details/main.cpp +++ b/src/corelib/doc/snippets/qsortfilterproxymodel-details/main.cpp @@ -55,7 +55,7 @@ class MyItemModel : public QStandardItemModel { public: - MyItemModel(QWidget *parent = 0); + MyItemModel(QWidget *parent = nullptr); }; MyItemModel::MyItemModel(QWidget *parent) @@ -65,7 +65,7 @@ MyItemModel::MyItemModel(QWidget *parent) class Widget : public QWidget { public: - Widget(QWidget *parent = 0); + Widget(QWidget *parent = nullptr); }; Widget::Widget(QWidget *parent) diff --git a/src/corelib/doc/snippets/qstring/main.cpp b/src/corelib/doc/snippets/qstring/main.cpp index cb557ac023..419b98366d 100644 --- a/src/corelib/doc/snippets/qstring/main.cpp +++ b/src/corelib/doc/snippets/qstring/main.cpp @@ -55,7 +55,7 @@ class Widget : public QWidget { public: - Widget(QWidget *parent = 0); + Widget(QWidget *parent = nullptr); void constCharPointer(); void constCharArray(); diff --git a/src/corelib/doc/snippets/qstringlist/main.cpp b/src/corelib/doc/snippets/qstringlist/main.cpp index 5284a5fb78..fceadc4e99 100644 --- a/src/corelib/doc/snippets/qstringlist/main.cpp +++ b/src/corelib/doc/snippets/qstringlist/main.cpp @@ -55,7 +55,7 @@ using namespace std; class Widget : public QWidget { public: - Widget(QWidget *parent = 0); + Widget(QWidget *parent = nullptr); }; Widget::Widget(QWidget *parent) diff --git a/src/corelib/doc/snippets/qstringlistmodel/main.cpp b/src/corelib/doc/snippets/qstringlistmodel/main.cpp index 4c9519d2b2..fa7f414526 100644 --- a/src/corelib/doc/snippets/qstringlistmodel/main.cpp +++ b/src/corelib/doc/snippets/qstringlistmodel/main.cpp @@ -53,7 +53,7 @@ class Widget : public QWidget { public: - Widget(QWidget *parent = 0); + Widget(QWidget *parent = nullptr); }; Widget::Widget(QWidget *parent) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 25c31e4067..deb3dfe454 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -1184,7 +1184,7 @@ Q_CORE_EXPORT QString qtTrId(const char *id, int n = -1); # define dynamic_cast QT_PREPEND_NAMESPACE(qt_dynamic_cast_check) template<typename T, typename X> - T qt_dynamic_cast_check(X, T* = 0) + T qt_dynamic_cast_check(X, T* = nullptr) { return T::dynamic_cast_will_always_fail_because_rtti_is_disabled; } #endif diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index b3d7ecfed8..d876fdf4ae 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -567,7 +567,7 @@ QString QFileSystemEngine::nativeAbsoluteFilePath(const QString &path) // can be //server or //server/share QString absPath; QVarLengthArray<wchar_t, MAX_PATH> buf(qMax(MAX_PATH, path.size() + 1)); - wchar_t *fileName = 0; + wchar_t *fileName = nullptr; DWORD retLen = GetFullPathName((wchar_t*)path.utf16(), buf.size(), buf.data(), &fileName); if (retLen > (DWORD)buf.size()) { buf.resize(retLen); diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index b131524614..29dd78030b 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -406,7 +406,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, pathInfo = fileInfo; // Look for a thread - QWindowsFileSystemWatcherEngineThread *thread = 0; + QWindowsFileSystemWatcherEngineThread *thread = nullptr; QWindowsFileSystemWatcherEngine::Handle handle; QList<QWindowsFileSystemWatcherEngineThread *>::const_iterator jt, end; end = threads.constEnd(); diff --git a/src/corelib/io/qstandardpaths_android.cpp b/src/corelib/io/qstandardpaths_android.cpp index 1f4e0de1e7..f4a2a8f121 100644 --- a/src/corelib/io/qstandardpaths_android.cpp +++ b/src/corelib/io/qstandardpaths_android.cpp @@ -134,7 +134,7 @@ static QString getExternalStoragePublicDirectory(const char *directoryField) * Locations where applications can place persistent files it owns. * E.g., /storage/org.app/Music */ -static QString getExternalFilesDir(const char *directoryField = 0) +static QString getExternalFilesDir(const char *directoryField = nullptr) { QString &path = (*androidDirCache)[QLatin1String("APPNAME_%1").arg(QLatin1String(directoryField))]; if (!path.isEmpty()) diff --git a/src/corelib/io/qwindowspipereader_p.h b/src/corelib/io/qwindowspipereader_p.h index 5ec9dc379c..2842343597 100644 --- a/src/corelib/io/qwindowspipereader_p.h +++ b/src/corelib/io/qwindowspipereader_p.h @@ -62,7 +62,7 @@ class Q_CORE_EXPORT QWindowsPipeReader : public QObject { Q_OBJECT public: - explicit QWindowsPipeReader(QObject *parent = 0); + explicit QWindowsPipeReader(QObject *parent = nullptr); ~QWindowsPipeReader(); void setHandle(HANDLE hPipeReadEnd); diff --git a/src/corelib/io/qwindowspipewriter_p.h b/src/corelib/io/qwindowspipewriter_p.h index f7f68b688c..39e8ffe40a 100644 --- a/src/corelib/io/qwindowspipewriter_p.h +++ b/src/corelib/io/qwindowspipewriter_p.h @@ -111,7 +111,7 @@ class Q_CORE_EXPORT QWindowsPipeWriter : public QObject { Q_OBJECT public: - explicit QWindowsPipeWriter(HANDLE pipeWriteEnd, QObject *parent = 0); + explicit QWindowsPipeWriter(HANDLE pipeWriteEnd, QObject *parent = nullptr); ~QWindowsPipeWriter(); bool write(const QByteArray &ba); diff --git a/src/corelib/kernel/qeventdispatcher_cf_p.h b/src/corelib/kernel/qeventdispatcher_cf_p.h index eb84b0a64c..2d76bf53da 100644 --- a/src/corelib/kernel/qeventdispatcher_cf_p.h +++ b/src/corelib/kernel/qeventdispatcher_cf_p.h @@ -209,7 +209,7 @@ class Q_CORE_EXPORT QEventDispatcherCoreFoundation : public QAbstractEventDispat Q_OBJECT public: - explicit QEventDispatcherCoreFoundation(QObject *parent = 0); + explicit QEventDispatcherCoreFoundation(QObject *parent = nullptr); void startingUp() override; ~QEventDispatcherCoreFoundation(); diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index 03d003bb0f..44487d57e2 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -162,8 +162,8 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA #else auto q = reinterpret_cast<QEventDispatcherWin32 *>(GetWindowLong(hwnd, GWL_USERDATA)); #endif - QEventDispatcherWin32Private *d = 0; - if (q != 0) + QEventDispatcherWin32Private *d = nullptr; + if (q != nullptr) d = q->d_func(); switch (message) { @@ -187,7 +187,7 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA break; } if (type >= 0) { - Q_ASSERT(d != 0); + Q_ASSERT(d != nullptr); QSNDict *sn_vec[4] = { &d->sn_read, &d->sn_write, &d->sn_except, &d->sn_read }; QSNDict *dict = sn_vec[type]; @@ -217,7 +217,7 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA return 0; } case WM_QT_ACTIVATENOTIFIERS: { - Q_ASSERT(d != 0); + Q_ASSERT(d != nullptr); // Postpone activation if we have unhandled socket notifier messages // in the queue. WM_QT_ACTIVATENOTIFIERS will be posted again as a result of @@ -242,7 +242,7 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA return 0; } case WM_TIMER: - Q_ASSERT(d != 0); + Q_ASSERT(d != nullptr); if (wp == d->sendPostedEventsTimerId) q->sendPostedEvents(); @@ -250,7 +250,7 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA d->sendTimerEvent(wp); return 0; case WM_QT_SENDPOSTEDEVENTS: - Q_ASSERT(d != 0); + Q_ASSERT(d != nullptr); // We send posted events manually, if the window procedure was invoked // by the foreign event loop (e.g. from the native modal dialog). @@ -268,7 +268,7 @@ LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPA LRESULT QT_WIN_CALLBACK qt_GetMessageHook(int code, WPARAM wp, LPARAM lp) { QEventDispatcherWin32 *q = qobject_cast<QEventDispatcherWin32 *>(QAbstractEventDispatcher::instance()); - Q_ASSERT(q != 0); + Q_ASSERT(q != nullptr); QEventDispatcherWin32Private *d = q->d_func(); MSG *msg = reinterpret_cast<MSG *>(lp); // Windows unexpectedly passes PM_NOYIELD flag to the hook procedure, diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index 9ee4eb725d..a5c063e062 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -73,7 +73,7 @@ class Q_CORE_EXPORT QEventDispatcherWin32 : public QAbstractEventDispatcher Q_DECLARE_PRIVATE(QEventDispatcherWin32) public: - explicit QEventDispatcherWin32(QObject *parent = 0); + explicit QEventDispatcherWin32(QObject *parent = nullptr); ~QEventDispatcherWin32(); bool QT_ENSURE_STACK_ALIGNED_FOR_SSE processEvents(QEventLoop::ProcessEventsFlags flags) override; @@ -103,7 +103,7 @@ public: HWND internalHwnd(); protected: - QEventDispatcherWin32(QEventDispatcherWin32Private &dd, QObject *parent = 0); + QEventDispatcherWin32(QEventDispatcherWin32Private &dd, QObject *parent = nullptr); virtual void sendPostedEvents(); void doUnregisterSocketNotifier(QSocketNotifier *notifier); void doUnregisterEventNotifier(QWinEventNotifier *notifier); diff --git a/src/corelib/kernel/qjni.cpp b/src/corelib/kernel/qjni.cpp index 5f652d70e3..b593483e59 100644 --- a/src/corelib/kernel/qjni.cpp +++ b/src/corelib/kernel/qjni.cpp @@ -81,7 +81,7 @@ static QByteArray toBinaryEncClassName(const QByteArray &className) return QByteArray(className).replace('/', '.'); } -static jclass getCachedClass(const QByteArray &classBinEnc, bool *isCached = 0) +static jclass getCachedClass(const QByteArray &classBinEnc, bool *isCached = nullptr) { QReadLocker locker(cachedClassesLock); const QHash<QString, jclass>::const_iterator &it = cachedClasses->constFind(QString::fromLatin1(classBinEnc)); diff --git a/src/corelib/kernel/qjni_p.h b/src/corelib/kernel/qjni_p.h index ec8525e6e1..b5139d404b 100644 --- a/src/corelib/kernel/qjni_p.h +++ b/src/corelib/kernel/qjni_p.h @@ -72,7 +72,7 @@ public: ~QJNIEnvironmentPrivate(); JNIEnv *operator->(); operator JNIEnv*() const; - static jclass findClass(const char *className, JNIEnv *env = 0); + static jclass findClass(const char *className, JNIEnv *env = nullptr); private: friend class QAndroidJniEnvironment; diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index b3807b145d..60588e9329 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -579,7 +579,7 @@ const QMetaObject *QMetaType::metaObject() const } /*! - \fn void *QMetaType::create(const void *copy = 0) const + \fn void *QMetaType::create(const void *copy = nullptr) const \since 5.0 Returns a copy of \a copy, assuming it is of the type that this @@ -624,7 +624,7 @@ void QMetaType::destroy(void *data) const } /*! - \fn void *QMetaType::construct(void *where, const void *copy = 0) const + \fn void *QMetaType::construct(void *where, const void *copy = nullptr) const \since 5.0 Constructs a value of the type that this QMetaType instance diff --git a/src/corelib/kernel/qpoll.cpp b/src/corelib/kernel/qpoll.cpp index 8b87bfe79d..f41c413db6 100644 --- a/src/corelib/kernel/qpoll.cpp +++ b/src/corelib/kernel/qpoll.cpp @@ -177,7 +177,7 @@ int qt_poll(struct pollfd *fds, nfds_t nfds, const struct timespec *timeout_ts) } fd_set read_fds, write_fds, except_fds; - struct timeval tv, *ptv = 0; + struct timeval tv, *ptv = nullptr; if (timeout_ts) { tv = timespecToTimeval(*timeout_ts); diff --git a/src/corelib/kernel/qproperty.h b/src/corelib/kernel/qproperty.h index 156696dace..ab93cdccc6 100644 --- a/src/corelib/kernel/qproperty.h +++ b/src/corelib/kernel/qproperty.h @@ -207,7 +207,7 @@ public: namespace Qt { template <typename Functor> auto makePropertyBinding(Functor &&f, const QPropertyBindingSourceLocation &location = QT_PROPERTY_DEFAULT_BINDING_LOCATION, - std::enable_if_t<std::is_invocable_v<Functor>> * = 0) + std::enable_if_t<std::is_invocable_v<Functor>> * = nullptr) { return QPropertyBinding<std::invoke_result_t<Functor>>(std::forward<Functor>(f), location); } @@ -321,7 +321,7 @@ public: #ifndef Q_CLANG_QDOC template <typename Functor> explicit QProperty(Functor &&f, const QPropertyBindingSourceLocation &location = QT_PROPERTY_DEFAULT_BINDING_LOCATION, - typename std::enable_if_t<std::is_invocable_r_v<T, Functor&>> * = 0) + typename std::enable_if_t<std::is_invocable_r_v<T, Functor&>> * = nullptr) : QProperty(QPropertyBinding<T>(std::forward<Functor>(f), location)) {} #else @@ -821,7 +821,7 @@ public: #ifndef Q_CLANG_QDOC template <typename Functor> explicit QObjectBindableProperty(Functor &&f, const QPropertyBindingSourceLocation &location = QT_PROPERTY_DEFAULT_BINDING_LOCATION, - typename std::enable_if_t<std::is_invocable_r_v<T, Functor&>> * = 0) + typename std::enable_if_t<std::is_invocable_r_v<T, Functor&>> * = nullptr) : QObjectBindableProperty(QPropertyBinding<T>(std::forward<Functor>(f), location)) {} #else diff --git a/src/corelib/kernel/qsystemerror.cpp b/src/corelib/kernel/qsystemerror.cpp index a2df9dee93..030c38e045 100644 --- a/src/corelib/kernel/qsystemerror.cpp +++ b/src/corelib/kernel/qsystemerror.cpp @@ -76,7 +76,7 @@ namespace { static QString windowsErrorString(int errorCode) { QString ret; - wchar_t *string = 0; + wchar_t *string = nullptr; FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM, NULL, errorCode, diff --git a/src/corelib/plugin/qmachparser.cpp b/src/corelib/plugin/qmachparser.cpp index 11670cafe9..9d0b4de4f5 100644 --- a/src/corelib/plugin/qmachparser.cpp +++ b/src/corelib/plugin/qmachparser.cpp @@ -103,7 +103,7 @@ int QMachOParser::parse(const char *m_s, ulong fdlen, const QString &library, QS return ns(QLibrary::tr("file too small"), library, errorString); // find out if this is a fat Mach-O binary first - const my_mach_header *header = 0; + const my_mach_header *header = nullptr; const fat_header *fat = reinterpret_cast<const fat_header *>(m_s); if (fat->magic == qToBigEndian(FAT_MAGIC)) { // find our architecture in the binary diff --git a/src/corelib/thread/qthread.cpp b/src/corelib/thread/qthread.cpp index e0d252b8ee..2f6a7a18ba 100644 --- a/src/corelib/thread/qthread.cpp +++ b/src/corelib/thread/qthread.cpp @@ -895,7 +895,7 @@ bool QThread::isRunning() const } // No threads: so we can just use static variables -static QThreadData *data = 0; +static QThreadData *data = nullptr; QThreadData *QThreadData::current(bool createIfNecessary) { diff --git a/src/corelib/thread/qthread_p.h b/src/corelib/thread/qthread_p.h index c853bd1de4..0a73bf8a36 100644 --- a/src/corelib/thread/qthread_p.h +++ b/src/corelib/thread/qthread_p.h @@ -208,7 +208,7 @@ public: class QThreadPrivate : public QObjectPrivate { public: - QThreadPrivate(QThreadData *d = 0); + QThreadPrivate(QThreadData *d = nullptr); ~QThreadPrivate(); mutable QMutex mutex; diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp index eb08bdba62..7647916e99 100644 --- a/src/corelib/tools/qscopedpointer.cpp +++ b/src/corelib/tools/qscopedpointer.cpp @@ -126,7 +126,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn template <typename T, typename Cleanup> QScopedPointer<T, Cleanup>::QScopedPointer(T *p = 0) + \fn template <typename T, typename Cleanup> QScopedPointer<T, Cleanup>::QScopedPointer(T *p = nullptr) Constructs this QScopedPointer instance and sets its pointer to \a p. */ @@ -242,7 +242,7 @@ QT_BEGIN_NAMESPACE */ /*! - \fn template <typename T, typename Cleanup> void QScopedPointer<T, Cleanup>::reset(T *other = 0) + \fn template <typename T, typename Cleanup> void QScopedPointer<T, Cleanup>::reset(T *other = nullptr) Deletes the existing object it is pointing to (if any), and sets its pointer to \a other. QScopedPointer now owns \a other and will delete it in its diff --git a/src/corelib/tools/qscopedpointer_p.h b/src/corelib/tools/qscopedpointer_p.h index c1c44e7695..233c2201dc 100644 --- a/src/corelib/tools/qscopedpointer_p.h +++ b/src/corelib/tools/qscopedpointer_p.h @@ -64,7 +64,7 @@ template <typename T, typename Cleanup = QScopedPointerDeleter<T> > class QCustomScopedPointer : public QScopedPointer<T, Cleanup> { public: - explicit inline QCustomScopedPointer(T *p = 0) + explicit inline QCustomScopedPointer(T *p = nullptr) : QScopedPointer<T, Cleanup>(p) { } @@ -107,7 +107,7 @@ template <typename T> class QScopedSharedPointer : public QCustomScopedPointer<T, QScopedPointerSharedDeleter<T> > { public: - explicit inline QScopedSharedPointer(T *p = 0) + explicit inline QScopedSharedPointer(T *p = nullptr) : QCustomScopedPointer<T, QScopedPointerSharedDeleter<T> >(p) { } |