Remove Rc<RefCell<T>> pattern in widgets::members_list
This commit is contained in:
parent
8d2f94709b
commit
ce605b8233
1 changed files with 4 additions and 7 deletions
|
@ -1,8 +1,6 @@
|
||||||
use glib::clone;
|
use glib::clone;
|
||||||
use matrix_sdk::identifiers::UserId;
|
use matrix_sdk::identifiers::UserId;
|
||||||
use std::cell::RefCell;
|
use std::{cell::RefCell, collections::hash_map::HashMap};
|
||||||
use std::collections::hash_map::HashMap;
|
|
||||||
use std::rc::Rc;
|
|
||||||
|
|
||||||
use glib::signal;
|
use glib::signal;
|
||||||
use gtk::prelude::*;
|
use gtk::prelude::*;
|
||||||
|
@ -69,12 +67,11 @@ impl MembersList {
|
||||||
Some(w.get_text().to_string()),
|
Some(w.get_text().to_string()),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
/* we need to remove the handler when the member list is destroyed */
|
// We need to remove the handler when the member list is destroyed
|
||||||
let id: Rc<RefCell<Option<signal::SignalHandlerId>>> = Rc::new(RefCell::new(Some(id)));
|
let id = RefCell::new(Some(id));
|
||||||
let search_entry = self.search_entry.clone();
|
let search_entry = self.search_entry.clone();
|
||||||
self.container.connect_destroy(move |_| {
|
self.container.connect_destroy(move |_| {
|
||||||
let id = id.borrow_mut().take();
|
if let Some(id) = id.borrow_mut().take() {
|
||||||
if let Some(id) = id {
|
|
||||||
signal::signal_handler_disconnect(&search_entry, id);
|
signal::signal_handler_disconnect(&search_entry, id);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue