Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PR: Fix segfault on shortcut preferences when using mouse #6092

Merged
merged 1 commit into from
Dec 30, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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