mirror of
https://git.eden-emu.dev/archive/citron
synced 2026-03-23 01:56:08 -04:00
fix(ui): Improper Overlay Shutdown & Zombie Processes
Signed-off-by: Collecting <collecting@noreply.localhost>
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
|
#include <QCoreApplication>
|
||||||
#include <QMenu>
|
#include <QMenu>
|
||||||
#include <QPainter>
|
#include <QPainter>
|
||||||
#include <QTimer>
|
#include <QTimer>
|
||||||
@@ -23,8 +24,16 @@ PlayerControlPreview::PlayerControlPreview(QWidget* parent) : QFrame(parent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
PlayerControlPreview::~PlayerControlPreview() {
|
PlayerControlPreview::~PlayerControlPreview() {
|
||||||
|
// If the app is closing down, the "controller" memory is likely garbage.
|
||||||
|
// We must NOT touch it or call UnloadController().
|
||||||
|
if (QCoreApplication::closingDown()) {
|
||||||
|
controller = nullptr;
|
||||||
|
is_controller_set = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
UnloadController();
|
UnloadController();
|
||||||
};
|
}
|
||||||
|
|
||||||
void PlayerControlPreview::SetRawJoystickVisible(bool visible) {
|
void PlayerControlPreview::SetRawJoystickVisible(bool visible) {
|
||||||
raw_joystick_visible = visible;
|
raw_joystick_visible = visible;
|
||||||
@@ -51,14 +60,22 @@ void PlayerControlPreview::SetController(Core::HID::EmulatedController* controll
|
|||||||
}
|
}
|
||||||
|
|
||||||
void PlayerControlPreview::UnloadController() {
|
void PlayerControlPreview::UnloadController() {
|
||||||
// Only try to access the controller if the pointer is valid.
|
// If the app is closing or the key is invalid, just reset pointers and quit.
|
||||||
|
if (QCoreApplication::closingDown() || callback_key < 0) {
|
||||||
|
is_controller_set = false;
|
||||||
|
controller = nullptr;
|
||||||
|
callback_key = -1;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (controller) {
|
if (controller) {
|
||||||
controller->DeleteCallback(callback_key);
|
controller->DeleteCallback(callback_key);
|
||||||
// Also clear the destruction callback we set.
|
|
||||||
controller->SetDestructionCallback(nullptr);
|
controller->SetDestructionCallback(nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
is_controller_set = false;
|
is_controller_set = false;
|
||||||
controller = nullptr;
|
controller = nullptr;
|
||||||
|
callback_key = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerControlPreview::BeginMappingButton(std::size_t button_id) {
|
void PlayerControlPreview::BeginMappingButton(std::size_t button_id) {
|
||||||
|
|||||||
Reference in New Issue
Block a user