┌   ┐
54
└   ┘

summaryrefslogtreecommitdiff
path: root/src/kitemviews/private
diff options
context:
space:
mode:
authorFrank Reininghaus <[email protected]>2012-12-07 22:31:24 +0100
committerFrank Reininghaus <[email protected]>2012-12-07 22:31:24 +0100
commitb2a580c2b9b85a5a5b91e2eb3f218cea3b7b98c3 (patch)
tree322ef1d66572d86ce2dcbcab859535d64cd3fec4 /src/kitemviews/private
parent46f2c2ef3c90ccb5741455d488cec578ff981ddf (diff)
parente97c050157890dd1adf14d98bbed4aa86af98354 (diff)
Merge remote-tracking branch 'origin/KDE/4.9'
Diffstat (limited to 'src/kitemviews/private')
-rw-r--r--src/kitemviews/private/kitemlistroleeditor.cpp52
-rw-r--r--src/kitemviews/private/kitemlistroleeditor.h12
2 files changed, 3 insertions, 61 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:
diff --git a/src/kitemviews/private/kitemlistroleeditor.h b/src/kitemviews/private/kitemlistroleeditor.h
index a2f705808..aa2c97754 100644
--- a/src/kitemviews/private/kitemlistroleeditor.h
+++ b/src/kitemviews/private/kitemlistroleeditor.h
@@ -47,15 +47,6 @@ public:
void setRole(const QByteArray& role);
QByteArray role() const;
- /**
- * Calls deleteLater() if no event is being handled at the moment.
- * Otherwise, the deletion is deferred until the event handling is
- * finished. This prevents that the deletion happens inside a nested
- * event loop which might be run in contextMenuEvent() or
- * mouseMoveEvent() because this would probably cause a crash.
- */
- void deleteWhenIdle();
-
virtual bool eventFilter(QObject* watched, QEvent* event);
signals:
@@ -64,7 +55,6 @@ signals:
protected:
virtual bool event(QEvent* event);
- virtual bool viewportEvent(QEvent* event);
virtual void keyPressEvent(QKeyEvent* event);
private slots:
@@ -85,8 +75,6 @@ private:
int m_index;
QByteArray m_role;
bool m_blockFinishedSignal;
- int m_eventHandlingLevel;
- bool m_deleteAfterEventHandling;
};
#endif