-
Notifications
You must be signed in to change notification settings - Fork 106
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
[BUG]app crashed when click on tree node #1544
Comments
Thank you for the detailed report. |
I tried the following program on linux: use fltk::prelude::*;
use fltk::*;
fn main() {
let app = app::App::default();
let mut w = window::Window::default().with_size(400, 300);
let mut tree = tree::Tree::default().with_size(400, 300);
tree.set_root_label(".");
tree.set_select_mode(tree::TreeSelect::Multi);
// tree.set_color(Color::Blue);
for i in 0 .. 5 {
let ti = tree::TreeItem::new(&tree, &*("item".to_owned() + &*i.to_string()));
tree.add_item("2/2/3/1", &ti);
}
for i in 0 .. 5 {
tree.add(&*("item".to_owned() + &*i.to_string()));
}
tree.set_callback(|t| {
if let Some(items) = t.get_selected_items() {
for i in items {
println!("{} selected", t.item_pathname(&i).unwrap());
}
}
});
w.end();
w.show();
app.run().unwrap();
} It doesn't cause a crash and also ran it under valgrind with no memory errors. Can you check on your system? |
@MoAlyousef Thank you but sorry of my misleading message. Yes and your code works well. So I tried many times to comment / uncomment some code blocks in my project back and forth and eventually I found out the code causing crash. Badly I can't figure it out why the code is incorrect. So I uploaded it to a repo and create a pr. Please help me to solve it. you can see that it's |
Thank you for sharing the code. I was able to minimize it to the following: use fltk::prelude::*;
use fltk::*;
use fltk::enums::*;
fn main() {
let app = app::App::default();
let mut w = window::Window::default().with_size(400, 300);
let mut i = input::Input::new(0, 0, 400, 40, None);
let mut tree = tree::Tree::new(0, 40, 400, 260, None);
tree.set_root_label(".");
tree.set_select_mode(tree::TreeSelect::Multi);
for i in 0 .. 5 {
let ti = tree::TreeItem::new(&tree, &*("item".to_owned() + &*i.to_string()));
tree.add_item("2/2/3/1", &ti);
}
w.end();
w.show();
i.handle(move |i, ev| match ev {
Event::Unfocus => {
tree.clear();
true
}
_ => false,
});
app.run().unwrap();
} I believe it's an issue with FLTK's focus. I'll try to reproduce in C++ then I'll report it there. |
I've reported this and a fix was applied. If you can try the master branch by adding to your Cargo.toml: [patch.crates-io]
fltk = { git = "https://github.com/fltk-rs/fltk-rs" } Note, the issue upstream is still open for input by other core FLTK devs. |
Yes man, it works as expected. good job doc! I'll close this issue. |
Remember to search before filing a new report
no similar issue found.
Describe the bug
I'm writing a little desktop app on Mac and using
Tree
.The core code is
when the 2nd
for
block is commented out, the app runs well. But after I added it to logic, when I click on any tree node, the App will crash.Process finished with exit code 139 (interrupted by signal 11:SIGSEGV)
To Reproduce
see code above.
fltk=1.4.28
Expected behavior
no crash.
Screenshots
Desktop info
Additional info
System catch info :
The text was updated successfully, but these errors were encountered: