image_view: Pass model to update_action_state()
Due to the latest refactoring passes, it was possible for the model to be borrowed twice when navigating to a file. This commit makes model an argument to update_action_state() so we don't need to acquire another borrow. We have the model already in all cases where we use update_action_state().
This commit is contained in:
parent
ddb02d0eb7
commit
e8511bf5d5
1 changed files with 4 additions and 8 deletions
|
|
@ -191,7 +191,7 @@ impl LpImageView {
|
|||
imp.filename.replace(util::get_file_display_name(file));
|
||||
carousel.append(&LpImagePage::from_file(file));
|
||||
self.fill_carousel(model, index);
|
||||
self.update_action_state(index);
|
||||
self.update_action_state(model, index);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -243,7 +243,7 @@ impl LpImageView {
|
|||
// Clear everything on either side, then refill
|
||||
self.clear_carousel(true);
|
||||
self.fill_carousel(model, new_index);
|
||||
self.update_action_state(new_index);
|
||||
self.update_action_state(model, new_index);
|
||||
|
||||
drop(guard);
|
||||
}
|
||||
|
|
@ -290,11 +290,7 @@ impl LpImageView {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn update_action_state(&self, index: u32) {
|
||||
let imp = self.imp();
|
||||
let b = imp.model.borrow();
|
||||
let model = b.as_ref().unwrap();
|
||||
|
||||
pub fn update_action_state(&self, model: &LpFileModel, index: u32) {
|
||||
let next_enabled = model.item(index + 1).is_some();
|
||||
let prev_enabled = index.checked_sub(1).and_then(|i| model.item(i)).is_some();
|
||||
|
||||
|
|
@ -315,7 +311,7 @@ impl LpImageView {
|
|||
if model_index != prev_index {
|
||||
imp.filename.replace(util::get_file_display_name(¤t));
|
||||
self.notify("filename");
|
||||
self.update_action_state(model_index);
|
||||
self.update_action_state(model, model_index);
|
||||
|
||||
// We've moved forward
|
||||
if let Some(diff) = model_index.checked_sub(prev_index) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue