mirror of
https://git.citron-emu.org/citron/emulator
synced 2025-12-20 11:03:56 +00:00
fix: Add safety checks for input processing and callback cleanup
- Prevent controller input processing until emulation is fully running - Add null checks and prevent double deletion of NPAD callbacks - Set callback_key to -1 after deletion to prevent reuse Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
@@ -5573,6 +5573,11 @@ void GMainWindow::UpdateUISettings() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void GMainWindow::UpdateInputDrivers() {
|
void GMainWindow::UpdateInputDrivers() {
|
||||||
|
// Do not process ANY controller input until emulation is fully running
|
||||||
|
if (!emulation_running) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (!input_subsystem) {
|
if (!input_subsystem) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
|
||||||
|
// SPDX-FileCopyrightText: 2025 citron Emulator Project
|
||||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@@ -46,10 +47,14 @@ NPad::NPad(Core::HID::HIDCore& hid_core_, KernelHelpers::ServiceContext& service
|
|||||||
}
|
}
|
||||||
|
|
||||||
NPad::~NPad() {
|
NPad::~NPad() {
|
||||||
|
// Iterate over ALL aruids and ALL controllers to delete every callback
|
||||||
for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; ++aruid_index) {
|
for (std::size_t aruid_index = 0; aruid_index < AruidIndexMax; ++aruid_index) {
|
||||||
for (std::size_t i = 0; i < controller_data[aruid_index].size(); ++i) {
|
for (std::size_t i = 0; i < controller_data[aruid_index].size(); ++i) {
|
||||||
auto& controller = controller_data[aruid_index][i];
|
auto& controller = controller_data[aruid_index][i];
|
||||||
controller.device->DeleteCallback(controller.callback_key);
|
if (controller.device && controller.callback_key != -1) {
|
||||||
|
controller.device->DeleteCallback(controller.callback_key);
|
||||||
|
controller.callback_key = -1; // Prevent double deletion
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user