diff options
| author | Frank Reininghaus <[email protected]> | 2012-12-07 22:15:32 +0100 |
|---|---|---|
| committer | Frank Reininghaus <[email protected]> | 2012-12-07 22:15:32 +0100 |
| commit | e97c050157890dd1adf14d98bbed4aa86af98354 (patch) | |
| tree | 9cc9009b03c99c82ab8bf4b82b9345815983c691 /src/kitemviews/private/kitemlistroleeditor.cpp | |
| parent | a1353a9d48bc8a45516f7d9323c5a9f99194b310 (diff) | |
Fix keyboard focus handling after renaming items inline
This reverts 951cb9c35d7a9ef814b3de5b359915968da9b881 and
3143acc084d54d43df469b54762bfa10a7050a9f, and fixes the crash caused by
nested event loops by delaying the deletion of the KItemListRoleEditor
until the next item is renamed inline.
BUG: 311206
FIXED-IN: 4.9.5
REVIEW: 107606
Diffstat (limited to 'src/kitemviews/private/kitemlistroleeditor.cpp')
| -rw-r--r-- | src/kitemviews/private/kitemlistroleeditor.cpp | 52 |
1 files changed, 3 insertions, 49 deletions
diff --git a/src/kitemviews/private/kitemlistroleeditor.cpp b/src/kitemviews/private/kitemlistroleeditor.cpp index 78dbfe95b..1e4b5fd4e 100644 --- a/src/kitemviews/private/kitemlistroleeditor.cpp +++ b/src/kitemviews/private/kitemlistroleeditor.cpp @@ -26,9 +26,7 @@ KItemListRoleEditor::KItemListRoleEditor(QWidget *parent) : KTextEdit(parent), m_index(0), m_role(), - m_blockFinishedSignal(false), - m_eventHandlingLevel(0), - m_deleteAfterEventHandling(false) + m_blockFinishedSignal(false) { setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); @@ -66,20 +64,6 @@ QByteArray KItemListRoleEditor::role() const return m_role; } -void KItemListRoleEditor::deleteWhenIdle() -{ - if (m_eventHandlingLevel > 0) { - // We are handling an event at the moment. It could be that we - // are in a nested event loop run by contextMenuEvent() or a - // call of mousePressEvent() which results in drag&drop. - // -> do not call deleteLater() to prevent a crash when we - // return from the nested event loop. - m_deleteAfterEventHandling = true; - } else { - deleteLater(); - } -} - bool KItemListRoleEditor::eventFilter(QObject* watched, QEvent* event) { if (watched == parentWidget() && event->type() == QEvent::Resize) { @@ -91,42 +75,13 @@ bool KItemListRoleEditor::eventFilter(QObject* watched, QEvent* event) bool KItemListRoleEditor::event(QEvent* event) { - ++m_eventHandlingLevel; - if (event->type() == QEvent::FocusOut) { QFocusEvent* focusEvent = static_cast<QFocusEvent*>(event); if (focusEvent->reason() != Qt::PopupFocusReason) { emitRoleEditingFinished(); } } - - const int result = KTextEdit::event(event); - --m_eventHandlingLevel; - - if (m_deleteAfterEventHandling && m_eventHandlingLevel == 0) { - // Schedule this object for deletion and make sure that we do not try - // to deleteLater() again when the DeferredDelete event is received. - deleteLater(); - m_deleteAfterEventHandling = false; - } - - return result; -} - -bool KItemListRoleEditor::viewportEvent(QEvent* event) -{ - ++m_eventHandlingLevel; - const bool result = KTextEdit::viewportEvent(event); - --m_eventHandlingLevel; - - if (m_deleteAfterEventHandling && m_eventHandlingLevel == 0) { - // Schedule this object for deletion and make sure that we do not try - // to deleteLater() again when the DeferredDelete event is received. - deleteLater(); - m_deleteAfterEventHandling = false; - } - - return result; + return KTextEdit::event(event); } void KItemListRoleEditor::keyPressEvent(QKeyEvent* event) @@ -144,8 +99,7 @@ void KItemListRoleEditor::keyPressEvent(QKeyEvent* event) return; case Qt::Key_Enter: case Qt::Key_Return: - // TODO: find a better way to fix the bug 309760 - clearFocus(); // emitRoleEditingFinished(); results in a crash + emitRoleEditingFinished(); event->accept(); return; default: |
