summary history branches tags files
commit:db10ff8e87cb31a60c74ec08b3c2c496dc9586ff
author:Trevor Bentley
committer:GitHub
date:Fri Nov 17 10:23:26 2017 +0100
parents:1e45490a8eb4c5beea4bcfa42a9468cf4b5c3eea, 36e83259a5aca226db1fef68a93b35f7f64c7a39
Merge pull request #12 from mrmekon/scrubber_crash

Fix scrubber crash
diff --git a/Cargo.toml b/Cargo.toml
line changes: +2/-2
index 55903d3..ffba85f
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "rubrail"
-version = "0.4.4-rc"
+version = "0.5.1-rc"
 authors = ["Trevor Bentley <mrmekon@gmail.com>"]
 description = "Rubrail is a Rust library for interfacing with the Mac Touch Bar"
 keywords = ["macos", "touchbar", "osx", "mac"]
@@ -31,7 +31,7 @@ objc-foundation = "0.1.1"
 objc_id = "0.1"
 
 [dependencies.fruitbasket]
-version = "0.4"
+version = "0.5"
 features = ["logging"]
 
 [target."cfg(target_os = \"macos\")".dependencies.objc]

diff --git a/src/touchbar.rs b/src/touchbar.rs
line changes: +3/-1
index b26ddd1..90c8cf5
--- a/src/touchbar.rs
+++ b/src/touchbar.rs
@@ -783,9 +783,11 @@ impl TTouchbar for Touchbar {
             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];
             }
         }