From 55d43a1d57369dd689db523156b0801eff8d0a05 Mon Sep 17 00:00:00 2001 From: rdb Date: Sat, 26 Dec 2020 12:45:13 +0100 Subject: [PATCH] device: Fix macOS crash when unplugging device in threaded pipeline Fixes #1082 --- doc/ReleaseNotes | 1 + panda/src/device/inputDeviceManager.cxx | 2 ++ 2 files changed, 3 insertions(+) diff --git a/doc/ReleaseNotes b/doc/ReleaseNotes index 376bbc8f63..83fe5b1bd5 100644 --- a/doc/ReleaseNotes +++ b/doc/ReleaseNotes @@ -4,6 +4,7 @@ Recommended maintenance release. * Support building for macOS 11 "Big Sur" and "Apple Silicon" (arm64) * Fix a memory leak, particularly noticeable with multithreaded pipeline (#1077) +* Fix crash on macOS when unplugging device with threading active (#1082) * Fix error with build_apps not working with certain versions of Python * Fix DirectEntry/PGEntry flickering in the multithreaded pipeline (#1070) * Fix sounds resuming on reactivation if stop() was called while inactive (#559) diff --git a/panda/src/device/inputDeviceManager.cxx b/panda/src/device/inputDeviceManager.cxx index 8cd470e271..9f4f81c833 100644 --- a/panda/src/device/inputDeviceManager.cxx +++ b/panda/src/device/inputDeviceManager.cxx @@ -111,6 +111,8 @@ add_device(InputDevice *device) { */ void InputDeviceManager:: remove_device(InputDevice *device) { + // We need to hold a reference, since remove_device decrements the refcount. + PT(InputDevice) device_ref = device; { LightMutexHolder holder(_lock); _connected_devices.remove_device(device);