Fix crash when the selected item disappears from a scrubber
objc_id = "0.1"
[dependencies.fruitbasket]
-version = "0.4"
+version = "0.5"
features = ["logging"]
[target."cfg(target_os = \"macos\")".dependencies.objc]
let item = *scrub_id as *mut Object;
let scrubber: *mut Object = msg_send![item, view];
let sel_idx: i32 = msg_send![scrubber, selectedIndex];
+ let pre_count: i32 = msg_send![scrubber, numberOfItems];
let _:() = msg_send![scrubber, reloadData];
+ let post_count: i32 = msg_send![scrubber, numberOfItems];
// reload clears the selected item. re-select it.
- if sel_idx >= 0 {
+ if sel_idx >= 0 && pre_count == post_count {
let _:() = msg_send![scrubber, setSelectedIndex: sel_idx];
}
}