Skip to content

Commit

Permalink
Fix crashing when attempting to lock shared memory (#76)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sainan authored Oct 21, 2024
1 parent 89c15df commit cd412d3
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions wooting-analog-test-plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,6 @@ pub struct SharedState {
pub manufacturer_name: [u8; 20],
/// Device name
pub device_name: [u8; 20],
/// Unique device ID, which should be generated using `generate_device_id`
pub device_id: DeviceID,

pub device_type: DeviceType,

Expand Down Expand Up @@ -63,7 +61,6 @@ impl WootingAnalogTestPlugin {

let t_buffer = Arc::clone(&buffer);
let t_device = Arc::clone(&device);
let t_device_id = Arc::clone(&device_id);
let t_device_event_cb = Arc::clone(&device_event_cb);
let t_device_connected = Arc::clone(&device_connected);
let t_thread_running = Arc::clone(&thread_running);
Expand Down Expand Up @@ -108,7 +105,6 @@ impl WootingAnalogTestPlugin {
};
shared_state.vendor_id = 0x03eb;
shared_state.product_id = 0xFFFF;
shared_state.device_id = 1;
shared_state.device_type = DeviceType::Keyboard;
shared_state.device_connected = false;
shared_state.dirty_device_info = false;
Expand Down Expand Up @@ -145,10 +141,9 @@ impl WootingAnalogTestPlugin {
.to_string(),
from_ut8f_to_null(&state.device_name[..], state.device_name.len())
.to_string(),
state.device_id,
1,
state.device_type.clone(),
);
*t_device_id.lock().unwrap() = state.device_id;
t_device.lock().unwrap().replace(dev);
}
if *t_device_connected.lock().unwrap() != state.device_connected {
Expand Down

0 comments on commit cd412d3

Please # to comment.