Skip to content

Commit a18ce17

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 a18ce17

2 files changed

Lines changed: 6 additions & 3 deletions

File tree

src/gui/joystickstatuswindow.cpp

Lines changed: 5 additions & 3 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)
@@ -336,9 +338,9 @@ void JoystickStatusWindow::updateAccelerometerValues(float valueX, float valueY,
336338
*/
337339
void JoystickStatusWindow::updateGyroscopeValues(float valueX, float valueY, float valueZ)
338340
{
339-
m_gyro_axes[0]->setValue(JoySensor::radToDeg(valueX) * 1000);
340-
m_gyro_axes[1]->setValue(JoySensor::radToDeg(valueY) * 1000);
341-
m_gyro_axes[2]->setValue(JoySensor::radToDeg(valueZ) * 1000);
341+
m_gyro_axes[0]->setValue(valueX * 1000);
342+
m_gyro_axes[1]->setValue(valueY * 1000);
343+
m_gyro_axes[2]->setValue(valueZ * 1000);
342344
}
343345

344346
InputDevice *JoystickStatusWindow::getJoystick() const { return joystick; }

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)