diff --git a/src/widgets/widgets/qwidgetlinecontrol.cpp b/src/widgets/widgets/qwidgetlinecontrol.cpp index ded325a121..c04671b710 100644 --- a/src/widgets/widgets/qwidgetlinecontrol.cpp +++ b/src/widgets/widgets/qwidgetlinecontrol.cpp @@ -265,13 +265,13 @@ void QWidgetLineControl::setSelection(int start, int length) } if (length > 0) { - if (start == m_selstart && start + length == m_selend) + if (start == m_selstart && start + length == m_selend && m_cursor == m_selend) return; m_selstart = start; m_selend = qMin(start + length, (int)m_text.length()); m_cursor = m_selend; } else if (length < 0){ - if (start == m_selend && start + length == m_selstart) + if (start == m_selend && start + length == m_selstart && m_cursor == m_selstart) return; m_selstart = qMax(start + length, 0); m_selend = start; @@ -434,6 +434,7 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event) || event->preeditString() != preeditAreaText() || event->replacementLength() > 0; bool cursorPositionChanged = false; + bool selectionChange = false; if (isGettingInput) { // If any text is being input, remove selected text. @@ -477,6 +478,7 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event) if (m_selend < m_selstart) { qSwap(m_selstart, m_selend); } + selectionChange = true; } else { m_selstart = m_selend = 0; } @@ -514,6 +516,8 @@ void QWidgetLineControl::processInputMethodEvent(QInputMethodEvent *event) emit updateMicroFocus(); if (isGettingInput) finishChange(priorState); + if (selectionChange) + emit selectionChanged(); } /*! @@ -601,7 +605,7 @@ void QWidgetLineControl::selectWordAtPos(int cursor) bool QWidgetLineControl::finishChange(int validateFromState, bool update, bool edited) { Q_UNUSED(update) - bool lineDirty = m_selDirty; + if (m_textDirty) { // do validation bool wasValidInput = m_validInput; @@ -632,7 +636,7 @@ bool QWidgetLineControl::finishChange(int validateFromState, bool update, bool e m_textDirty = false; } updateDisplayText(); - lineDirty |= m_textDirty; + if (m_textDirty) { m_textDirty = false; QString actualText = text();