Skip to content

Commit 239dc40

Browse files
committed
device: fix crash when unplugging certain devices on macOS
Fixes panda3d#621
1 parent 5530074 commit 239dc40

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

panda/src/device/ioKitInputDevice.cxx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,11 @@
2222
#include "mouseButton.h"
2323

2424
static void removal_callback(void *ctx, IOReturn result, void *sender) {
25-
IOKitInputDevice *input_device = (IOKitInputDevice *)ctx;
25+
// We need to hold a reference to this because it may otherwise be destroyed
26+
// during the call to on_remove().
27+
PT(IOKitInputDevice) input_device = (IOKitInputDevice *)ctx;
2628
nassertv(input_device != nullptr);
29+
nassertv(input_device->test_ref_count_integrity());
2730
input_device->on_remove();
2831
}
2932

0 commit comments

Comments
 (0)