Skip to content

Commit

Permalink
Merge pull request #6092 from csabella/issue5426
Browse files Browse the repository at this point in the history
PR: Fix segfault on shortcut preferences when using mouse
  • Loading branch information
ccordoba12 authored Dec 30, 2017
2 parents 8c1a391 + 9243517 commit b8c0b78
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 b8c0b78

Please sign in to comment.