diff options
-rw-r--r-- | src/corelib/kernel/qcoreevent.cpp | 4 | ||||
-rw-r--r-- | src/corelib/kernel/qcoreevent.h | 12 | ||||
-rw-r--r-- | src/corelib/thread/qfutureinterface_p.h | 1 | ||||
-rw-r--r-- | src/gui/kernel/qevent.cpp | 10 | ||||
-rw-r--r-- | src/gui/kernel/qevent.h | 43 | ||||
-rw-r--r-- | src/plugins/platforms/android/qandroidinputcontext.cpp | 20 | ||||
-rw-r--r-- | src/plugins/platforms/ios/qiostextresponder.mm | 16 |
7 files changed, 75 insertions, 31 deletions
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp index 1bafb85c93..7491f8e539 100644 --- a/src/corelib/kernel/qcoreevent.cpp +++ b/src/corelib/kernel/qcoreevent.cpp @@ -302,10 +302,10 @@ QEvent::QEvent(Type type) } /*! + \fn QEvent::QEvent(const QEvent &other) \internal Copies the \a other event. */ -QEvent::QEvent(const QEvent &other) = default; /*! \internal @@ -334,13 +334,13 @@ QEvent::QEvent(const QEvent &other) = default; */ /*! + \fn QEvent &QEvent::operator=(const QEvent &other) \internal Attempts to copy the \a other event. Copying events is a bad idea, yet some Qt 4 code does it (notably, QApplication and the state machine). */ -QEvent &QEvent::operator=(const QEvent &other) = default; /*! Destroys the event. If it was \l{QCoreApplication::postEvent()}{posted}, diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h index 23503dee05..f6417438b1 100644 --- a/src/corelib/kernel/qcoreevent.h +++ b/src/corelib/kernel/qcoreevent.h @@ -46,12 +46,18 @@ QT_BEGIN_NAMESPACE +#define Q_EVENT_DISABLE_COPY(Class) \ +protected: \ + Class(const Class &) = default; \ + Class &operator=(const Class &other) = default class QEventPrivate; class Q_CORE_EXPORT QEvent // event base class { Q_GADGET QDOC_PROPERTY(bool accepted READ isAccepted WRITE setAccepted) + + Q_EVENT_DISABLE_COPY(QEvent); public: enum Type { /* @@ -295,9 +301,7 @@ public: Q_ENUM(Type) explicit QEvent(Type type); - QEvent(const QEvent &other); virtual ~QEvent(); - QEvent &operator=(const QEvent &other); inline Type type() const { return static_cast<Type>(t); } inline bool spontaneous() const { return m_spont; } @@ -359,6 +363,7 @@ private: class Q_CORE_EXPORT QTimerEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QTimerEvent); public: explicit QTimerEvent(int timerId); ~QTimerEvent(); @@ -374,6 +379,7 @@ class QObject; class Q_CORE_EXPORT QChildEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QChildEvent); public: QChildEvent(Type type, QObject *child); ~QChildEvent(); @@ -390,6 +396,7 @@ protected: class Q_CORE_EXPORT QDynamicPropertyChangeEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QDynamicPropertyChangeEvent); public: explicit QDynamicPropertyChangeEvent(const QByteArray &name); ~QDynamicPropertyChangeEvent(); @@ -404,6 +411,7 @@ private: class Q_CORE_EXPORT QDeferredDeleteEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QDeferredDeleteEvent); public: explicit QDeferredDeleteEvent(); ~QDeferredDeleteEvent(); diff --git a/src/corelib/thread/qfutureinterface_p.h b/src/corelib/thread/qfutureinterface_p.h index bd3bd80dd9..083d6d3962 100644 --- a/src/corelib/thread/qfutureinterface_p.h +++ b/src/corelib/thread/qfutureinterface_p.h @@ -65,6 +65,7 @@ QT_BEGIN_NAMESPACE class QFutureCallOutEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QFutureCallOutEvent); public: enum CallOutType { Started, diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index ff67d64cd3..a2576cb1b5 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -2267,16 +2267,6 @@ QInputMethodEvent::QInputMethodEvent(const QString &preeditText, const QList<Att { } -/*! - Constructs a copy of \a other. -*/ -QInputMethodEvent::QInputMethodEvent(const QInputMethodEvent &other) - : QEvent(QEvent::InputMethod), m_preedit(other.m_preedit), m_commit(other.m_commit), - m_attributes(other.m_attributes), m_replacementStart(other.m_replacementStart), - m_replacementLength(other.m_replacementLength) -{ -} - QInputMethodEvent::~QInputMethodEvent() { } diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 841d63caa3..a0f7fcfac5 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -74,6 +74,7 @@ class QGesture; class Q_GUI_EXPORT QInputEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QInputEvent); public: explicit QInputEvent(Type type, const QInputDevice *m_dev, Qt::KeyboardModifiers modifiers = Qt::NoModifier); ~QInputEvent(); @@ -99,6 +100,7 @@ protected: class Q_GUI_EXPORT QPointerEvent : public QInputEvent { + Q_EVENT_DISABLE_COPY(QPointerEvent); public: explicit QPointerEvent(Type type, const QPointingDevice *dev, Qt::KeyboardModifiers modifiers = Qt::NoModifier, const QList<QEventPoint> &points = {}); @@ -139,6 +141,7 @@ class Q_GUI_EXPORT QSinglePointEvent : public QPointerEvent Q_GADGET Q_PROPERTY(QObject *exclusivePointGrabber READ exclusivePointGrabber WRITE setExclusivePointGrabber) + Q_EVENT_DISABLE_COPY(QSinglePointEvent); public: inline Qt::MouseButton button() const { return m_button; } inline Qt::MouseButtons buttons() const { return m_mouseState; } @@ -191,6 +194,7 @@ protected: class Q_GUI_EXPORT QEnterEvent : public QSinglePointEvent { + Q_EVENT_DISABLE_COPY(QEnterEvent); public: QEnterEvent(const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos, const QPointingDevice *device = QPointingDevice::primaryPointingDevice()); @@ -224,6 +228,7 @@ public: class Q_GUI_EXPORT QMouseEvent : public QSinglePointEvent { + Q_EVENT_DISABLE_COPY(QMouseEvent); public: QMouseEvent(Type type, const QPointF &localPos, Qt::MouseButton button, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, @@ -273,6 +278,7 @@ public: class Q_GUI_EXPORT QHoverEvent : public QSinglePointEvent { + Q_EVENT_DISABLE_COPY(QHoverEvent); public: QHoverEvent(Type type, const QPointF &pos, const QPointF &oldPos, Qt::KeyboardModifiers modifiers = Qt::NoModifier, @@ -310,6 +316,8 @@ class Q_GUI_EXPORT QWheelEvent : public QSinglePointEvent Q_PROPERTY(QPoint angleDelta READ angleDelta) Q_PROPERTY(Qt::ScrollPhase phase READ phase) Q_PROPERTY(bool inverted READ inverted) + + Q_EVENT_DISABLE_COPY(QWheelEvent); public: enum { DefaultDeltasPerStep = 120 }; @@ -343,6 +351,7 @@ protected: #if QT_CONFIG(tabletevent) class Q_GUI_EXPORT QTabletEvent : public QSinglePointEvent { + Q_EVENT_DISABLE_COPY(QTabletEvent); public: QTabletEvent(Type t, const QPointingDevice *device, const QPointF &pos, const QPointF &globalPos, @@ -397,6 +406,7 @@ protected: #if QT_CONFIG(gestures) class Q_GUI_EXPORT QNativeGestureEvent : public QSinglePointEvent { + Q_EVENT_DISABLE_COPY(QNativeGestureEvent); public: QNativeGestureEvent(Qt::NativeGestureType type, const QPointingDevice *dev, const QPointF &localPos, const QPointF &scenePos, const QPointF &globalPos, qreal value, quint64 sequenceId, quint64 intArgument); @@ -433,6 +443,7 @@ protected: class Q_GUI_EXPORT QKeyEvent : public QInputEvent { + Q_EVENT_DISABLE_COPY(QKeyEvent); public: QKeyEvent(Type type, int key, Qt::KeyboardModifiers modifiers, const QString& text = QString(), bool autorep = false, quint16 count = 1); @@ -481,6 +492,7 @@ protected: class Q_GUI_EXPORT QFocusEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QFocusEvent); public: explicit QFocusEvent(Type type, Qt::FocusReason reason=Qt::OtherFocusReason); ~QFocusEvent(); @@ -499,6 +511,7 @@ private: class Q_GUI_EXPORT QPaintEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QPaintEvent); public: explicit QPaintEvent(const QRegion& paintRegion); explicit QPaintEvent(const QRect &paintRect); @@ -517,6 +530,7 @@ protected: class Q_GUI_EXPORT QMoveEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QMoveEvent); public: QMoveEvent(const QPoint &pos, const QPoint &oldPos); ~QMoveEvent(); @@ -532,6 +546,7 @@ protected: class Q_GUI_EXPORT QExposeEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QExposeEvent); public: explicit QExposeEvent(const QRegion &m_region); ~QExposeEvent(); @@ -549,6 +564,7 @@ protected: class Q_GUI_EXPORT QPlatformSurfaceEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QPlatformSurfaceEvent); public: enum SurfaceEventType { SurfaceCreated, @@ -568,6 +584,7 @@ protected: class Q_GUI_EXPORT QResizeEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QResizeEvent); public: QResizeEvent(const QSize &size, const QSize &oldSize); ~QResizeEvent(); @@ -584,6 +601,7 @@ protected: class Q_GUI_EXPORT QCloseEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QCloseEvent); public: QCloseEvent(); ~QCloseEvent(); @@ -592,6 +610,7 @@ public: class Q_GUI_EXPORT QIconDragEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QIconDragEvent); public: QIconDragEvent(); ~QIconDragEvent(); @@ -600,6 +619,7 @@ public: class Q_GUI_EXPORT QShowEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QShowEvent); public: QShowEvent(); ~QShowEvent(); @@ -608,6 +628,7 @@ public: class Q_GUI_EXPORT QHideEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QHideEvent); public: QHideEvent(); ~QHideEvent(); @@ -616,6 +637,7 @@ public: #ifndef QT_NO_CONTEXTMENU class Q_GUI_EXPORT QContextMenuEvent : public QInputEvent { + Q_EVENT_DISABLE_COPY(QContextMenuEvent); public: enum Reason { Mouse, Keyboard, Other }; @@ -646,6 +668,7 @@ protected: #ifndef QT_NO_INPUTMETHOD class Q_GUI_EXPORT QInputMethodEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QInputMethodEvent); public: enum AttributeType { TextFormat, @@ -678,8 +701,6 @@ public: inline int replacementStart() const { return m_replacementStart; } inline int replacementLength() const { return m_replacementLength; } - QInputMethodEvent(const QInputMethodEvent &other); - inline friend bool operator==(const QInputMethodEvent::Attribute &lhs, const QInputMethodEvent::Attribute &rhs) { @@ -704,6 +725,7 @@ Q_DECLARE_TYPEINFO(QInputMethodEvent::Attribute, Q_MOVABLE_TYPE); class Q_GUI_EXPORT QInputMethodQueryEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QInputMethodQueryEvent); public: explicit QInputMethodQueryEvent(Qt::InputMethodQueries queries); ~QInputMethodQueryEvent(); @@ -733,6 +755,7 @@ class QMimeData; class Q_GUI_EXPORT QDropEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QDropEvent); public: QDropEvent(const QPointF& pos, Qt::DropActions actions, const QMimeData *data, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = Drop); @@ -779,6 +802,7 @@ protected: class Q_GUI_EXPORT QDragMoveEvent : public QDropEvent { + Q_EVENT_DISABLE_COPY(QDragMoveEvent); public: QDragMoveEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers, Type type = DragMove); @@ -801,6 +825,7 @@ protected: class Q_GUI_EXPORT QDragEnterEvent : public QDragMoveEvent { + Q_EVENT_DISABLE_COPY(QDragEnterEvent); public: QDragEnterEvent(const QPoint &pos, Qt::DropActions actions, const QMimeData *data, Qt::MouseButtons buttons, Qt::KeyboardModifiers modifiers); @@ -810,6 +835,7 @@ public: class Q_GUI_EXPORT QDragLeaveEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QDragLeaveEvent); public: QDragLeaveEvent(); ~QDragLeaveEvent(); @@ -819,6 +845,7 @@ public: class Q_GUI_EXPORT QHelpEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QHelpEvent); public: QHelpEvent(Type type, const QPoint &pos, const QPoint &globalPos); ~QHelpEvent(); @@ -841,6 +868,7 @@ private: #ifndef QT_NO_STATUSTIP class Q_GUI_EXPORT QStatusTipEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QStatusTipEvent); public: explicit QStatusTipEvent(const QString &tip); ~QStatusTipEvent(); @@ -856,6 +884,7 @@ private: #if QT_CONFIG(whatsthis) class Q_GUI_EXPORT QWhatsThisClickedEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QWhatsThisClickedEvent); public: explicit QWhatsThisClickedEvent(const QString &href); ~QWhatsThisClickedEvent(); @@ -871,6 +900,7 @@ private: #if QT_CONFIG(action) class Q_GUI_EXPORT QActionEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QActionEvent); public: QActionEvent(int type, QAction *action, QAction *before = nullptr); ~QActionEvent(); @@ -887,6 +917,7 @@ private: class Q_GUI_EXPORT QFileOpenEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QFileOpenEvent); public: explicit QFileOpenEvent(const QString &file); explicit QFileOpenEvent(const QUrl &url); @@ -905,6 +936,7 @@ private: #ifndef QT_NO_TOOLBAR class Q_GUI_EXPORT QToolBarChangeEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QToolBarChangeEvent); public: explicit QToolBarChangeEvent(bool t); ~QToolBarChangeEvent(); @@ -920,6 +952,7 @@ private: #if QT_CONFIG(shortcut) class Q_GUI_EXPORT QShortcutEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QShortcutEvent); public: QShortcutEvent(const QKeySequence &key, int id, bool ambiguous = false); ~QShortcutEvent(); @@ -938,6 +971,7 @@ protected: class Q_GUI_EXPORT QWindowStateChangeEvent: public QEvent { + Q_EVENT_DISABLE_COPY(QWindowStateChangeEvent); public: explicit QWindowStateChangeEvent(Qt::WindowStates oldState, bool isOverride = false); ~QWindowStateChangeEvent(); @@ -958,6 +992,7 @@ Q_GUI_EXPORT QDebug operator<<(QDebug, const QEvent *); class Q_GUI_EXPORT QTouchEvent : public QPointerEvent { + Q_EVENT_DISABLE_COPY(QTouchEvent); public: using TouchPoint = QEventPoint; // source compat @@ -995,6 +1030,7 @@ protected: class Q_GUI_EXPORT QScrollPrepareEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QScrollPrepareEvent); public: explicit QScrollPrepareEvent(const QPointF &startPos); ~QScrollPrepareEvent(); @@ -1021,6 +1057,7 @@ private: class Q_GUI_EXPORT QScrollEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QScrollEvent); public: enum ScrollState { @@ -1046,6 +1083,7 @@ private: class Q_GUI_EXPORT QScreenOrientationChangeEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QScreenOrientationChangeEvent); public: QScreenOrientationChangeEvent(QScreen *screen, Qt::ScreenOrientation orientation); ~QScreenOrientationChangeEvent(); @@ -1062,6 +1100,7 @@ private: class Q_GUI_EXPORT QApplicationStateChangeEvent : public QEvent { + Q_EVENT_DISABLE_COPY(QApplicationStateChangeEvent); public: explicit QApplicationStateChangeEvent(Qt::ApplicationState state); diff --git a/src/plugins/platforms/android/qandroidinputcontext.cpp b/src/plugins/platforms/android/qandroidinputcontext.cpp index 689da5c136..0bd3205e50 100644 --- a/src/plugins/platforms/android/qandroidinputcontext.cpp +++ b/src/plugins/platforms/android/qandroidinputcontext.cpp @@ -1453,12 +1453,11 @@ jboolean QAndroidInputContext::setComposingText(const QString &text, jint newCur else m_composingCursor = -1; - QInputMethodEvent event; if (focusObjectIsComposing()) { QTextCharFormat underlined; underlined.setFontUnderline(true); - event = QInputMethodEvent(m_composingText, { + QInputMethodEvent event(m_composingText, { { QInputMethodEvent::TextFormat, 0, int(m_composingText.length()), underlined }, { QInputMethodEvent::Cursor, m_composingCursor - m_composingTextStart, 1 } }); @@ -1467,8 +1466,12 @@ jboolean QAndroidInputContext::setComposingText(const QString &text, jint newCur event.setCommitString({}, m_composingTextStart - effectiveAbsoluteCursorPos, oldComposingTextLen); } + if (m_composingText.isEmpty()) + clear(); + + QGuiApplication::sendEvent(m_focusObject, &event); } else { - event = QInputMethodEvent({}, {}); + QInputMethodEvent event({}, {}); if (focusObjectWasComposing) { event.setCommitString(m_composingText); @@ -1477,12 +1480,11 @@ jboolean QAndroidInputContext::setComposingText(const QString &text, jint newCur m_composingTextStart - effectiveAbsoluteCursorPos, oldComposingTextLen); } - } - - if (m_composingText.isEmpty()) - clear(); + if (m_composingText.isEmpty()) + clear(); - QGuiApplication::sendEvent(m_focusObject, &event); + QGuiApplication::sendEvent(m_focusObject, &event); + } if (!focusObjectIsComposing() && newCursorPosition != 1) { // Move cursor using a separate event because if we have inserted or deleted a newline @@ -1491,7 +1493,7 @@ jboolean QAndroidInputContext::setComposingText(const QString &text, jint newCur const int newBlockPos = getBlockPosition( focusObjectInputMethodQuery(Qt::ImCursorPosition | Qt::ImAbsolutePosition)); - event = QInputMethodEvent({}, { + QInputMethodEvent event({}, { { QInputMethodEvent::Selection, newAbsoluteCursorPos - newBlockPos, 0 } }); diff --git a/src/plugins/platforms/ios/qiostextresponder.mm b/src/plugins/platforms/ios/qiostextresponder.mm index 19e476a064..358ccbf602 100644 --- a/src/plugins/platforms/ios/qiostextresponder.mm +++ b/src/plugins/platforms/ios/qiostextresponder.mm @@ -178,7 +178,7 @@ m_inSelectionChange = NO; m_inputContext = inputContext; - m_configuredImeState = new QInputMethodQueryEvent(m_inputContext->imeState().currentState); + m_configuredImeState = static_cast<QInputMethodQueryEvent*>(m_inputContext->imeState().currentState.clone()); QVariantMap platformData = m_configuredImeState->value(Qt::ImPlatformData).toMap(); Qt::InputMethodHints hints = Qt::InputMethodHints(m_configuredImeState->value(Qt::ImHints).toUInt()); @@ -828,20 +828,24 @@ NSRange r = static_cast<QUITextRange*>(range).range; QList<QInputMethodEvent::Attribute> attrs; attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, r.location, 0, 0); - QInputMethodEvent e(m_markedText, attrs); - [self sendEventToFocusObject:e]; + { + QInputMethodEvent e(m_markedText, attrs); + [self sendEventToFocusObject:e]; + } QRectF startRect = qApp->inputMethod()->cursorRectangle(); attrs = QList<QInputMethodEvent::Attribute>(); attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, r.location + r.length, 0, 0); - e = QInputMethodEvent(m_markedText, attrs); - [self sendEventToFocusObject:e]; + { + QInputMethodEvent e(m_markedText, attrs); + [self sendEventToFocusObject:e]; + } QRectF endRect = qApp->inputMethod()->cursorRectangle(); if (cursorPos != int(r.location + r.length) || cursorPos != anchorPos) { attrs = QList<QInputMethodEvent::Attribute>(); attrs << QInputMethodEvent::Attribute(QInputMethodEvent::Selection, qMin(cursorPos, anchorPos), qAbs(cursorPos - anchorPos), 0); - e = QInputMethodEvent(m_markedText, attrs); + QInputMethodEvent e(m_markedText, attrs); [self sendEventToFocusObject:e]; } |