Hi,
This is probably a bit stupid question, but I think I’m missing something and I’m not sure what is it.
I’m trying to write a simple app, the main looks as follows:
fn main() -> glib::ExitCode {
let application = gtk::Application::new(
Some("MySuperApp"),
Default::default(),
);
application.connect_activate(build_ui);
application.run()
}
The thing I’m missing happens in build_ui
pub fn build_ui(application: >k::Application) {
...
//this is my custom object that uses Vec, so I figured Rc<RefCell<>> is a way to go here
let mut register = Rc::new(RefCell::new(Register::new()));
//now I want to use register in 2 handlers in a mut way
//here
hex_entry.connect_activate(clone!(@strong register => move |entry| {
//some code
register.borrow_mut()
}
//and here
open_button.connect_clicked(glib::clone!(@weak register => move |_| {
//some code
register.borrow_mut();
}
What I don’t understand is why my app only works if one of the references is @strong
.
I know that Rc counts references every time clone()
is invoked, however my register
object doesn’t implement that trait. Is @strong
keeping it somehow “alive” ?
I know this is very basic stuff, but if someone could explain what am I missing here I’d grateful.