From 48894cc75b08964e0303c8045cb9ec0c274a4c9e Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Fri, 25 Oct 2013 19:51:33 +0200 Subject: [PATCH] QAbstractSpinBox: use QSignalBlocker This change changes the point where signals are unblocked again in QAbstractSpinBoxPrivate::updateEdit() to include the final update() call. This should not be a problem, as update() merely posts an event and shouldn't emit any signals. Change-Id: I4b2ae109f057792b573ad6ea168ca77c18c773d0 Reviewed-by: Olivier Goffart --- src/widgets/widgets/qabstractspinbox.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/widgets/widgets/qabstractspinbox.cpp b/src/widgets/widgets/qabstractspinbox.cpp index af3a4d35f9a..92af91b66e3 100644 --- a/src/widgets/widgets/qabstractspinbox.cpp +++ b/src/widgets/widgets/qabstractspinbox.cpp @@ -1516,13 +1516,12 @@ void QAbstractSpinBoxPrivate::_q_editorCursorPositionChanged(int oldpos, int new * (newpos < pos ? -1 : 1)) - newpos + pos : 0; - const bool wasBlocked = edit->blockSignals(true); + const QSignalBlocker blocker(edit); if (selSize != 0) { edit->setSelection(pos - selSize, selSize); } else { edit->setCursorPosition(pos); } - edit->blockSignals(wasBlocked); } ignoreCursorPositionChanged = false; } @@ -1722,7 +1721,7 @@ void QAbstractSpinBoxPrivate::updateEdit() const bool empty = edit->text().isEmpty(); int cursor = edit->cursorPosition(); int selsize = edit->selectedText().size(); - const bool sb = edit->blockSignals(true); + const QSignalBlocker blocker(edit); edit->setText(newText); if (!specialValue()) { @@ -1734,7 +1733,6 @@ void QAbstractSpinBoxPrivate::updateEdit() edit->setCursorPosition(empty ? prefix.size() : cursor); } } - edit->blockSignals(sb); q->update(); }