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/widgets/accessible/complexwidgets.cpp | 18 ++++---- src/widgets/accessible/itemviews.cpp | 50 +++++++++++----------- src/widgets/accessible/qaccessiblemenu.cpp | 14 +++--- src/widgets/accessible/qaccessiblewidget.cpp | 8 ++-- .../accessible/qaccessiblewidgetfactory.cpp | 6 +-- src/widgets/accessible/qaccessiblewidgets.cpp | 28 ++++++------ src/widgets/accessible/simplewidgets.cpp | 4 +- 7 files changed, 64 insertions(+), 64 deletions(-) (limited to 'src/widgets/accessible') diff --git a/src/widgets/accessible/complexwidgets.cpp b/src/widgets/accessible/complexwidgets.cpp index 63c6fbb9bb..4d9a629ab6 100644 --- a/src/widgets/accessible/complexwidgets.cpp +++ b/src/widgets/accessible/complexwidgets.cpp @@ -97,10 +97,10 @@ public: if (t == QAccessible::ActionInterface) { return static_cast(this); } - return 0; + return nullptr; } - QObject *object() const override { return 0; } + QObject *object() const override { return nullptr; } QAccessible::Role role() const override { return QAccessible::PageTab; } QAccessible::State state() const override { if (!isValid()) { @@ -129,7 +129,7 @@ public: return false; } - QAccessibleInterface *childAt(int, int) const override { return 0; } + QAccessibleInterface *childAt(int, int) const override { return nullptr; } int childCount() const override { return 0; } int indexOfChild(const QAccessibleInterface *) const override { return -1; } @@ -168,7 +168,7 @@ public: QAccessibleInterface *parent() const override { return QAccessible::queryAccessibleInterface(m_parent.data()); } - QAccessibleInterface *child(int) const override { return 0; } + QAccessibleInterface *child(int) const override { return nullptr; } // action interface QStringList actionNames() const override @@ -237,7 +237,7 @@ QAccessibleInterface* QAccessibleTabBar::child(int index) const return QAccessible::queryAccessibleInterface(tabBar()->d_func()->rightB); } } - return 0; + return nullptr; } int QAccessibleTabBar::indexOfChild(const QAccessibleInterface *child) const @@ -314,7 +314,7 @@ QAccessibleInterface *QAccessibleComboBox::child(int index) const } else if (index == 1 && comboBox()->isEditable()) { return QAccessible::queryAccessibleInterface(comboBox()->lineEdit()); } - return 0; + return nullptr; } int QAccessibleComboBox::childCount() const @@ -327,7 +327,7 @@ QAccessibleInterface *QAccessibleComboBox::childAt(int x, int y) const { if (comboBox()->isEditable() && comboBox()->lineEdit()->rect().contains(x, y)) return child(1); - return 0; + return nullptr; } int QAccessibleComboBox::indexOfChild(const QAccessibleInterface *child) const @@ -432,7 +432,7 @@ bool QAccessibleAbstractScrollArea::isValid() const QAccessibleInterface *QAccessibleAbstractScrollArea::childAt(int x, int y) const { if (!abstractScrollArea()->isVisible()) - return 0; + return nullptr; for (int i = 0; i < childCount(); ++i) { QPoint wpos = accessibleChildren().at(i)->mapToGlobal(QPoint(0, 0)); @@ -440,7 +440,7 @@ QAccessibleInterface *QAccessibleAbstractScrollArea::childAt(int x, int y) const if (rect.contains(x, y)) return child(i); } - return 0; + return nullptr; } QAbstractScrollArea *QAccessibleAbstractScrollArea::abstractScrollArea() const diff --git a/src/widgets/accessible/itemviews.cpp b/src/widgets/accessible/itemviews.cpp index 3bfe215c05..5a7fdf9a03 100644 --- a/src/widgets/accessible/itemviews.cpp +++ b/src/widgets/accessible/itemviews.cpp @@ -121,7 +121,7 @@ QAccessibleTable::~QAccessibleTable() QHeaderView *QAccessibleTable::horizontalHeader() const { - QHeaderView *header = 0; + QHeaderView *header = nullptr; if (false) { #if QT_CONFIG(tableview) } else if (const QTableView *tv = qobject_cast(view())) { @@ -137,7 +137,7 @@ QHeaderView *QAccessibleTable::horizontalHeader() const QHeaderView *QAccessibleTable::verticalHeader() const { - QHeaderView *header = 0; + QHeaderView *header = nullptr; if (false) { #if QT_CONFIG(tableview) } else if (const QTableView *tv = qobject_cast(view())) { @@ -150,19 +150,19 @@ QHeaderView *QAccessibleTable::verticalHeader() const QAccessibleInterface *QAccessibleTable::cellAt(int row, int column) const { if (!view()->model()) - return 0; + return nullptr; Q_ASSERT(role() != QAccessible::Tree); QModelIndex index = view()->model()->index(row, column, view()->rootIndex()); if (Q_UNLIKELY(!index.isValid())) { qWarning() << "QAccessibleTable::cellAt: invalid index: " << index << " for " << view(); - return 0; + return nullptr; } return child(logicalIndex(index)); } QAccessibleInterface *QAccessibleTable::caption() const { - return 0; + return nullptr; } QString QAccessibleTable::columnDescription(int column) const @@ -254,7 +254,7 @@ QList QAccessibleTable::selectedRows() const QAccessibleInterface *QAccessibleTable::summary() const { - return 0; + return nullptr; } bool QAccessibleTable::isColumnSelected(int column) const @@ -422,7 +422,7 @@ QAccessibleInterface *QAccessibleTable::childAt(int x, int y) const if (index.isValid()) { return child(logicalIndex(index)); } - return 0; + return nullptr; } int QAccessibleTable::childCount() const @@ -485,13 +485,13 @@ QAccessibleInterface *QAccessibleTable::parent() const } return QAccessible::queryAccessibleInterface(view()->parent()); } - return 0; + return nullptr; } QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const { if (!view()->model()) - return 0; + return nullptr; auto id = childToId.constFind(logicalIndex); if (id != childToId.constEnd()) @@ -505,7 +505,7 @@ QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const int row = logicalIndex / columns; int column = logicalIndex % columns; - QAccessibleInterface *iface = 0; + QAccessibleInterface *iface = nullptr; if (vHeader) { if (column == 0) { @@ -528,7 +528,7 @@ QAccessibleInterface *QAccessibleTable::child(int logicalIndex) const QModelIndex index = view()->model()->index(row, column, view()->rootIndex()); if (Q_UNLIKELY(!index.isValid())) { qWarning("QAccessibleTable::child: Invalid index at: %d %d", row, column); - return 0; + return nullptr; } iface = new QAccessibleTableCell(view(), index, cellRole()); } @@ -542,7 +542,7 @@ void *QAccessibleTable::interface_cast(QAccessible::InterfaceType t) { if (t == QAccessible::TableInterface) return static_cast(this); - return 0; + return nullptr; } void QAccessibleTable::modelChange(QAccessibleTableModelChangeEvent *event) @@ -676,13 +676,13 @@ QModelIndex QAccessibleTree::indexFromLogical(int row, int column) const QAccessibleInterface *QAccessibleTree::childAt(int x, int y) const { if (!view()->model()) - return 0; + return nullptr; QPoint viewportOffset = view()->viewport()->mapTo(view(), QPoint(0,0)); QPoint indexPosition = view()->mapFromGlobal(QPoint(x, y) - viewportOffset); QModelIndex index = view()->indexAt(indexPosition); if (!index.isValid()) - return 0; + return nullptr; const QTreeView *treeView = qobject_cast(view()); int row = treeView->d_func()->viewIndex(index) + (horizontalHeader() ? 1 : 0); @@ -706,9 +706,9 @@ int QAccessibleTree::childCount() const QAccessibleInterface *QAccessibleTree::child(int logicalIndex) const { if (logicalIndex < 0 || !view()->model() || !view()->model()->columnCount()) - return 0; + return nullptr; - QAccessibleInterface *iface = 0; + QAccessibleInterface *iface = nullptr; int index = logicalIndex; if (horizontalHeader()) { @@ -724,7 +724,7 @@ QAccessibleInterface *QAccessibleTree::child(int logicalIndex) const int column = index % view()->model()->columnCount(); QModelIndex modelIndex = indexFromLogical(row, column); if (!modelIndex.isValid()) - return 0; + return nullptr; iface = new QAccessibleTableCell(view(), modelIndex, cellRole()); } QAccessible::registerAccessibleInterface(iface); @@ -772,7 +772,7 @@ QAccessibleInterface *QAccessibleTree::cellAt(int row, int column) const QModelIndex index = indexFromLogical(row, column); if (Q_UNLIKELY(!index.isValid())) { qWarning("Requested invalid tree cell: %d %d", row, column); - return 0; + return nullptr; } const QTreeView *treeView = qobject_cast(view()); Q_ASSERT(treeView); @@ -841,7 +841,7 @@ void *QAccessibleTableCell::interface_cast(QAccessible::InterfaceType t) return static_cast(this); if (t == QAccessible::ActionInterface) return static_cast(this); - return 0; + return nullptr; } int QAccessibleTableCell::columnExtent() const { return 1; } @@ -869,7 +869,7 @@ QList QAccessibleTableCell::columnHeaderCells() const QHeaderView *QAccessibleTableCell::horizontalHeader() const { - QHeaderView *header = 0; + QHeaderView *header = nullptr; if (false) { #if QT_CONFIG(tableview) @@ -887,7 +887,7 @@ QHeaderView *QAccessibleTableCell::horizontalHeader() const QHeaderView *QAccessibleTableCell::verticalHeader() const { - QHeaderView *header = 0; + QHeaderView *header = nullptr; #if QT_CONFIG(tableview) if (const QTableView *tv = qobject_cast(view)) header = tv->verticalHeader(); @@ -1115,7 +1115,7 @@ QAccessibleInterface *QAccessibleTableCell::parent() const QAccessibleInterface *QAccessibleTableCell::child(int) const { - return 0; + return nullptr; } QAccessibleTableHeaderCell::QAccessibleTableHeaderCell(QAbstractItemView *view_, int index_, Qt::Orientation orientation_) @@ -1143,7 +1143,7 @@ QAccessible::State QAccessibleTableHeaderCell::state() const QRect QAccessibleTableHeaderCell::rect() const { - QHeaderView *header = 0; + QHeaderView *header = nullptr; if (false) { #if QT_CONFIG(tableview) } else if (const QTableView *tv = qobject_cast(view)) { @@ -1206,12 +1206,12 @@ QAccessibleInterface *QAccessibleTableHeaderCell::parent() const QAccessibleInterface *QAccessibleTableHeaderCell::child(int) const { - return 0; + return nullptr; } QHeaderView *QAccessibleTableHeaderCell::headerView() const { - QHeaderView *header = 0; + QHeaderView *header = nullptr; if (false) { #if QT_CONFIG(tableview) } else if (const QTableView *tv = qobject_cast(view)) { diff --git a/src/widgets/accessible/qaccessiblemenu.cpp b/src/widgets/accessible/qaccessiblemenu.cpp index 7f87288520..51ba0adaa6 100644 --- a/src/widgets/accessible/qaccessiblemenu.cpp +++ b/src/widgets/accessible/qaccessiblemenu.cpp @@ -88,8 +88,8 @@ QAccessibleInterface *QAccessibleMenu::childAt(int x, int y) const { QAction *act = menu()->actionAt(menu()->mapFromGlobal(QPoint(x,y))); if(act && act->isSeparator()) - act = 0; - return act ? getOrCreateMenu(menu(), act) : 0; + act = nullptr; + return act ? getOrCreateMenu(menu(), act) : nullptr; } QString QAccessibleMenu::text(QAccessible::Text t) const @@ -112,7 +112,7 @@ QAccessibleInterface *QAccessibleMenu::child(int index) const { if (index < childCount()) return getOrCreateMenu(menu(), menu()->actions().at(index)); - return 0; + return nullptr; } QAccessibleInterface *QAccessibleMenu::parent() const @@ -165,7 +165,7 @@ QAccessibleInterface *QAccessibleMenuBar::child(int index) const if (index < childCount()) { return getOrCreateMenu(menuBar(), menuBar()->actions().at(index)); } - return 0; + return nullptr; } int QAccessibleMenuBar::indexOfChild(const QAccessibleInterface *child) const @@ -195,7 +195,7 @@ QAccessibleInterface *QAccessibleMenuItem::childAt(int x, int y ) const return childInterface; } } - return 0; + return nullptr; } int QAccessibleMenuItem::childCount() const @@ -224,14 +224,14 @@ QAccessibleInterface *QAccessibleMenuItem::child(int index) const { if (index == 0 && action()->menu()) return QAccessible::queryAccessibleInterface(action()->menu()); - return 0; + return nullptr; } void *QAccessibleMenuItem::interface_cast(QAccessible::InterfaceType t) { if (t == QAccessible::ActionInterface) return static_cast(this); - return 0; + return nullptr; } QObject *QAccessibleMenuItem::object() const diff --git a/src/widgets/accessible/qaccessiblewidget.cpp b/src/widgets/accessible/qaccessiblewidget.cpp index 27e6b09dc7..c782e00f4f 100644 --- a/src/widgets/accessible/qaccessiblewidget.cpp +++ b/src/widgets/accessible/qaccessiblewidget.cpp @@ -363,7 +363,7 @@ QAccessibleInterface *QAccessibleWidget::child(int index) const QWidgetList childList = childWidgets(widget()); if (index >= 0 && index < childList.size()) return QAccessible::queryAccessibleInterface(childList.at(index)); - return 0; + return nullptr; } /*! \reimp */ @@ -374,11 +374,11 @@ QAccessibleInterface *QAccessibleWidget::focusChild() const QWidget *fw = widget()->focusWidget(); if (!fw) - return 0; + return nullptr; if (isAncestor(widget(), fw) || fw == widget()) return QAccessible::queryAccessibleInterface(fw); - return 0; + return nullptr; } /*! \reimp */ @@ -522,7 +522,7 @@ void *QAccessibleWidget::interface_cast(QAccessible::InterfaceType t) { if (t == QAccessible::ActionInterface) return static_cast(this); - return 0; + return nullptr; } QT_END_NAMESPACE diff --git a/src/widgets/accessible/qaccessiblewidgetfactory.cpp b/src/widgets/accessible/qaccessiblewidgetfactory.cpp index 0bac45de27..d59da86076 100644 --- a/src/widgets/accessible/qaccessiblewidgetfactory.cpp +++ b/src/widgets/accessible/qaccessiblewidgetfactory.cpp @@ -62,7 +62,7 @@ QT_BEGIN_NAMESPACE QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *object) { - QAccessibleInterface *iface = 0; + QAccessibleInterface *iface = nullptr; if (!object || !object->isWidgetType()) return iface; @@ -79,7 +79,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje #if QT_CONFIG(lineedit) } else if (classname == QLatin1String("QLineEdit")) { if (widget->objectName() == QLatin1String("qt_spinbox_lineedit")) - iface = 0; + iface = nullptr; else iface = new QAccessibleLineEdit(widget); #endif @@ -223,7 +223,7 @@ QAccessibleInterface *qAccessibleFactory(const QString &classname, QObject *obje #endif } else if (classname == QLatin1String("QDesktopScreenWidget")) { - iface = 0; + iface = nullptr; } else if (classname == QLatin1String("QWidget")) { iface = new QAccessibleWidget(widget); } else if (classname == QLatin1String("QWindowContainer")) { diff --git a/src/widgets/accessible/qaccessiblewidgets.cpp b/src/widgets/accessible/qaccessiblewidgets.cpp index 52c953ed3a..574be1f5ea 100644 --- a/src/widgets/accessible/qaccessiblewidgets.cpp +++ b/src/widgets/accessible/qaccessiblewidgets.cpp @@ -332,14 +332,14 @@ QAccessibleStackedWidget::QAccessibleStackedWidget(QWidget *widget) QAccessibleInterface *QAccessibleStackedWidget::childAt(int x, int y) const { if (!stackedWidget()->isVisible()) - return 0; + return nullptr; QWidget *currentWidget = stackedWidget()->currentWidget(); if (!currentWidget) - return 0; + return nullptr; QPoint position = currentWidget->mapFromGlobal(QPoint(x, y)); if (currentWidget->rect().contains(position)) return child(stackedWidget()->currentIndex()); - return 0; + return nullptr; } int QAccessibleStackedWidget::childCount() const @@ -359,7 +359,7 @@ int QAccessibleStackedWidget::indexOfChild(const QAccessibleInterface *child) co QAccessibleInterface *QAccessibleStackedWidget::child(int index) const { if (index < 0 || index >= stackedWidget()->count()) - return 0; + return nullptr; return QAccessible::queryAccessibleInterface(stackedWidget()->widget(index)); } @@ -401,7 +401,7 @@ QAccessibleInterface *QAccessibleMdiArea::child(int index) const QList subWindows = mdiArea()->subWindowList(); QWidget *targetObject = subWindows.value(index); if (!targetObject) - return 0; + return nullptr; return QAccessible::queryAccessibleInterface(targetObject); } @@ -478,7 +478,7 @@ QAccessibleInterface *QAccessibleMdiSubWindow::child(int index) const { QMdiSubWindow *source = mdiSubWindow(); if (index != 0 || !source->widget()) - return 0; + return nullptr; return QAccessible::queryAccessibleInterface(source->widget()); } @@ -554,7 +554,7 @@ int QAccessibleCalendarWidget::indexOfChild(const QAccessibleInterface *child) c QAccessibleInterface *QAccessibleCalendarWidget::child(int index) const { if (index < 0 || index >= childCount()) - return 0; + return nullptr; if (childCount() > 1 && index == 0) return QAccessible::queryAccessibleInterface(navigationBar()); @@ -573,7 +573,7 @@ QAbstractItemView *QAccessibleCalendarWidget::calendarView() const if (child->objectName() == QLatin1String("qt_calendar_calendarview")) return static_cast(child); } - return 0; + return nullptr; } QWidget *QAccessibleCalendarWidget::navigationBar() const @@ -582,7 +582,7 @@ QWidget *QAccessibleCalendarWidget::navigationBar() const if (child->objectName() == QLatin1String("qt_calendar_navigationbar")) return static_cast(child); } - return 0; + return nullptr; } #endif // QT_CONFIG(calendarwidget) @@ -624,7 +624,7 @@ QAccessibleInterface *QAccessibleDockWidget::child(int index) const if (item) return QAccessible::queryAccessibleInterface(item->widget()); } - return 0; + return nullptr; } int QAccessibleDockWidget::indexOfChild(const QAccessibleInterface *child) const @@ -1109,7 +1109,7 @@ QAccessibleInterface *QAccessibleMainWindow::child(int index) const if (index >= 0 && index < kids.count()) { return QAccessible::queryAccessibleInterface(kids.at(index)); } - return 0; + return nullptr; } int QAccessibleMainWindow::childCount() const @@ -1128,10 +1128,10 @@ QAccessibleInterface *QAccessibleMainWindow::childAt(int x, int y) const { QWidget *w = widget(); if (!w->isVisible()) - return 0; + return nullptr; QPoint gp = w->mapToGlobal(QPoint(0, 0)); if (!QRect(gp.x(), gp.y(), w->width(), w->height()).contains(x, y)) - return 0; + return nullptr; const QWidgetList kids = childWidgets(mainWindow()); QPoint rp = mainWindow()->mapFromGlobal(QPoint(x, y)); @@ -1140,7 +1140,7 @@ QAccessibleInterface *QAccessibleMainWindow::childAt(int x, int y) const return QAccessible::queryAccessibleInterface(child); } } - return 0; + return nullptr; } QMainWindow *QAccessibleMainWindow::mainWindow() const diff --git a/src/widgets/accessible/simplewidgets.cpp b/src/widgets/accessible/simplewidgets.cpp index ca74ee4b12..9dbbe9c608 100644 --- a/src/widgets/accessible/simplewidgets.cpp +++ b/src/widgets/accessible/simplewidgets.cpp @@ -364,7 +364,7 @@ QAccessibleInterface *QAccessibleToolButton::child(int index) const #else Q_UNUSED(index) #endif - return 0; + return nullptr; } /* @@ -976,7 +976,7 @@ QAccessibleInterface *QAccessibleWindowContainer::child(int i) const { if (i == 0) return QAccessible::queryAccessibleInterface(container()->containedWindow()); - return 0; + return nullptr; } QWindowContainer *QAccessibleWindowContainer::container() const -- cgit v1.2.3