Include what you need: <QPointer>

All these TUs relied on transitive includes of qpointer.h, maybe to a
large extent via qevent.h, though, given that qevent.h is more or less
the only public QtBase header that includes qpointer.h, something else
seems to be at play here.

Said qevent.h actually needs QPointer in-name-only, so a forward
declaration would suffice. Prepare for qevent.h dropping the include.

The algorithm I used was:

If the TU mentions 'passiveGrabbers', the name of the QEvent function
that returns QPointers, and the TU doesn't have qpointer.h included
explicitly, include it. That may produce False Positives, but better
safe than sorry. Otherwise, in src/, add an include to all source and
header files which mention QPointer. Exception: if foo.h of a foo.cpp
already includes it, don't include again.

Task-number: QTBUG-117670
Change-Id: I3321cccdb41ce0ba6d8a709cea92427aba398254
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
This commit is contained in:
Marc Mutz 2023-10-05 17:26:25 +02:00
parent 0b6d2d9187
commit 4a7c76d4a5
76 changed files with 144 additions and 0 deletions

View File

@ -36,6 +36,7 @@
#endif
#endif
#include <qlibraryinfo.h>
#include <qpointer.h>
#include <qvarlengtharray.h>
#include <private/qfactoryloader_p.h>
#include <private/qfunctions_p.h>

View File

@ -16,6 +16,7 @@
#include <private/qthread_p.h>
#include <QtCore/QLoggingCategory>
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE

View File

@ -6,6 +6,8 @@
#include "qdeadlinetimer.h"
#include "qcoreapplication.h"
#include <QtCore/qpointer.h>
#include <algorithm>
#include <memory>

View File

@ -21,6 +21,8 @@
#if QT_CONFIG(shortcut)
# include <QtGui/private/qshortcutmap_p.h>
#endif
#include <QtCore/qpointer.h>
#include "private/qobject_p.h"
QT_REQUIRE_CONFIG(action);

View File

@ -21,6 +21,8 @@
#if QT_CONFIG(shortcut)
# include <QtGui/private/qshortcutmap_p.h>
#endif
#include <QtCore/qpointer.h>
#include "private/qobject_p.h"
QT_REQUIRE_CONFIG(action);

View File

@ -27,6 +27,8 @@
#include "private/qobject_p.h"
#include "QtGui/qbackingstore.h"
#include <QtCore/qpointer.h>
QT_REQUIRE_CONFIG(draganddrop);
QT_BEGIN_NAMESPACE

View File

@ -9,6 +9,8 @@
#include <qpoint.h>
#include "qdnd_p.h"
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE
/*!

View File

@ -2,6 +2,7 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
#include "qevent.h"
#include "qcursor.h"
#include "private/qguiapplication_p.h"
#include "private/qinputdevice_p.h"
@ -9,6 +10,7 @@
#include "qpa/qplatformintegration.h"
#include "private/qevent_p.h"
#include "private/qeventpoint_p.h"
#include "qfile.h"
#include "qhashfunctions.h"
#include "qmetaobject.h"
@ -16,6 +18,7 @@
#include "qevent_p.h"
#include "qmath.h"
#include "qloggingcategory.h"
#include "qpointer.h"
#if QT_CONFIG(draganddrop)
#include <qpa/qplatformdrag.h>

View File

@ -17,7 +17,9 @@
#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/qevent.h>
#include <QtCore/qloggingcategory.h>
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE

View File

@ -34,6 +34,8 @@
# include "private/qshortcutmap_p.h"
#endif
#include <QtCore/qpointer.h>
#include <memory>
QT_BEGIN_NAMESPACE

View File

@ -20,6 +20,8 @@
#include <QtGui/qpointingdevice.h>
#include <QtGui/private/qtguiglobal_p.h>
#include <QtGui/private/qinputdevice_p.h>
#include <QtCore/qpointer.h>
#include <QtCore/private/qflatmap_p.h>
QT_BEGIN_NAMESPACE

View File

@ -26,6 +26,8 @@
#include <QtGui/qicon.h>
#include <QtGui/qpalette.h>
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE
class Q_GUI_EXPORT QWindowPrivate : public QObjectPrivate

View File

@ -19,7 +19,9 @@
#include "private/qobject_p.h"
#include "qtextdocument_p.h"
#include "qabstracttextdocumentlayout.h"
#include "QtCore/qhash.h"
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE

View File

@ -25,6 +25,7 @@
#include <qbasictimer.h>
#include "private/qfunctions_p.h"
#include <qloggingcategory.h>
#include <QtCore/qpointer.h>
#include <algorithm>

View File

@ -40,6 +40,7 @@
# include <QtNetwork/qtcpsocket.h>
#endif
#include <QtCore/qpointer.h>
#include <QtCore/qscopedpointer.h>
#include <memory>

View File

@ -42,6 +42,8 @@ Q_MOC_INCLUDE(<QtNetwork/QAuthenticator>)
#include <private/qdecompresshelper_p.h>
#include <QtCore/qpointer.h>
QT_REQUIRE_CONFIG(http);
QT_BEGIN_NAMESPACE

View File

@ -19,7 +19,9 @@
#include "qnetworkreply.h"
#include "qnetworkreply_p.h"
#include "qnetworkaccessmanager.h"
#include <QFile>
#include <QtCore/qpointer.h>
#include <private/qabstractfileengine_p.h>
QT_BEGIN_NAMESPACE

View File

@ -21,6 +21,8 @@
#include <qendian.h>
#include <qnetworkinterface.h>
#include <QtCore/qpointer.h>
#include <memory>
QT_BEGIN_NAMESPACE

View File

@ -6,6 +6,8 @@
#include "qopenglpaintengine_p.h"
#include <private/qpainter_p.h>
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE
class QOpenGLCustomShaderStagePrivate

View File

@ -15,6 +15,8 @@
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qpointingdevice_p.h>
#include <QtCore/qpointer.h>
#include <mutex>
#ifdef Q_OS_FREEBSD

View File

@ -15,7 +15,9 @@
#include <QtCore/private/qjnihelpers_p.h>
#include <QtCore/QJniObject>
#include <QtGui/private/qhighdpiscaling_p.h>
#include <QtCore/QObject>
#include <QtCore/qpointer.h>
#include <QtCore/qvarlengtharray.h>
static const char m_qtTag[] = "Qt A11Y";

View File

@ -9,6 +9,8 @@
#include <functional>
#include <jni.h>
#include <qevent.h>
#include <QtCore/qpointer.h>
#include <QTimer>
QT_BEGIN_NAMESPACE

View File

@ -56,6 +56,7 @@
#include <QtCore/private/qcfsocketnotifier_p.h>
#include <QtCore/private/qtimerinfo_unix_p.h>
#include <QtCore/qloggingcategory.h>
#include <QtCore/qpointer.h>
#include <CoreFoundation/CoreFoundation.h>

View File

@ -19,6 +19,7 @@
#include "qcocoaapplicationdelegate.h"
#include <QtCore/private/qcore_mac_p.h>
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE

View File

@ -9,6 +9,8 @@
#include <qpa/qplatformmenu.h>
#include "qcocoamenu.h"
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE
class QCocoaWindow;

View File

@ -8,6 +8,8 @@
#include <qpa/qplatformmenu.h>
#include <QtGui/QImage>
#include <QtCore/qpointer.h>
Q_FORWARD_DECLARE_OBJC_CLASS(NSMenuItem);
Q_FORWARD_DECLARE_OBJC_CLASS(NSMenu);
Q_FORWARD_DECLARE_OBJC_CLASS(NSObject);

View File

@ -16,6 +16,8 @@
#include <QtCore/qvarlengtharray.h>
#include <QtGui/private/qapplekeymapper_p.h>
#include <QtCore/qpointer.h>
static NSString *qt_mac_removePrivateUnicode(NSString *string)
{
if (const int len = string.length) {

View File

@ -7,6 +7,8 @@
#include <QtGui>
#include <QtGui/qutimimeconverter.h>
#include <QtCore/qpointer.h>
#include <ApplicationServices/ApplicationServices.h>
QT_BEGIN_NAMESPACE

View File

@ -12,6 +12,7 @@
#include <QtCore/qset.h>
#include <QtCore/qthreadstorage.h>
#include <QtCore/qfileselector.h>
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE

View File

@ -16,6 +16,8 @@
#include "qiosoptionalplugininterface.h"
#include "qiosdocumentpickercontroller.h"
#include <QtCore/qpointer.h>
using namespace Qt::StringLiterals;
QIOSFileDialog::QIOSFileDialog()

View File

@ -18,6 +18,8 @@
#include <QGuiApplication>
#include <QtGui/private/qwindow_p.h>
#include <QtCore/qpointer.h>
// -------------------------------------------------------------------------
static QUIView *focusView()

View File

@ -11,6 +11,8 @@
#import "quiview.h"
#include <QtCore/qpointer.h>
class QIOSMenu;
@class QUIMenuController;
@class QUIPickerView;

View File

@ -21,6 +21,8 @@
#include "qioswindow.h"
#include "quiview.h"
#include <QtCore/qpointer.h>
// -------------------------------------------------------------------------
@interface QIOSViewController ()

View File

@ -28,6 +28,7 @@
#include <QtCore/qdebug.h>
#include <QtCore/qbuffer.h>
#include <QtCore/qpoint.h>
#include <QtCore/qpointer.h>
#include <shlobj.h>

View File

@ -20,6 +20,8 @@
#include "private/qdialog_p.h"
#include "QtPrintSupport/qabstractprintdialog.h"
#include <QtCore/qpointer.h>
QT_REQUIRE_CONFIG(printdialog);
QT_BEGIN_NAMESPACE

View File

@ -28,6 +28,8 @@
#include <QtWidgets/qformlayout.h>
#include <QtWidgets/qlabel.h>
#include <QtCore/qpointer.h>
static void _q_ppd_initResources()
{
static bool resourcesInitialized = false;

View File

@ -43,6 +43,8 @@
#include <qpa/qplatformservices.h>
#include <private/qguiapplication_p.h>
#include <QtCore/qpointer.h>
#include <algorithm>
QT_BEGIN_NAMESPACE

View File

@ -21,6 +21,8 @@
#include "qfontdatabase.h"
#include "qfontdialog.h"
#include <qpa/qplatformdialoghelper.h>
#include <QtCore/qpointer.h>
#include "qsharedpointer.h"
QT_REQUIRE_CONFIG(fontdialog);

View File

@ -18,6 +18,8 @@
#include "qevent.h"
#include "qdialog_p.h"
#include <QtCore/qpointer.h>
QT_USE_NAMESPACE
enum CandidateSignal {

View File

@ -32,6 +32,7 @@
#include <QtCore/qanystringview.h>
#include <QtCore/qdebug.h>
#include <QtCore/qpointer.h>
#include <QtCore/qversionnumber.h>
#ifdef Q_OS_WIN

View File

@ -17,6 +17,9 @@
#include "qelapsedtimer.h"
#include "qscopedvaluerollback.h"
#include <private/qdialog_p.h>
#include <QtCore/qpointer.h>
#include <limits.h>
using namespace std::chrono_literals;

View File

@ -1,6 +1,8 @@
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QtCore/qpointer.h>
//! [0]
QFormLayout *formLayout = new QFormLayout(this);
formLayout->addRow(tr("&Name:"), nameLineEdit);

View File

@ -19,6 +19,8 @@
#include "qgraphicsproxywidget.h"
#include "private/qgraphicswidget_p.h"
#include <QtCore/qpointer.h>
QT_REQUIRE_CONFIG(graphicsview);
QT_BEGIN_NAMESPACE

View File

@ -216,6 +216,8 @@
#include <private/qgesturemanager_p.h>
#include <private/qpathclipper_p.h>
#include <QtCore/qpointer.h>
// #define GESTURE_DEBUG
#ifndef GESTURE_DEBUG
# define DEBUG if (0) qDebug

View File

@ -25,6 +25,8 @@
#include <private/qabstractscrollarea_p.h>
#include <private/qapplication_p.h>
#include <QtCore/qpointer.h>
QT_REQUIRE_CONFIG(graphicsview);
QT_BEGIN_NAMESPACE

View File

@ -24,9 +24,12 @@
#include "QtCore/qmimedata.h"
#include "QtGui/qpainter.h"
#include "QtGui/qregion.h"
#include "QtCore/qdebug.h"
#include "QtCore/qbasictimer.h"
#include "QtCore/qelapsedtimer.h"
#include <QtCore/qpointer.h>
#include <array>

View File

@ -7,8 +7,10 @@
#include "qmetaobject.h"
#include "qwidget.h"
#include "qstyleditemdelegate.h"
#include "private/qobject_p.h"
#include "private/qabstractitemmodel_p.h"
#include <QtCore/qpointer.h>
#include <array>
#include <iterator>

View File

@ -20,6 +20,8 @@
#include <QtWidgets/qmenu.h>
#endif
#include <QtCore/qpointer.h>
QT_REQUIRE_CONFIG(action);
QT_BEGIN_NAMESPACE

View File

@ -21,6 +21,8 @@
#include "private/qwidget_p.h"
#include "qgesturerecognizer.h"
#include <QtCore/qpointer.h>
#ifndef QT_NO_GESTURES
#include <functional>

View File

@ -8,6 +8,8 @@
#include "private/qwidget_p.h"
#include "private/qlayoutengine_p.h"
#include <QtCore/qpointer.h>
#include <memory>
QT_BEGIN_NAMESPACE

View File

@ -42,6 +42,8 @@
#include <qpa/qplatformbackingstore.h>
#include <QtGui/private/qbackingstorerhisupport_p.h>
#include <QtCore/qpointer.h>
#include <vector>
#include <memory>

View File

@ -18,6 +18,8 @@
#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qaction_widgets_p.h"
#include <QtCore/qpointer.h>
QT_REQUIRE_CONFIG(action);
QT_BEGIN_NAMESPACE

View File

@ -22,6 +22,8 @@
#include <QtGui/private/qevent_p.h>
#include <QtWidgets/qwidget.h>
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE

View File

@ -14,6 +14,8 @@
#include <QAbstractScrollArea>
#include <QPainter>
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;

View File

@ -20,6 +20,8 @@
#include "qcommonstyle_p.h"
#include "qproxystyle.h"
#include <QtCore/qpointer.h>
#ifndef QT_NO_STYLE_PROXY
QT_BEGIN_NAMESPACE

View File

@ -25,7 +25,9 @@
#include "qcompleter.h"
#include "qstyleditemdelegate.h"
#include "QtGui/qpainter.h"
#include "private/qabstractproxymodel_p.h"
#include <QtCore/qpointer.h>
QT_REQUIRE_CONFIG(completer);

View File

@ -20,6 +20,8 @@
#include "qgesturerecognizer.h"
#include "private/qgesture_p.h"
#include "qscroller.h"
#include <QtCore/qpointer.h>
#include "qscopedpointer.h"
#ifndef QT_NO_GESTURES

View File

@ -21,6 +21,8 @@
#endif
#include <qpa/qplatformtheme.h>
#include <QtCore/qpointer.h>
#include <algorithm>
QT_BEGIN_NAMESPACE

View File

@ -26,6 +26,7 @@
# include <qaccessible.h>
#endif
#include <QtCore/qpointer.h>
//#define QABSTRACTSPINBOX_QSBDEBUG
#ifdef QABSTRACTSPINBOX_QSBDEBUG

View File

@ -50,6 +50,8 @@
#endif
#include <array>
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE
using namespace Qt::StringLiterals;

View File

@ -28,6 +28,7 @@
#include "private/qdatetimeparser_p.h"
#include "qdebug.h"
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE

View File

@ -16,6 +16,8 @@
#include "qdialogbuttonbox.h"
#include "qdialogbuttonbox_p.h"
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE
/*!

View File

@ -22,6 +22,7 @@
#include <qpa/qplatformtheme.h>
#include "qdebug.h"
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE

View File

@ -33,6 +33,8 @@
#include "qmenu.h"
#endif
#include <QtCore/qpointer.h>
#include <optional>
QT_BEGIN_NAMESPACE

View File

@ -37,7 +37,9 @@
#if QT_CONFIG(toolbar)
#include "qtoolbararealayout_p.h"
#endif
#include <QtCore/qloggingcategory.h>
#include <QtCore/qpointer.h>
QT_REQUIRE_CONFIG(mainwindow);

View File

@ -29,6 +29,8 @@ QT_REQUIRE_CONFIG(mdiarea);
#include <private/qmdisubwindow_p.h>
#include <private/qabstractscrollarea_p.h>
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE
namespace QMdi {

View File

@ -29,6 +29,8 @@
#include <qpa/qplatformmenu.h>
#include <QtCore/qpointer.h>
#include <functional>
QT_REQUIRE_CONFIG(menu);

View File

@ -20,6 +20,8 @@
#include <private/qmenu_p.h> // Mac needs what in this file!
#include <qpa/qplatformmenu.h>
#include <QtCore/qpointer.h>
QT_REQUIRE_CONFIG(menubar);
QT_BEGIN_NAMESPACE

View File

@ -32,6 +32,8 @@
#include "private/qwidgettextcontrol_p.h"
#include <QtCore/qpointer.h>
QT_REQUIRE_CONFIG(textedit);
QT_BEGIN_NAMESPACE

View File

@ -7,6 +7,8 @@
#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qabstractbutton_p.h"
#include <QtCore/qpointer.h>
QT_REQUIRE_CONFIG(pushbutton);
//

View File

@ -20,6 +20,8 @@
#include "private/qabstractscrollarea_p.h"
#include <QtWidgets/qscrollbar.h>
#include <QtCore/qpointer.h>
QT_REQUIRE_CONFIG(scrollarea);
QT_BEGIN_NAMESPACE

View File

@ -12,7 +12,10 @@
#if QT_CONFIG(menu)
#include "qmenu.h"
#endif
#include <QtCore/qelapsedtimer.h>
#include <QtCore/qpointer.h>
#if QT_CONFIG(accessibility)
#include "qaccessible.h"

View File

@ -18,6 +18,8 @@
#include <qpa/qplatformtheme.h>
#include <QtWidgets/qabstractscrollarea.h>
#include <QtCore/qpointer.h>
QT_BEGIN_NAMESPACE
static QWidget *qt_sizegrip_topLevelWidget(QWidget* w)

View File

@ -18,6 +18,8 @@
#include <QtWidgets/private/qtwidgetsglobal_p.h>
#include "private/qframe_p.h"
#include <QtCore/qpointer.h>
QT_REQUIRE_CONFIG(splitter);
QT_BEGIN_NAMESPACE

View File

@ -7,6 +7,8 @@
#include <qwindow.h>
#include <QtGui/private/qpointingdevice_p.h>
#include <QtCore/qpointer.h>
Q_LOGGING_CATEGORY(lcTests, "qt.gui.tests")
class MouseEventWidget : public QWindow

View File

@ -20,6 +20,8 @@
#include <private/qguiapplication_p.h>
#include <qpa/qplatformintegration.h>
#include <QtCore/qpointer.h>
Q_LOGGING_CATEGORY(lcTests, "qt.gui.tests")
class tst_QTouchEventWidget : public QWidget