From 0ee1b4a1dea8b587a5d39bfeb7e18c97f13dd877 Mon Sep 17 00:00:00 2001 From: Pekka Vuorela Date: Tue, 28 Feb 2012 13:35:17 +0200 Subject: Reverted use of tentative commit use in QWidget editors Feature to be reimplemented simplified. Cases when input method needs to be reset with possibility to commit use QInputMethod::commit() again. Change-Id: Ibfe7aecc0799e7a76c7ac4f5d860971cfe6e97ca Reviewed-by: Joona Petrell --- src/widgets/kernel/qapplication.cpp | 2 +- src/widgets/kernel/qwidget.cpp | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 2615ac891d..a099faae3f 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -2042,7 +2042,7 @@ void QApplication::setActiveWindow(QWidget* act) if (QApplicationPrivate::focus_widget) { if (QApplicationPrivate::focus_widget->testAttribute(Qt::WA_InputMethodEnabled)) - qApp->inputMethod()->reset(); + qApp->inputMethod()->commit(); QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange, Qt::ActiveWindowFocusReason); QApplication::sendEvent(QApplicationPrivate::focus_widget, &focusAboutToChange); diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 9a32d952f9..cccde764ad 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -3090,7 +3090,7 @@ void QWidgetPrivate::setEnabled_helper(bool enable) if (focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) qApp->inputMethod()->update(Qt::ImEnabled); } else { - qApp->inputMethod()->reset(); + qApp->inputMethod()->commit(); qApp->inputMethod()->update(Qt::ImEnabled); } } @@ -5948,7 +5948,7 @@ void QWidget::setFocus(Qt::FocusReason reason) if (prev) { if (reason != Qt::PopupFocusReason && reason != Qt::MenuBarFocusReason && prev->testAttribute(Qt::WA_InputMethodEnabled)) { - qApp->inputMethod()->reset(); + qApp->inputMethod()->commit(); } if (reason != Qt::NoFocusReason) { @@ -6057,7 +6057,7 @@ void QWidget::clearFocus() { if (hasFocus()) { if (testAttribute(Qt::WA_InputMethodEnabled)) - qApp->inputMethod()->reset(); + qApp->inputMethod()->commit(); QFocusEvent focusAboutToChange(QEvent::FocusAboutToChange); QApplication::sendEvent(this, &focusAboutToChange); @@ -10087,7 +10087,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) QWidget *focusWidget = d->effectiveFocusWidget(); if (on && !internalWinId() && hasFocus() && focusWidget->testAttribute(Qt::WA_InputMethodEnabled)) { - qApp->inputMethod()->reset(); + qApp->inputMethod()->commit(); qApp->inputMethod()->update(Qt::ImEnabled); } if (!qApp->testAttribute(Qt::AA_DontCreateNativeWidgetSiblings) && parentWidget() @@ -10137,7 +10137,7 @@ void QWidget::setAttribute(Qt::WidgetAttribute attribute, bool on) #ifndef QT_NO_IM if (qApp->focusObject() == this) { if (!on) - qApp->inputMethod()->reset(); + qApp->inputMethod()->commit(); qApp->inputMethod()->update(Qt::ImEnabled); } #endif //QT_NO_IM -- cgit v1.2.3 From 3ec88b355b5c9649d128fcf18cb2abc39ac0e770 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Wed, 28 Mar 2012 21:54:52 +0200 Subject: Plug memory leak when gestures are grabbed but never triggered When a gesture is grabbed by QAbstractScrollArea but never triggered then the deletion of the QAbstractScrollArea would mean that the gesture created for it would not be deleted. This ensures that it always deletes the gestures waiting to be deleted even if no gesture event is triggered Task-number: QTBUG-25011 Change-Id: I36118b82baaa60ac4e014896159060e1af76b2d2 Reviewed-by: Denis Dzyubenko --- src/widgets/kernel/qgesturemanager.cpp | 184 ++++++++++++++++----------------- 1 file changed, 91 insertions(+), 93 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qgesturemanager.cpp b/src/widgets/kernel/qgesturemanager.cpp index 296d8d31e7..f4bf667ef8 100644 --- a/src/widgets/kernel/qgesturemanager.cpp +++ b/src/widgets/kernel/qgesturemanager.cpp @@ -285,106 +285,104 @@ bool QGestureManager::filterEventThroughContexts(const QMultiMap startedGestures = triggeredGestures - m_activeGestures; - triggeredGestures &= m_activeGestures; - - // check if a running gesture switched back to maybe state - QSet activeToMaybeGestures = m_activeGestures & newMaybeGestures; - - // check if a maybe gesture switched to canceled - reset it but don't send an event - QSet maybeToCanceledGestures = m_maybeGestures & notGestures; - - // check if a running gesture switched back to not gesture state, - // i.e. were canceled - QSet canceledGestures = m_activeGestures & notGestures; - - // new gestures in maybe state - m_maybeGestures += newMaybeGestures; - - // gestures that were in maybe state - QSet notMaybeGestures = (startedGestures | triggeredGestures - | finishedGestures | canceledGestures - | notGestures); - m_maybeGestures -= notMaybeGestures; - - Q_ASSERT((startedGestures & finishedGestures).isEmpty()); - Q_ASSERT((startedGestures & newMaybeGestures).isEmpty()); - Q_ASSERT((startedGestures & canceledGestures).isEmpty()); - Q_ASSERT((finishedGestures & newMaybeGestures).isEmpty()); - Q_ASSERT((finishedGestures & canceledGestures).isEmpty()); - Q_ASSERT((canceledGestures & newMaybeGestures).isEmpty()); - - QSet notStarted = finishedGestures - m_activeGestures; - if (!notStarted.isEmpty()) { - // there are some gestures that claim to be finished, but never started. - // probably those are "singleshot" gestures so we'll fake the started state. - foreach (QGesture *gesture, notStarted) + if (!triggeredGestures.isEmpty() || !finishedGestures.isEmpty() + || !newMaybeGestures.isEmpty() || !notGestures.isEmpty()) { + QSet startedGestures = triggeredGestures - m_activeGestures; + triggeredGestures &= m_activeGestures; + + // check if a running gesture switched back to maybe state + QSet activeToMaybeGestures = m_activeGestures & newMaybeGestures; + + // check if a maybe gesture switched to canceled - reset it but don't send an event + QSet maybeToCanceledGestures = m_maybeGestures & notGestures; + + // check if a running gesture switched back to not gesture state, + // i.e. were canceled + QSet canceledGestures = m_activeGestures & notGestures; + + // new gestures in maybe state + m_maybeGestures += newMaybeGestures; + + // gestures that were in maybe state + QSet notMaybeGestures = (startedGestures | triggeredGestures + | finishedGestures | canceledGestures + | notGestures); + m_maybeGestures -= notMaybeGestures; + + Q_ASSERT((startedGestures & finishedGestures).isEmpty()); + Q_ASSERT((startedGestures & newMaybeGestures).isEmpty()); + Q_ASSERT((startedGestures & canceledGestures).isEmpty()); + Q_ASSERT((finishedGestures & newMaybeGestures).isEmpty()); + Q_ASSERT((finishedGestures & canceledGestures).isEmpty()); + Q_ASSERT((canceledGestures & newMaybeGestures).isEmpty()); + + QSet notStarted = finishedGestures - m_activeGestures; + if (!notStarted.isEmpty()) { + // there are some gestures that claim to be finished, but never started. + // probably those are "singleshot" gestures so we'll fake the started state. + foreach (QGesture *gesture, notStarted) + gesture->d_func()->state = Qt::GestureStarted; + QSet undeliveredGestures; + deliverEvents(notStarted, &undeliveredGestures); + finishedGestures -= undeliveredGestures; + } + + m_activeGestures += startedGestures; + // sanity check: all triggered gestures should already be in active gestures list + Q_ASSERT((m_activeGestures & triggeredGestures).size() == triggeredGestures.size()); + m_activeGestures -= finishedGestures; + m_activeGestures -= activeToMaybeGestures; + m_activeGestures -= canceledGestures; + + // set the proper gesture state on each gesture + foreach (QGesture *gesture, startedGestures) gesture->d_func()->state = Qt::GestureStarted; - QSet undeliveredGestures; - deliverEvents(notStarted, &undeliveredGestures); - finishedGestures -= undeliveredGestures; - } + foreach (QGesture *gesture, triggeredGestures) + gesture->d_func()->state = Qt::GestureUpdated; + foreach (QGesture *gesture, finishedGestures) + gesture->d_func()->state = Qt::GestureFinished; + foreach (QGesture *gesture, canceledGestures) + gesture->d_func()->state = Qt::GestureCanceled; + foreach (QGesture *gesture, activeToMaybeGestures) + gesture->d_func()->state = Qt::GestureFinished; + + if (!m_activeGestures.isEmpty() || !m_maybeGestures.isEmpty() || + !startedGestures.isEmpty() || !triggeredGestures.isEmpty() || + !finishedGestures.isEmpty() || !canceledGestures.isEmpty()) { + DEBUG() << "QGestureManager::filterEventThroughContexts:" + << "\n\tactiveGestures:" << m_activeGestures + << "\n\tmaybeGestures:" << m_maybeGestures + << "\n\tstarted:" << startedGestures + << "\n\ttriggered:" << triggeredGestures + << "\n\tfinished:" << finishedGestures + << "\n\tcanceled:" << canceledGestures + << "\n\tmaybe-canceled:" << maybeToCanceledGestures; + } - m_activeGestures += startedGestures; - // sanity check: all triggered gestures should already be in active gestures list - Q_ASSERT((m_activeGestures & triggeredGestures).size() == triggeredGestures.size()); - m_activeGestures -= finishedGestures; - m_activeGestures -= activeToMaybeGestures; - m_activeGestures -= canceledGestures; - - // set the proper gesture state on each gesture - foreach (QGesture *gesture, startedGestures) - gesture->d_func()->state = Qt::GestureStarted; - foreach (QGesture *gesture, triggeredGestures) - gesture->d_func()->state = Qt::GestureUpdated; - foreach (QGesture *gesture, finishedGestures) - gesture->d_func()->state = Qt::GestureFinished; - foreach (QGesture *gesture, canceledGestures) - gesture->d_func()->state = Qt::GestureCanceled; - foreach (QGesture *gesture, activeToMaybeGestures) - gesture->d_func()->state = Qt::GestureFinished; - - if (!m_activeGestures.isEmpty() || !m_maybeGestures.isEmpty() || - !startedGestures.isEmpty() || !triggeredGestures.isEmpty() || - !finishedGestures.isEmpty() || !canceledGestures.isEmpty()) { - DEBUG() << "QGestureManager::filterEventThroughContexts:" - << "\n\tactiveGestures:" << m_activeGestures - << "\n\tmaybeGestures:" << m_maybeGestures - << "\n\tstarted:" << startedGestures - << "\n\ttriggered:" << triggeredGestures - << "\n\tfinished:" << finishedGestures - << "\n\tcanceled:" << canceledGestures - << "\n\tmaybe-canceled:" << maybeToCanceledGestures; - } + QSet undeliveredGestures; + deliverEvents(startedGestures+triggeredGestures+finishedGestures+canceledGestures, + &undeliveredGestures); - QSet undeliveredGestures; - deliverEvents(startedGestures+triggeredGestures+finishedGestures+canceledGestures, - &undeliveredGestures); - - foreach (QGesture *g, startedGestures) { - if (undeliveredGestures.contains(g)) - continue; - if (g->gestureCancelPolicy() == QGesture::CancelAllInContext) { - DEBUG() << "lets try to cancel some"; - // find gestures in context in Qt::GestureStarted or Qt::GestureUpdated state and cancel them - cancelGesturesForChildren(g); + foreach (QGesture *g, startedGestures) { + if (undeliveredGestures.contains(g)) + continue; + if (g->gestureCancelPolicy() == QGesture::CancelAllInContext) { + DEBUG() << "lets try to cancel some"; + // find gestures in context in Qt::GestureStarted or Qt::GestureUpdated state and cancel them + cancelGesturesForChildren(g); + } } - } - m_activeGestures -= undeliveredGestures; + m_activeGestures -= undeliveredGestures; - // reset gestures that ended - QSet endedGestures = - finishedGestures + canceledGestures + undeliveredGestures + maybeToCanceledGestures; - foreach (QGesture *gesture, endedGestures) { - recycle(gesture); - m_gestureTargets.remove(gesture); + // reset gestures that ended + QSet endedGestures = + finishedGestures + canceledGestures + undeliveredGestures + maybeToCanceledGestures; + foreach (QGesture *gesture, endedGestures) { + recycle(gesture); + m_gestureTargets.remove(gesture); + } } - //Clean up the Gestures qDeleteAll(m_gesturesToDelete); m_gesturesToDelete.clear(); -- cgit v1.2.3 From 131a5ab54391a3a9abc5ca3bae6b47cc29dddc91 Mon Sep 17 00:00:00 2001 From: Marcel Krems Date: Mon, 26 Mar 2012 20:12:21 +0200 Subject: Fix QWheelEvent::angleDelta() returning QPoint(). MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Change-Id: I29460bd5a3f485dcd460edc52239d748e7faf6e0 Reviewed-by: Morten Johan Sørvig Reviewed-by: Bradley T. Hughes --- src/widgets/kernel/qwidgetwindow_qpa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qwidgetwindow_qpa.cpp b/src/widgets/kernel/qwidgetwindow_qpa.cpp index ed7371a9bd..6dbd3c1f77 100644 --- a/src/widgets/kernel/qwidgetwindow_qpa.cpp +++ b/src/widgets/kernel/qwidgetwindow_qpa.cpp @@ -383,7 +383,7 @@ void QWidgetWindow::handleWheelEvent(QWheelEvent *event) QPoint mapped = widget->mapFrom(m_widget, event->pos()); - QWheelEvent translated(mapped, event->globalPos(), event->pixelDelta(), event->pixelDelta(), event->delta(), event->orientation(), event->buttons(), event->modifiers()); + QWheelEvent translated(mapped, event->globalPos(), event->pixelDelta(), event->angleDelta(), event->delta(), event->orientation(), event->buttons(), event->modifiers()); QGuiApplication::sendSpontaneousEvent(widget, &translated); } -- cgit v1.2.3 From 1b29481f3bac0b1fd950a59251af8ead0c5b0bd4 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Wed, 28 Mar 2012 14:36:48 -0700 Subject: Documentation cleanup They are comments of Qt3 support members which have been removed already. Change-Id: I4b3dfaac1e5e1c3c13b83e41d0505dd16a4b6a8e Reviewed-by: Friedemann Kleint --- src/widgets/kernel/qapplication.cpp | 19 ------------------- 1 file changed, 19 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index a099faae3f..40263bf632 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -3924,13 +3924,6 @@ bool QApplicationPrivate::notify_helper(QObject *receiver, QEvent * e) \sa isPhase2() */ -/*! - \typedef QApplication::ColorMode - \compat - - Use ColorSpec instead. -*/ - /*! \fn Qt::MacintoshVersion QApplication::macVersion() @@ -4023,18 +4016,6 @@ bool QApplicationPrivate::inPopupMode() const return QApplicationPrivate::popupWidgets != 0; } -/*! \variable QApplication::NormalColors - \compat - - Use \l NormalColor instead. -*/ - -/*! \variable QApplication::CustomColors - \compat - - Use \l CustomColor instead. -*/ - #ifdef QT_KEYPAD_NAVIGATION /*! Sets the kind of focus navigation Qt should use to \a mode. -- cgit v1.2.3 From fd4f165eb78979a3573b9fa1a4a572600f9c47c7 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 3 Apr 2012 09:37:13 +0200 Subject: Fix warnings about unused variables. Fix MSVC warnings about unused q, d where only static functions are used. Change-Id: I239d6fc3c851b0a62434cb09fc0e1967f2e6d031 Reviewed-by: Thiago Macieira --- src/widgets/kernel/qapplication.cpp | 5 ++--- src/widgets/kernel/qapplication_qpa.cpp | 6 ++---- 2 files changed, 4 insertions(+), 7 deletions(-) (limited to 'src/widgets/kernel') diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index 40263bf632..a8b1fa6d1c 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -1977,12 +1977,11 @@ void QApplication::syncX() void QApplicationPrivate::notifyLayoutDirectionChange() { - Q_Q(QApplication); - QWidgetList list = q->topLevelWidgets(); + QWidgetList list = QApplication::topLevelWidgets(); for (int i = 0; i < list.size(); ++i) { QWidget *w = list.at(i); QEvent ev(QEvent::ApplicationLayoutDirectionChange); - q->sendEvent(w, &ev); + QCoreApplication::sendEvent(w, &ev); } } diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp index 97fc794252..bcea2676bc 100644 --- a/src/widgets/kernel/qapplication_qpa.cpp +++ b/src/widgets/kernel/qapplication_qpa.cpp @@ -162,12 +162,11 @@ QWidget *qt_tlw_for_window(QWindow *wnd) void QApplicationPrivate::notifyActiveWindowChange(QWindow *previous) { Q_UNUSED(previous); - Q_Q(QApplication); QWindow *wnd = QGuiApplicationPrivate::focus_window; if (inPopupMode()) // some delayed focus event to ignore return; QWidget *tlw = qt_tlw_for_window(wnd); - q->setActiveWindow(tlw); + QApplication::setActiveWindow(tlw); } static void ungrabKeyboardForPopup(QWidget *popup) @@ -201,7 +200,6 @@ static void grabForPopup(QWidget *popup) void QApplicationPrivate::closePopup(QWidget *popup) { - Q_Q(QApplication); if (!popupWidgets) return; popupWidgets->removeAll(popup); @@ -241,7 +239,7 @@ void QApplicationPrivate::closePopup(QWidget *popup) fw->setFocus(Qt::PopupFocusReason); } else { QFocusEvent e(QEvent::FocusIn, Qt::PopupFocusReason); - q->sendEvent(fw, &e); + QCoreApplication::sendEvent(fw, &e); } } } -- cgit v1.2.3