From 7d28f7772cd8f5aad63359ed0b9c57c12923dc85 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Wed, 30 May 2012 13:53:24 +0200 Subject: Use QPointer instead of QWeakPointer. The use of QWeakPointer for tracking QObject pointers is to be deprecated. Change-Id: If460ca7f515db77af24030152f4bd56e1a5fae7c Reviewed-by: Thiago Macieira --- src/corelib/animation/qabstractanimation.cpp | 2 +- src/corelib/animation/qpropertyanimation_p.h | 2 +- src/corelib/plugin/qlibrary_p.h | 2 +- src/corelib/statemachine/qabstracttransition_p.h | 2 +- src/corelib/statemachine/qstate.cpp | 2 +- src/gui/kernel/qguiapplication.cpp | 4 ++-- src/gui/kernel/qguiapplication_p.h | 6 ++--- src/gui/kernel/qinputmethod_p.h | 2 +- src/gui/kernel/qwindowsysteminterface_qpa_p.h | 29 ++++++++++++------------ src/network/access/qnetworkrequest_p.h | 3 ++- src/plugins/platforms/xcb/qxcbdrag.h | 3 ++- src/widgets/dialogs/qdialog.cpp | 2 +- src/widgets/graphicsview/qgraphicsscene.cpp | 4 ++-- src/widgets/itemviews/qabstractitemview_p.h | 4 ++-- src/widgets/kernel/qaction.cpp | 2 +- src/widgets/kernel/qapplication.cpp | 6 ++--- src/widgets/kernel/qwidget.cpp | 2 +- src/widgets/kernel/qwidgetwindow_qpa_p.h | 4 ++-- src/widgets/widgets/qdatetimeedit.cpp | 2 +- src/widgets/widgets/qdatetimeedit_p.h | 2 +- src/widgets/widgets/qmenu.cpp | 2 +- 21 files changed, 45 insertions(+), 42 deletions(-) (limited to 'src') diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp index 969a54775b..e56d1e26d3 100644 --- a/src/corelib/animation/qabstractanimation.cpp +++ b/src/corelib/animation/qabstractanimation.cpp @@ -925,7 +925,7 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState) } state = newState; - QWeakPointer guard(q); + QPointer guard(q); //(un)registration of the animation must always happen before calls to //virtual function (updateState) to ensure a correct state of the timer diff --git a/src/corelib/animation/qpropertyanimation_p.h b/src/corelib/animation/qpropertyanimation_p.h index c413c683ff..d6c0f9057c 100644 --- a/src/corelib/animation/qpropertyanimation_p.h +++ b/src/corelib/animation/qpropertyanimation_p.h @@ -70,7 +70,7 @@ public: { } - QWeakPointer target; + QPointer target; //we use targetValue to be able to unregister the target from the global hash QObject *targetValue; diff --git a/src/corelib/plugin/qlibrary_p.h b/src/corelib/plugin/qlibrary_p.h index 604a5fbdde..ca7b5d9bb4 100644 --- a/src/corelib/plugin/qlibrary_p.h +++ b/src/corelib/plugin/qlibrary_p.h @@ -96,7 +96,7 @@ public: static QVector staticPlugins(); - QWeakPointer inst; + QPointer inst; QtPluginInstanceFunction instance; QJsonObject metaData; bool compatPlugin; diff --git a/src/corelib/statemachine/qabstracttransition_p.h b/src/corelib/statemachine/qabstracttransition_p.h index 64a0af7cfb..442398825a 100644 --- a/src/corelib/statemachine/qabstracttransition_p.h +++ b/src/corelib/statemachine/qabstracttransition_p.h @@ -80,7 +80,7 @@ public: QStateMachine *machine() const; void emitTriggered(); - QList > targetStates; + QList > targetStates; #ifndef QT_NO_ANIMATION QList animations; diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp index 0230acbab6..14432edd7c 100644 --- a/src/corelib/statemachine/qstate.cpp +++ b/src/corelib/statemachine/qstate.cpp @@ -299,7 +299,7 @@ void QState::addTransition(QAbstractTransition *transition) } transition->setParent(this); - const QList > &targets = QAbstractTransitionPrivate::get(transition)->targetStates; + const QList > &targets = QAbstractTransitionPrivate::get(transition)->targetStates; for (int i = 0; i < targets.size(); ++i) { QAbstractState *t = targets.at(i).data(); if (!t) { diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 05e1274fef..f71e611303 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1604,7 +1604,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To touchPoint.d = touchPoint.d->detach(); // update state - QWeakPointer w; + QPointer w; QTouchEvent::TouchPoint previousTouchPoint; ActiveTouchPointsKey touchInfoKey(e->device, touchPoint.id()); ActiveTouchPointsValue &touchInfo = d->activeTouchPoints[touchInfoKey]; @@ -1613,7 +1613,7 @@ void QGuiApplicationPrivate::processTouchEvent(QWindowSystemInterfacePrivate::To if (e->device->type() == QTouchDevice::TouchPad) { // on touch-pads, send all touch points to the same widget w = d->activeTouchPoints.isEmpty() - ? QWeakPointer() + ? QPointer() : d->activeTouchPoints.constBegin().value().window; } diff --git a/src/gui/kernel/qguiapplication_p.h b/src/gui/kernel/qguiapplication_p.h index 8b7977e87a..e79c2afdf2 100644 --- a/src/gui/kernel/qguiapplication_p.h +++ b/src/gui/kernel/qguiapplication_p.h @@ -205,8 +205,8 @@ public: int touchPointId; }; struct ActiveTouchPointsValue { - QWeakPointer window; - QWeakPointer target; + QPointer window; + QPointer target; QTouchEvent::TouchPoint touchPoint; }; QHash activeTouchPoints; @@ -216,7 +216,7 @@ public: : pos(p), screenPos(sp), window(w) { } QPointF pos; QPointF screenPos; - QWeakPointer window; + QPointer window; }; QHash synthesizedMousePoints; diff --git a/src/gui/kernel/qinputmethod_p.h b/src/gui/kernel/qinputmethod_p.h index ad3d2141c1..7b24ebe33d 100644 --- a/src/gui/kernel/qinputmethod_p.h +++ b/src/gui/kernel/qinputmethod_p.h @@ -85,7 +85,7 @@ public: bool objectAcceptsInputMethod(QObject *object); QTransform inputItemTransform; - QWeakPointer inputItem; + QPointer inputItem; QPlatformInputContext *testContext; }; diff --git a/src/gui/kernel/qwindowsysteminterface_qpa_p.h b/src/gui/kernel/qwindowsysteminterface_qpa_p.h index 3eebaf2dfc..919a7de39b 100644 --- a/src/gui/kernel/qwindowsysteminterface_qpa_p.h +++ b/src/gui/kernel/qwindowsysteminterface_qpa_p.h @@ -44,6 +44,7 @@ #include "qwindowsysteminterface_qpa.h" #include +#include QT_BEGIN_HEADER @@ -88,7 +89,7 @@ public: public: explicit CloseEvent(QWindow *w) : WindowSystemEvent(Close), window(w) { } - QWeakPointer window; + QPointer window; }; class GeometryChangeEvent : public WindowSystemEvent { @@ -96,7 +97,7 @@ public: GeometryChangeEvent(QWindow *tlw, const QRect &newGeometry) : WindowSystemEvent(GeometryChange), tlw(tlw), newGeometry(newGeometry) { } - QWeakPointer tlw; + QPointer tlw; QRect newGeometry; }; @@ -105,7 +106,7 @@ public: explicit EnterEvent(QWindow *enter) : WindowSystemEvent(Enter), enter(enter) { } - QWeakPointer enter; + QPointer enter; }; class LeaveEvent : public WindowSystemEvent { @@ -113,7 +114,7 @@ public: explicit LeaveEvent(QWindow *leave) : WindowSystemEvent(Leave), leave(leave) { } - QWeakPointer leave; + QPointer leave; }; class ActivatedWindowEvent : public WindowSystemEvent { @@ -121,7 +122,7 @@ public: explicit ActivatedWindowEvent(QWindow *activatedWindow) : WindowSystemEvent(ActivatedWindow), activated(activatedWindow) { } - QWeakPointer activated; + QPointer activated; }; class WindowStateChangedEvent : public WindowSystemEvent { @@ -130,7 +131,7 @@ public: : WindowSystemEvent(WindowStateChanged), window(_window), newState(_newState) { } - QWeakPointer window; + QPointer window; Qt::WindowState newState; }; @@ -138,7 +139,7 @@ public: public: UserEvent(QWindow * w, ulong time, EventType t) : WindowSystemEvent(t), window(w), nullWindow(w == 0), timestamp(time) { } - QWeakPointer window; + QPointer window; bool nullWindow; unsigned long timestamp; }; @@ -209,7 +210,7 @@ public: public: ScreenOrientationEvent(QScreen *s, Qt::ScreenOrientation o) : WindowSystemEvent(ScreenOrientation), screen(s), orientation(o) { } - QWeakPointer screen; + QPointer screen; Qt::ScreenOrientation orientation; }; @@ -217,7 +218,7 @@ public: public: ScreenGeometryEvent(QScreen *s, const QRect &g) : WindowSystemEvent(ScreenGeometry), screen(s), geometry(g) { } - QWeakPointer screen; + QPointer screen; QRect geometry; }; @@ -225,7 +226,7 @@ public: public: ScreenAvailableGeometryEvent(QScreen *s, const QRect &g) : WindowSystemEvent(ScreenAvailableGeometry), screen(s), availableGeometry(g) { } - QWeakPointer screen; + QPointer screen; QRect availableGeometry; }; @@ -233,7 +234,7 @@ public: public: ScreenLogicalDotsPerInchEvent(QScreen *s, qreal dx, qreal dy) : WindowSystemEvent(ScreenLogicalDotsPerInch), screen(s), dpiX(dx), dpiY(dy) { } - QWeakPointer screen; + QPointer screen; qreal dpiX; qreal dpiY; }; @@ -242,7 +243,7 @@ public: public: ScreenRefreshRateEvent(QScreen *s, qreal r) : WindowSystemEvent(ScreenRefreshRate), screen(s), rate(r) { } - QWeakPointer screen; + QPointer screen; qreal rate; }; @@ -250,13 +251,13 @@ public: public: explicit ThemeChangeEvent(QWindow * w) : WindowSystemEvent(ThemeChange), window(w) { } - QWeakPointer window; + QPointer window; }; class ExposeEvent : public WindowSystemEvent { public: ExposeEvent(QWindow *exposed, const QRegion ®ion); - QWeakPointer exposed; + QPointer exposed; bool isExposed; QRegion region; }; diff --git a/src/network/access/qnetworkrequest_p.h b/src/network/access/qnetworkrequest_p.h index 13861cc80e..0df886cfc2 100644 --- a/src/network/access/qnetworkrequest_p.h +++ b/src/network/access/qnetworkrequest_p.h @@ -59,6 +59,7 @@ #include "QtCore/qhash.h" #include "QtCore/qshareddata.h" #include "QtCore/qsharedpointer.h" +#include "QtCore/qpointer.h" QT_BEGIN_NAMESPACE @@ -74,7 +75,7 @@ public: RawHeadersList rawHeaders; CookedHeadersMap cookedHeaders; AttributesMap attributes; - QWeakPointer originatingObject; + QPointer originatingObject; RawHeadersList::ConstIterator findRawHeader(const QByteArray &key) const; RawHeadersList allRawHeaders() const; diff --git a/src/plugins/platforms/xcb/qxcbdrag.h b/src/plugins/platforms/xcb/qxcbdrag.h index b404d26ed5..2666e5925c 100644 --- a/src/plugins/platforms/xcb/qxcbdrag.h +++ b/src/plugins/platforms/xcb/qxcbdrag.h @@ -50,6 +50,7 @@ #include #include #include +#include #include #include @@ -113,7 +114,7 @@ private: Qt::DropAction toDropAction(xcb_atom_t atom) const; xcb_atom_t toXdndAction(Qt::DropAction a) const; - QWeakPointer currentWindow; + QPointer currentWindow; QPoint currentPosition; QXcbDropData *dropData; diff --git a/src/widgets/dialogs/qdialog.cpp b/src/widgets/dialogs/qdialog.cpp index 97a5b6d454..0e57a16757 100644 --- a/src/widgets/dialogs/qdialog.cpp +++ b/src/widgets/dialogs/qdialog.cpp @@ -624,7 +624,7 @@ void QDialog::contextMenuEvent(QContextMenuEvent *e) while (w && w->whatsThis().size() == 0 && !w->testAttribute(Qt::WA_CustomWhatsThis)) w = w->isWindow() ? 0 : w->parentWidget(); if (w) { - QWeakPointer p = new QMenu(this); + QPointer p = new QMenu(this); QAction *wt = p.data()->addAction(tr("What's This?")); if (p.data()->exec(e->globalPos()) == wt) { QHelpEvent e(QEvent::WhatsThis, w->rect().center(), diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index a63403a039..6feeb943b7 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -6067,7 +6067,7 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) // initial gesture targets if (!conflictedGestures.isEmpty()) { for (int i = 0; i < cachedTargetItems.size(); ++i) { - QWeakPointer item = cachedTargetItems.at(i); + QPointer item = cachedTargetItems.at(i); // get gestures to deliver to the current item QSet gestures = conflictedGestures & cachedItemGestures.value(item.data()); @@ -6153,7 +6153,7 @@ void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) } qSort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst); for (int i = 0; i < cachedTargetItems.size(); ++i) { - QWeakPointer receiver = cachedTargetItems.at(i); + QPointer receiver = cachedTargetItems.at(i); QSet gestures = undeliveredGestures & cachedItemGestures.value(receiver.data()); gestures -= cachedAlreadyDeliveredGestures.value(receiver.data()); diff --git a/src/widgets/itemviews/qabstractitemview_p.h b/src/widgets/itemviews/qabstractitemview_p.h index 3826f3b4e9..63f7488704 100644 --- a/src/widgets/itemviews/qabstractitemview_p.h +++ b/src/widgets/itemviews/qabstractitemview_p.h @@ -71,10 +71,10 @@ QT_BEGIN_NAMESPACE struct QEditorInfo { - QEditorInfo(QWidget *e, bool s): widget(QWeakPointer(e)), isStatic(s) {} + QEditorInfo(QWidget *e, bool s): widget(QPointer(e)), isStatic(s) {} QEditorInfo(): isStatic(false) {} - QWeakPointer widget; + QPointer widget; bool isStatic; }; diff --git a/src/widgets/kernel/qaction.cpp b/src/widgets/kernel/qaction.cpp index 0d500c81d6..05d250e73a 100644 --- a/src/widgets/kernel/qaction.cpp +++ b/src/widgets/kernel/qaction.cpp @@ -1181,7 +1181,7 @@ void QAction::activate(ActionEvent event) { Q_D(QAction); if(event == Trigger) { - QWeakPointer guard = this; + QPointer guard = this; if(d->checkable) { // the checked action of an exclusive group cannot be unchecked if (d->checked && (d->group && d->group->isExclusive() diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 1ca30c5819..e9003e8c14 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3425,7 +3425,7 @@ bool QApplication::notify(QObject *receiver, QEvent *e) bool acceptTouchEvents = widget->testAttribute(Qt::WA_AcceptTouchEvents); touchEvent->setTarget(widget); touchEvent->setAccepted(acceptTouchEvents); - QWeakPointer p = widget; + QPointer p = widget; res = acceptTouchEvents && d->notify_helper(widget, touchEvent); eventAccepted = touchEvent->isAccepted(); if (p.isNull()) { @@ -4369,14 +4369,14 @@ void QApplicationPrivate::translateRawTouchEvent(QWidget *window, touchPoint.d = touchPoint.d->detach(); // update state - QWeakPointer target; + QPointer target; ActiveTouchPointsKey touchInfoKey(device, touchPoint.id()); ActiveTouchPointsValue &touchInfo = d->activeTouchPoints[touchInfoKey]; if (touchPoint.state() == Qt::TouchPointPressed) { if (device->type() == QTouchDevice::TouchPad) { // on touch-pads, send all touch points to the same widget target = d->activeTouchPoints.isEmpty() - ? QWeakPointer() + ? QPointer() : d->activeTouchPoints.constBegin().value().target; } diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 454ffd5eb7..e6a760abde 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -2459,7 +2459,7 @@ void QWidgetPrivate::setStyle_helper(QStyle *newStyle, bool propagate, bool Q_Q(QWidget); QStyle *oldStyle = q->style(); #ifndef QT_NO_STYLE_STYLESHEET - QWeakPointer origStyle; + QPointer origStyle; #endif #ifdef Q_WS_MAC diff --git a/src/widgets/kernel/qwidgetwindow_qpa_p.h b/src/widgets/kernel/qwidgetwindow_qpa_p.h index d4fd37c456..8afa3f33cd 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa_p.h +++ b/src/widgets/kernel/qwidgetwindow_qpa_p.h @@ -95,9 +95,9 @@ private: void updateGeometry(); QWidget *m_widget; - QWeakPointer m_implicit_mouse_grabber; + QPointer m_implicit_mouse_grabber; #ifndef QT_NO_DRAGANDDROP - QWeakPointer m_dragTarget; + QPointer m_dragTarget; #endif }; diff --git a/src/widgets/widgets/qdatetimeedit.cpp b/src/widgets/widgets/qdatetimeedit.cpp index 4c418bde9e..b916212871 100644 --- a/src/widgets/widgets/qdatetimeedit.cpp +++ b/src/widgets/widgets/qdatetimeedit.cpp @@ -2598,7 +2598,7 @@ void QCalendarPopup::setCalendarWidget(QCalendarWidget *cw) widgetLayout->setSpacing(0); } delete calendar.data(); - calendar = QWeakPointer(cw); + calendar = QPointer(cw); widgetLayout->addWidget(cw); connect(cw, SIGNAL(activated(QDate)), this, SLOT(dateSelected(QDate))); diff --git a/src/widgets/widgets/qdatetimeedit_p.h b/src/widgets/widgets/qdatetimeedit_p.h index 35f0f57f54..f7e6861677 100644 --- a/src/widgets/widgets/qdatetimeedit_p.h +++ b/src/widgets/widgets/qdatetimeedit_p.h @@ -173,7 +173,7 @@ protected: private: QCalendarWidget *verifyCalendarInstance(); - QWeakPointer calendar; + QPointer calendar; QDate oldDate; bool dateChanged; }; diff --git a/src/widgets/widgets/qmenu.cpp b/src/widgets/widgets/qmenu.cpp index 8d50b03edb..4747d1c661 100644 --- a/src/widgets/widgets/qmenu.cpp +++ b/src/widgets/widgets/qmenu.cpp @@ -1098,7 +1098,7 @@ void QMenuPrivate::_q_actionTriggered() { Q_Q(QMenu); if (QAction *action = qobject_cast(q->sender())) { - QWeakPointer actionGuard = action; + QPointer actionGuard = action; emit q->triggered(action); if (!activationRecursionGuard && actionGuard) { //in case the action has not been activated by the mouse -- cgit v1.2.3