Skip to content

Commit f8388ec

Browse files
committed
joystickstatuswindow: defer deletion of window upon close
Defer deleting the window when it's closed until after the main loop has run. This prevents a segfault when the window is closed for controllers with accelerometers and gyroscopes, such as DualSense controllers. Signed-off-by: Sean Cross <sean@xobs.io>
1 parent ab27f58 commit f8388ec

2 files changed

Lines changed: 3 additions & 0 deletions

File tree

src/gui/joystickstatuswindow.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ JoystickStatusWindow::JoystickStatusWindow(InputDevice *joystick, QWidget *paren
302302
connect(this, &JoystickStatusWindow::finished, this, &JoystickStatusWindow::restoreButtonStates);
303303
}
304304

305+
void JoystickStatusWindow::reject() { this->deleteLater(); }
306+
305307
JoystickStatusWindow::~JoystickStatusWindow() { delete ui; }
306308

307309
void JoystickStatusWindow::restoreButtonStates(int code)

src/gui/joystickstatuswindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ class JoystickStatusWindow : public QDialog
4444
InputDevice *getJoystick() const;
4545

4646
private:
47+
void reject();
4748
Ui::JoystickStatusWindow *ui;
4849

4950
InputDevice *joystick;

0 commit comments

Comments
 (0)