Skip to content

Commit

Permalink
Documentation: Add \nullptr macro and use where applicable
Browse files Browse the repository at this point in the history
Qt for Python users reading the documentation assume that int(0) can
be passed for pointer parameters. Use the newly introduced \nullptr to
disambiguate this.

In a follow-up step, the \nullptr macro can be defined as None
when generating the Qt for Python documentation.

Task-number: PYSIDE-903
Change-Id: I3a45f87175a0668ab5f3f95f0aff409f7e3ef027
Reviewed-by: Cristian Maureira-Fredes <[email protected]>
Reviewed-by: Christian Tismer <[email protected]>
Reviewed-by: Venugopal Shivashankar <[email protected]>
Reviewed-by: Paul Wicking <[email protected]>
  • Loading branch information
FriedemannKleint committed Jan 10, 2019
1 parent 574b569 commit 3eac688
Show file tree
Hide file tree
Showing 36 changed files with 62 additions and 61 deletions.
1 change: 1 addition & 0 deletions doc/global/macros.qdocconf
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ macro.macos = "macOS"
macro.menu = "\\b"
macro.oslash.HTML = "&oslash;"
macro.ouml.HTML = "&ouml;"
macro.nullptr = "\\c{nullptr}"
macro.QA = "\\e{Qt Assistant}"
macro.QD = "\\e{Qt Designer}"
macro.QL = "\\e{Qt Linguist}"
Expand Down
14 changes: 7 additions & 7 deletions src/gui/accessible/qaccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -654,7 +654,7 @@ void QAccessible::removeActivationObserver(ActivationObserver *observer)
/*!
If a QAccessibleInterface implementation exists for the given \a object,
this function returns a pointer to the implementation; otherwise it
returns 0.
returns \nullptr.
The function calls all installed factory functions (from most
recently installed to least recently installed) until one is found
Expand Down Expand Up @@ -770,7 +770,7 @@ QAccessible::Id QAccessible::uniqueId(QAccessibleInterface *iface)
/*!
Returns the QAccessibleInterface belonging to the \a id.
Returns 0 if the id is invalid.
Returns \nullptr if the id is invalid.
*/
QAccessibleInterface *QAccessible::accessibleInterface(Id id)
{
Expand Down Expand Up @@ -1119,7 +1119,7 @@ QAccessibleInterface *QAccessibleInterface::focusChild() const
\fn QAccessibleInterface *QAccessibleInterface::childAt(int x, int y) const
Returns the QAccessibleInterface of a child that contains the screen coordinates (\a x, \a y).
If there are no children at this position this function returns 0.
If there are no children at this position this function returns \nullptr.
The returned accessible must be a child, but not necessarily a direct child.
This function is only relyable for visible objects (invisible
Expand All @@ -1139,7 +1139,7 @@ QAccessibleInterface *QAccessibleInterface::focusChild() const
Returns the QAccessibleInterface of the parent in the accessible object hierarchy.
Returns 0 if no parent exists (e.g. for the top level application object).
Returns \nullptr if no parent exists (e.g. for the top level application object).
\sa child()
*/
Expand All @@ -1150,7 +1150,7 @@ QAccessibleInterface *QAccessibleInterface::focusChild() const
Returns the accessible child with index \a index.
0-based index. The number of children of an object can be checked with childCount.
Returns 0 when asking for an invalid child (e.g. when the child became invalid in the meantime).
Returns \nullptr when asking for an invalid child (e.g. when the child became invalid in the meantime).
\sa childCount(), parent()
*/
Expand Down Expand Up @@ -1356,7 +1356,7 @@ QAccessibleEvent::~QAccessibleEvent()
\internal
Returns the uniqueId of the QAccessibleInterface represented by this event.
In case the object() function returns 0 this is the only way to access the
In case the object() function returns \nullptr, this is the only way to access the
interface.
*/
QAccessible::Id QAccessibleEvent::uniqueId() const
Expand Down Expand Up @@ -1786,7 +1786,7 @@ QAccessibleInterface *QAccessibleEvent::accessibleInterface() const
(This means that at least one interface among the ancestors should
return a valid QWindow pointer).
The default implementation returns 0.
The default implementation returns \nullptr.
*/
QWindow *QAccessibleInterface::window() const
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/image/qimage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ QImageData::QImageData()
\internal
Creates a new image data.
Returns 0 if invalid parameters are give or anything else failed.
Returns \nullptr if invalid parameters are give or anything else failed.
*/
QImageData * QImageData::create(const QSize &size, QImage::Format format)
{
Expand Down
18 changes: 9 additions & 9 deletions src/gui/itemmodels/qstandarditemmodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -879,8 +879,8 @@ QStandardItem::~QStandardItem()
}

/*!
Returns the item's parent item, or 0 if the item has no parent.
\note For toplevel items parent() returns 0. To receive toplevel
Returns the item's parent item, or \nullptr if the item has no parent.
\note For toplevel items parent() returns \nullptr. To receive toplevel
item's parent use QStandardItemModel::invisibleRootItem() instead.
\sa child(), QStandardItemModel::invisibleRootItem()
Expand Down Expand Up @@ -1548,7 +1548,7 @@ QModelIndex QStandardItem::index() const
Returns the QStandardItemModel that this item belongs to.
If the item is not a child of another item that belongs to the model, this
function returns 0.
function returns \nullptr.
\sa index()
*/
Expand Down Expand Up @@ -1865,7 +1865,7 @@ void QStandardItem::setChild(int row, int column, QStandardItem *item)

/*!
Returns the child item at (\a row, \a column) if one has been set; otherwise
returns 0.
returns \nullptr.
\sa setChild(), takeChild(), parent()
*/
Expand All @@ -1881,7 +1881,7 @@ QStandardItem *QStandardItem::child(int row, int column) const
/*!
Removes the child item at (\a row, \a column) without deleting it, and returns
a pointer to the item. If there was no child at the given location, then
this function returns 0.
this function returns \nullptr.
Note that this function, unlike takeRow() and takeColumn(), does not affect
the dimensions of the child table.
Expand Down Expand Up @@ -2283,7 +2283,7 @@ void QStandardItemModel::clear()
itemPrototype()), and set it in the parent item's child table, if no item
already exists at that index.
If \a index is an invalid index, this function returns 0.
If \a index is an invalid index, this function returns \nullptr.
\sa indexFromItem()
*/
Expand Down Expand Up @@ -2380,7 +2380,7 @@ void QStandardItemModel::setItem(int row, int column, QStandardItem *item)
\since 4.2
Returns the item for the given \a row and \a column if one has been set;
otherwise returns 0.
otherwise returns \nullptr.
\sa setItem(), takeItem(), itemFromIndex()
*/
Expand Down Expand Up @@ -2453,7 +2453,7 @@ void QStandardItemModel::setHorizontalHeaderItem(int column, QStandardItem *item
\since 4.2
Returns the horizontal header item for \a column if one has been set;
otherwise returns 0.
otherwise returns \nullptr.
\sa setHorizontalHeaderItem(), verticalHeaderItem()
*/
Expand Down Expand Up @@ -2509,7 +2509,7 @@ void QStandardItemModel::setVerticalHeaderItem(int row, QStandardItem *item)
\since 4.2
Returns the vertical header item for row \a row if one has been set;
otherwise returns 0.
otherwise returns \nullptr.
\sa setVerticalHeaderItem(), horizontalHeaderItem()
*/
Expand Down
4 changes: 2 additions & 2 deletions src/gui/kernel/qevent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3072,7 +3072,7 @@ QDropEvent::~QDropEvent()
/*!
If the source of the drag operation is a widget in this
application, this function returns that source; otherwise it
returns 0. The source of the operation is the first parameter to
returns \nullptr. The source of the operation is the first parameter to
the QDrag object used instantiate the drag.
This is useful if your widget needs special behavior when dragging
Expand Down Expand Up @@ -3514,7 +3514,7 @@ QActionEvent::~QActionEvent()
\fn QAction *QActionEvent::before() const
If type() is \l ActionAdded, returns the action that should
appear before action(). If this function returns 0, the action
appear before action(). If this function returns \nullptr, the action
should be appended to already existing actions on the same
widget.
Expand Down
2 changes: 1 addition & 1 deletion src/gui/kernel/qguiapplication.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3747,7 +3747,7 @@ Qt::LayoutDirection QGuiApplication::layoutDirection()

Returns the active application override cursor.

This function returns 0 if no application cursor has been defined (i.e. the
This function returns \nullptr if no application cursor has been defined (i.e. the
internal cursor stack is empty).

\sa setOverrideCursor(), restoreOverrideCursor()
Expand Down
2 changes: 1 addition & 1 deletion src/gui/kernel/qopenglcontext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1118,7 +1118,7 @@ void QOpenGLContext::swapBuffers(QSurface *surface)
/*!
Resolves the function pointer to an OpenGL extension function, identified by \a procName

Returns 0 if no such function can be found.
Returns \nullptr if no such function can be found.
*/
QFunctionPointer QOpenGLContext::getProcAddress(const QByteArray &procName) const
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/kernel/qplatformcursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ QT_BEGIN_NAMESPACE

\a windowCursor is a pointer to the QCursor that should be displayed.

To unset the cursor of \a window, 0 is passed. This means \a window does not have
To unset the cursor of \a window, \nullptr is passed. This means \a window does not have
a cursor set and the cursor of a the first parent window which has a cursor explicitly
set or the system default cursor should take effect.

Expand Down
2 changes: 1 addition & 1 deletion src/gui/kernel/qplatformintegration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ void QPlatformIntegration::destroy()
/*!
Returns the platforms input context.

The default implementation returns 0, implying no input method support.
The default implementation returns \nullptr, implying no input method support.
*/
QPlatformInputContext *QPlatformIntegration::inputContext() const
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/kernel/qplatformscreen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ QString QPlatformScreen::serialNumber() const
/*!
Reimplement this function in subclass to return the cursor of the screen.

The default implementation returns 0.
The default implementation returns \nullptr.
*/
QPlatformCursor *QPlatformScreen::cursor() const
{
Expand Down
2 changes: 1 addition & 1 deletion src/gui/kernel/qwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2644,7 +2644,7 @@ QOpenGLContext *QWindowPrivate::shareContext() const
native window, or to embed a native window inside a QWindow.

If foreign windows are not supported or embedding the native window
failed in the platform plugin, this function returns 0.
failed in the platform plugin, this function returns \nullptr.

\note The resulting QWindow should not be used to manipulate the underlying
native window (besides re-parenting), or to observe state changes of the
Expand Down
2 changes: 1 addition & 1 deletion src/gui/painting/qpaintengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,7 +913,7 @@ void QPaintEngine::setPaintDevice(QPaintDevice *device)

/*!
Returns the device that this engine is painting on, if painting is
active; otherwise returns 0.
active; otherwise returns \nullptr.
*/
QPaintDevice *QPaintEngine::paintDevice() const
{
Expand Down
6 changes: 3 additions & 3 deletions src/gui/text/qtextcursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2116,7 +2116,7 @@ QTextList *QTextCursor::createList(QTextListFormat::Style style)

/*!
Returns the current list if the cursor position() is inside a
block that is part of a list; otherwise returns 0.
block that is part of a list; otherwise returns \nullptr.

\sa insertList(), createList()
*/
Expand Down Expand Up @@ -2176,7 +2176,7 @@ QTextTable *QTextCursor::insertTable(int rows, int cols, const QTextTableFormat

/*!
Returns a pointer to the current table if the cursor position()
is inside a block that is part of a table; otherwise returns 0.
is inside a block that is part of a table; otherwise returns \nullptr.

\sa insertTable()
*/
Expand Down Expand Up @@ -2213,7 +2213,7 @@ QTextFrame *QTextCursor::insertFrame(const QTextFrameFormat &format)
}

/*!
Returns a pointer to the current frame. Returns 0 if the cursor is invalid.
Returns a pointer to the current frame. Returns \nullptr if the cursor is invalid.

\sa insertFrame()
*/
Expand Down
2 changes: 1 addition & 1 deletion src/gui/text/qtextobject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1301,7 +1301,7 @@ const QTextDocument *QTextBlock::document() const

/*!
If the block represents a list item, returns the list that the item belongs
to; otherwise returns 0.
to; otherwise returns \nullptr.
*/
QTextList *QTextBlock::textList() const
{
Expand Down
2 changes: 1 addition & 1 deletion src/network/access/qftp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2154,7 +2154,7 @@ QFtp::Command QFtp::currentCommand() const
\internal
Returns the QIODevice pointer that is used by the FTP command to read data
from or store data to. If there is no current FTP command being executed or
if the command does not use an IO device, this function returns 0.
if the command does not use an IO device, this function returns \nullptr.

This function can be used to delete the QIODevice in the slot connected to
the commandFinished() signal.
Expand Down
2 changes: 1 addition & 1 deletion src/network/access/qnetworkrequest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,7 @@ void QNetworkRequest::setOriginatingObject(QObject *object)
\since 4.6

Returns a reference to the object that initiated this
network request; returns 0 if not set or the object has
network request; returns \nullptr if not set or the object has
been destroyed.

\sa setOriginatingObject()
Expand Down
2 changes: 1 addition & 1 deletion src/testlib/qtestcase.qdoc
Original file line number Diff line number Diff line change
Expand Up @@ -959,7 +959,7 @@
\overload
\since 5.8

Returns a string containing \c{nullptr}.
Returns a string containing \nullptr.
*/

/*!
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/dialogs/qdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -969,7 +969,7 @@ Qt::Orientation QDialog::orientation() const

Sets the widget, \a extension, to be the dialog's extension,
deleting any previous extension. The dialog takes ownership of the
extension. Note that if 0 is passed any existing extension will be
extension. Note that if \nullptr is passed, any existing extension will be
deleted. This function must only be called while the dialog is hidden.

Instead of using this functionality, we recommend that you simply call
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/dialogs/qprogressdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,7 @@ void QProgressDialog::setLabelText(const QString &text)
Sets the cancel button to the push button, \a cancelButton. The
progress dialog takes ownership of this button which will be deleted
when necessary, so do not pass the address of an object that is on
the stack, i.e. use new() to create the button. If 0 is passed then
the stack, i.e. use new() to create the button. If \nullptr is passed,
no cancel button will be shown.

\sa setCancelButtonText()
Expand Down
6 changes: 3 additions & 3 deletions src/widgets/effects/qgraphicseffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ QRectF QGraphicsEffect::sourceBoundingRect(Qt::CoordinateSystem system) const

/*!
Returns a pointer to the item if this source is a QGraphicsItem; otherwise
returns 0.
returns \nullptr.

\sa widget()
*/
Expand All @@ -189,7 +189,7 @@ const QGraphicsItem *QGraphicsEffectSource::graphicsItem() const

/*!
Returns a pointer to the widget if this source is a QWidget; otherwise
returns 0.
returns \nullptr.

\sa graphicsItem()
*/
Expand All @@ -200,7 +200,7 @@ const QWidget *QGraphicsEffectSource::widget() const

/*!
Returns a pointer to the style options (used when drawing the source) if
available; otherwise returns 0.
available; otherwise returns \nullptr.

\sa graphicsItem(), widget()
*/
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/graphicsview/qgraphicsitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1726,8 +1726,8 @@ QGraphicsItem *QGraphicsItem::topLevelItem() const
/*!
\since 4.6

Returns a pointer to the item's parent, cast to a QGraphicsObject. returns 0 if the parent item
is not a QGraphicsObject.
Returns a pointer to the item's parent, cast to a QGraphicsObject. Returns
\nullptr if the parent item is not a QGraphicsObject.

\sa parentItem(), childItems()
*/
Expand Down
2 changes: 1 addition & 1 deletion src/widgets/graphicsview/qgraphicslayoutitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ bool QGraphicsLayoutItemPrivate::hasWidthForHeight() const
protected constructor, or by calling setParentLayoutItem(). The
parentLayoutItem() function returns a pointer to the item's layoutItem
parent. If the item's parent is 0 or if the parent does not inherit
from QGraphicsItem, the parentLayoutItem() function then returns 0.
from QGraphicsItem, the parentLayoutItem() function then returns \nullptr.
isLayout() returns \c true if the QGraphicsLayoutItem subclass is itself a
layout, or false otherwise.

Expand Down
2 changes: 1 addition & 1 deletion src/widgets/itemviews/qabstractitemdelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ QAbstractItemDelegate::~QAbstractItemDelegate()
model being used. The editor's parent widget is specified by \a parent,
and the item options by \a option.

The base implementation returns 0. If you want custom editing you
The base implementation returns \nullptr. If you want custom editing you
will need to reimplement this function.

The returned editor widget should have Qt::StrongFocus;
Expand Down
4 changes: 2 additions & 2 deletions src/widgets/itemviews/qlistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1375,7 +1375,7 @@ void QListWidget::setSelectionModel(QItemSelectionModel *selectionModel)

/*!
Returns the item that occupies the given \a row in the list if one has been
set; otherwise returns 0.
set; otherwise returns \nullptr.

\sa row()
*/
Expand Down Expand Up @@ -1442,7 +1442,7 @@ void QListWidget::insertItems(int row, const QStringList &labels)

/*!
Removes and returns the item from the given \a row in the list widget;
otherwise returns 0.
otherwise returns \nullptr.

Items removed from a list widget will not be managed by Qt, and will need
to be deleted manually.
Expand Down
Loading

0 comments on commit 3eac688

Please sign in to comment.