all repos — mgba @ 17d343656f2bd4e0ae212d3abdc10e6e5108049a

mGBA Game Boy Advance Emulator

Qt: Fix some focus crashes
Jeffrey Pfau jeffrey@endrift.com
Mon, 18 Jan 2016 19:36:13 -0800
commit

17d343656f2bd4e0ae212d3abdc10e6e5108049a

parent

13dfb144e88290b0e747ac51391f0882e57ce4b2

3 files changed, 11 insertions(+), 4 deletions(-)

jump to
M src/platform/qt/SensorView.cppsrc/platform/qt/SensorView.cpp

@@ -81,9 +81,10 @@ button->installEventFilter(this);

} bool SensorView::event(QEvent* event) { - if (event->type() == QEvent::WindowActivate) { + QEvent::Type type = event->type(); + if (type == QEvent::WindowActivate || type == QEvent::Show) { m_input->stealFocus(this); - } else if (event->type() == QEvent::WindowDeactivate) { + } else if (type == QEvent::WindowDeactivate || type == QEvent::Hide) { m_input->releaseFocus(this); } return QWidget::event(event);
M src/platform/qt/ShortcutView.cppsrc/platform/qt/ShortcutView.cpp

@@ -37,6 +37,10 @@ connect(m_ui.shortcutTable, SIGNAL(doubleClicked(const QModelIndex&)), this, SLOT(load(const QModelIndex&)));

connect(m_ui.clearButton, SIGNAL(clicked()), this, SLOT(clear())); } +ShortcutView::~ShortcutView() { + m_input->releaseFocus(this); +} + void ShortcutView::setController(ShortcutController* controller) { m_controller = controller; m_ui.shortcutTable->setModel(controller);

@@ -117,9 +121,10 @@ }

bool ShortcutView::event(QEvent* event) { if (m_input) { - if (event->type() == QEvent::WindowActivate) { + QEvent::Type type = event->type(); + if (type == QEvent::WindowActivate || type == QEvent::Show) { m_input->stealFocus(this); - } else if (event->type() == QEvent::WindowDeactivate) { + } else if (type == QEvent::WindowDeactivate || type == QEvent::Hide) { m_input->releaseFocus(this); } }
M src/platform/qt/ShortcutView.hsrc/platform/qt/ShortcutView.h

@@ -22,6 +22,7 @@ Q_OBJECT

public: ShortcutView(QWidget* parent = nullptr); + ~ShortcutView(); void setController(ShortcutController* controller); void setInputController(InputController* input);