-
-
Notifications
You must be signed in to change notification settings - Fork 78
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
destroy event never called #266
Comments
After some investigation, here's what is happening:
I opened #267 with a fix. Can you test it please? |
It works, it doesn't fix my real problem, but it's a good start 😃 |
Err, is your real problem related to |
I don’t know. The bugs appeared with the latest version. The first one is due to an unowned widget: todotxt-rs/effitask@9fef741 The second is still under investigation. This signal panics ( |
Yeah, those are a different issue and indeed caused by a bug that was fixed in This is discussed in the blog post announcing this new version. Basically, before version 0.21, the It might not always be obvious how to fix it, but if you need more details about this change, please ask me. By the way, I made this a |
I rewrite the widget with multiple widgets view: https://github.com/sanpii/effitask/blob/logger/src/logger.rs It’s cleaner! But still panic… I am going to write an simple application to reproduce this bug.
Logging an error, like gtk does with critical errors? |
I thought about logging, but the Any reason why you prefer logging than a |
A minimalist example to reproduce my bug: use gtk::prelude::*;
use relm::Widget;
#[derive(relm_derive::Msg)]
pub enum Msg {
Destroy,
Quit,
}
#[relm_derive::widget]
impl Widget for Win {
fn model() -> () {
}
fn update(&mut self, _: Msg) {
gtk::main_quit();
}
view! {
#[name="window"]
gtk::Window {
Logger {
},
delete_event(_, _) => (Msg::Quit, gtk::Inhibit(false)),
}
}
}
fn main() {
Win::run(()).expect("Win::run failed");
}
#[relm_derive::widget]
impl relm::Widget for Logger {
fn init_view(&mut self) {
let label = gtk::Label::new(None);
self.widgets.list_box.add(&label);
}
fn model() -> () {
}
fn update(&mut self, _: Msg) {
}
view! {
#[name="toggle"]
gtk::ToggleButton {
}
#[name="popover"]
gtk::Popover {
relative_to: Some(&toggle),
#[name="list_box"]
gtk::ListBox {
destroy(_) => Msg::Destroy,
},
}
}
}
I don’t know if it’s a good idea to crash an application for a non-critical error. Ok, the corresponding action doesn’t work, but you expose users to corrupted data.
Do both: panic in debug mode and log (with In reality, it's just a problem the time it takes to update the application for relm 0.21. |
Note to myself: it could be because of the handling of orphaned widgets. |
The problem persist is a own the label: diff --git i/src/main.rs w/src/main.rs
index 7019d65..0d8a592 100644
--- i/src/main.rs
+++ w/src/main.rs
@@ -33,11 +33,11 @@ fn main() {
#[relm_derive::widget]
impl relm::Widget for Logger {
fn init_view(&mut self) {
- let label = gtk::Label::new(None);
- self.widgets.list_box.add(&label);
+ self.widgets.list_box.add(&self.model);
}
- fn model() -> () {
+ fn model() -> gtk::Label {
+ gtk::Label::new(None)
}
fn update(&mut self, _: Msg) { But disappear if I don’t use a popover widget: diff --git i/src/main.rs w/src/main.rs
index 7019d65..1179b0c 100644
--- i/src/main.rs
+++ w/src/main.rs
@@ -44,17 +44,9 @@ impl relm::Widget for Logger {
}
view! {
- #[name="toggle"]
- gtk::ToggleButton {
- }
-
- #[name="popover"]
- gtk::Popover {
- relative_to: Some(&toggle),
- #[name="list_box"]
- gtk::ListBox {
- destroy(_) => Msg::Destroy,
- },
- }
+ #[name="list_box"]
+ gtk::ListBox {
+ destroy(_) => Msg::Destroy,
+ },
}
} or simply don’t set its relative to: diff --git i/src/main.rs w/src/main.rs
index 7019d65..c59f0b2 100644
--- i/src/main.rs
+++ w/src/main.rs
@@ -50,7 +50,6 @@ impl relm::Widget for Logger {
#[name="popover"]
gtk::Popover {
- relative_to: Some(&toggle),
#[name="list_box"]
gtk::ListBox {
destroy(_) => Msg::Destroy, |
The |
The same program without relm:
The text was updated successfully, but these errors were encountered: