Skip to content

Commit

Permalink
issue 5426: Seg fault on shortcut preferences when using mouse
Browse files Browse the repository at this point in the history
  • Loading branch information
csabella committed Dec 29, 2017
1 parent 9ce4b69 commit 9243517
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion spyder/plugins/shortcuts.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
from qtpy import PYQT5
from qtpy.compat import from_qvariant, to_qvariant
from qtpy.QtCore import (QAbstractTableModel, QModelIndex, QRegExp,
QSortFilterProxyModel, Qt)
QSortFilterProxyModel, Qt, Slot)
from qtpy.QtGui import (QKeySequence, QRegExpValidator)
from qtpy.QtWidgets import (QAbstractItemView, QApplication, QDialog,
QDialogButtonBox, QGridLayout, QHBoxLayout, QLabel,
Expand Down Expand Up @@ -204,6 +204,24 @@ def __init__(self, parent, context, name, sequence, shortcuts):
bbox.accepted.connect(self.accept)
bbox.rejected.connect(self.reject)

@Slot()
def reject(self):
"""Slot for rejected signal."""
# Added for issue #5426. Due to the focusPolicy of Qt.NoFocus for the
# buttons, if the cancel button was clicked without first setting focus
# to the button, it would cause a seg fault crash.
self.button_cancel.setFocus()
super().reject()

@Slot()
def accept(self):
"""Slot for accepted signal."""
# Added for issue #5426. Due to the focusPolicy of Qt.NoFocus for the
# buttons, if the ok button was clicked without first setting focus to
# the button, it would cause a seg fault crash.
self.button_ok.setFocus()
super().accept()

def keyPressEvent(self, e):
"""Qt override."""
key = e.key()
Expand Down

0 comments on commit 9243517

Please sign in to comment.