Improve error handling
This commit is contained in:
parent
795e4b20f2
commit
2ec2fda116
4 changed files with 32 additions and 36 deletions
|
|
@ -58,7 +58,12 @@ fn on_media_sort_activated < A : MediaAdapter + 'static > (
|
|||
on_sort : & impl Fn ( A :: Sorting ) ,
|
||||
sort_icons : & [ Image ] ,
|
||||
) {
|
||||
let ( sorting_property , _ ) = A :: get_property_descriptions () [ row as usize ] . clone () ; // TODO: Bounds checking
|
||||
let row = row as usize ;
|
||||
debug_assert ! (
|
||||
row <= A :: get_property_descriptions () . len () ,
|
||||
"Sorting menu has more rows than media adapter has property descriptions" ,
|
||||
) ;
|
||||
let ( sorting_property , _ ) = A :: get_property_descriptions () [row] . clone () ;
|
||||
|
||||
let previous_sorting = * previous_sorting_mut . borrow () ;
|
||||
if sorting_property == previous_sorting . get_property () {
|
||||
|
|
@ -66,20 +71,20 @@ fn on_media_sort_activated < A : MediaAdapter + 'static > (
|
|||
Ascending => {
|
||||
let new_sorting = A :: Sorting :: new ( sorting_property , Descending ) ;
|
||||
previous_sorting_mut . replace (new_sorting) ;
|
||||
sort_icons [ row as usize ] . set_icon_name ( Some ("view-sort-descending-symbolic") ) ;
|
||||
sort_icons [row] . set_icon_name ( Some ("view-sort-descending-symbolic") ) ;
|
||||
on_sort (new_sorting) ;
|
||||
} ,
|
||||
Descending => {
|
||||
let new_sorting = A :: Sorting :: new ( sorting_property , Ascending ) ;
|
||||
previous_sorting_mut . replace (new_sorting) ;
|
||||
sort_icons [ row as usize ] . set_icon_name ( Some ("view-sort-ascending-symbolic") ) ;
|
||||
sort_icons [row] . set_icon_name ( Some ("view-sort-ascending-symbolic") ) ;
|
||||
on_sort (new_sorting) ;
|
||||
} ,
|
||||
}
|
||||
} else {
|
||||
let new_sorting = A :: Sorting :: new ( sorting_property , Ascending ) ;
|
||||
previous_sorting_mut . replace (new_sorting) ;
|
||||
sort_icons [ row as usize ] . set_icon_name ( Some ("view-sort-ascending-symbolic") ) ;
|
||||
sort_icons [row] . set_icon_name ( Some ("view-sort-ascending-symbolic") ) ;
|
||||
on_sort (new_sorting) ;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue