From 24a0303b9ed7d48c75c4567b93b327b731b2de3b Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Mon, 19 Oct 2020 08:42:14 +0200 Subject: [PATCH] Doc: mention that disconnecting all signals can be dangerous MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-83387 Change-Id: I55c0a267e5490ba0226fd6858c18fd88cc3b8d59 Reviewed-by: Fabian Kosmale Reviewed-by: Giuseppe D'Angelo Reviewed-by: Topi Reiniƶ --- src/corelib/doc/src/includes/qobject.qdocinc | 34 ++++++++++++++++++++ src/corelib/kernel/qobject.cpp | 6 ++++ 2 files changed, 40 insertions(+) create mode 100644 src/corelib/doc/src/includes/qobject.qdocinc diff --git a/src/corelib/doc/src/includes/qobject.qdocinc b/src/corelib/doc/src/includes/qobject.qdocinc new file mode 100644 index 00000000000..1af4d3ae330 --- /dev/null +++ b/src/corelib/doc/src/includes/qobject.qdocinc @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2020 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:FDL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Free Documentation License Usage +** Alternatively, this file may be used under the terms of the GNU Free +** Documentation License version 1.3 as published by the Free Software +** Foundation and appearing in the file included in the packaging of +** this file. Please review the following information to ensure +** the GNU Free Documentation License version 1.3 requirements +** will be met: https://www.gnu.org/licenses/fdl-1.3.html. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +//! [disconnect-all] +\note Disconnecting all signal-slot connections will also disconnect the +\l QObject::destroyed() signal if it is connected. Doing so can adversely +affect classes that rely on this signal for cleaning up resources. It is +recommended to disconnect only the specific signals that were connected by +application code. +//! [disconnect-all] diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index f3fd249d094..28dd89397b6 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -2960,6 +2960,8 @@ QMetaObject::Connection QObject::connect(const QObject *sender, const QMetaMetho if \a receiver is left out, so you cannot disconnect a specifically-named slot on all objects. + \include includes/qobject.qdocinc disconnect-all + \sa connect() */ bool QObject::disconnect(const QObject *sender, const char *signal, @@ -3095,6 +3097,8 @@ bool QObject::disconnect(const QObject *sender, const char *signal, In the same way \nullptr can be used for \a receiver in the meaning "any receiving object". In this case method should also be QMetaMethod(). \a sender parameter should be never \nullptr. + \include includes/qobject.qdocinc disconnect-all + \sa disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method) */ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal, @@ -3172,6 +3176,8 @@ bool QObject::disconnect(const QObject *sender, const QMetaMethod &signal, A signal-slot connection is removed when either of the objects involved are destroyed. + + \include includes/qobject.qdocinc disconnect-all */ /*!