Fix the infinite event recursion in the klipper popup.

Klipper crashes when any modifier key (with the exception of ALT) is pressed.

This is because it enters into an infinite recursion.
This happens because Klipper popup delegates all events to its input field.
The input field does not consume the event, so it is propagated to the parent widget,
which is the popup. The popup tries to send the event to the input field again.

Since klipper is now part of plasma, this bug kills the entire shell

REVIEW: 122106
BUG: 342947
wilder-5.14
Filip Wieladek 11 years ago committed by David Edmundson
parent 8d831d9dfc
commit c01ab8aa2a
  1. 15
      klipper/klipperpopup.cpp
  2. 5
      klipper/klipperpopup.h

@ -75,7 +75,8 @@ KlipperPopup::KlipperPopup( History* history )
m_filterWidget( 0 ),
m_filterWidgetAction( 0 ),
m_nHistoryItems( 0 ),
m_showHelp(true)
m_showHelp(true),
m_lastEvent(NULL)
{
ensurePolished();
KWindowInfo windowInfo( winId(), NET::WMGeometry );
@ -181,6 +182,15 @@ void KlipperPopup::plugAction( QAction* action ) {
/* virtual */
void KlipperPopup::keyPressEvent( QKeyEvent* e ) {
// Most events are send down directly to the m_filterWidget.
// If the m_filterWidget does not handle the event, it will
// come back to this method. Remembering the last event stops
// the infinite event loop
if (m_lastEvent == e) {
m_lastEvent= NULL;
return;
}
m_lastEvent= e;
// If alt-something is pressed, select a shortcut
// from the menu. Do this by sending a keyPress
// without the alt-modifier to the superobject.
@ -240,8 +250,8 @@ void KlipperPopup::keyPressEvent( QKeyEvent* e ) {
#endif
setActiveAction(actions().at(actions().indexOf(m_filterWidgetAction)));
QString lastString = m_filterWidget->text();
QApplication::sendEvent(m_filterWidget, e);
QApplication::sendEvent(m_filterWidget, e);
if (m_filterWidget->text() != lastString) {
m_dirty = true;
rebuild(m_filterWidget->text());
@ -250,6 +260,7 @@ void KlipperPopup::keyPressEvent( QKeyEvent* e ) {
break;
} //default:
} //case
m_lastEvent= NULL;
}

@ -125,6 +125,11 @@ private:
bool m_showHelp;
/**
* The last event which was received. Used to avoid an infinite event loop
*/
QKeyEvent* m_lastEvent;
};
#endif

Loading…
Cancel
Save