{"action":"created","issue":{"url":"https://api.github.com/repos/jeremyletang/rgtk/issues/28","labels_url":"https://api.github.com/repos/jeremyletang/rgtk/issues/28/labels{/name}","comments_url":"https://api.github.com/repos/jeremyletang/rgtk/issues/28/comments","events_url":"https://api.github.com/repos/jeremyletang/rgtk/issues/28/events","html_url":"https://github.com/jeremyletang/rgtk/issues/28","id":36908640,"number":28,"title":"Closures fundamentally broken","user":{"login":"mathijshenquet","id":242143,"avatar_url":"https://avatars.githubusercontent.com/u/242143?v=3","gravatar_id":"","url":"https://api.github.com/users/mathijshenquet","html_url":"https://github.com/mathijshenquet","followers_url":"https://api.github.com/users/mathijshenquet/followers","following_url":"https://api.github.com/users/mathijshenquet/following{/other_user}","gists_url":"https://api.github.com/users/mathijshenquet/gists{/gist_id}","starred_url":"https://api.github.com/users/mathijshenquet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mathijshenquet/subscriptions","organizations_url":"https://api.github.com/users/mathijshenquet/orgs","repos_url":"https://api.github.com/users/mathijshenquet/repos","events_url":"https://api.github.com/users/mathijshenquet/events{/privacy}","received_events_url":"https://api.github.com/users/mathijshenquet/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2014-07-01T16:20:24Z","updated_at":"2015-03-03T21:59:31Z","closed_at":null,"body":"Closures right now are fundamentally broken:\r\n\r\n    fn main(){\r\n        make_window();\r\n        gtk::main();\r\n    }\r\n\r\n    fn make_window(){\r\n\r\n        let mut window = gtk::Window::new(gtk::window_type::TopLevel).unwrap();\r\n        let drawing_area = DrawingArea::new().unwrap();\r\n\r\n        drawing_area.connect(signals::Draw::new(|cr| \r\n            drawing_area.get_allocated_area() //`drawing_area` is garbage\r\n        ));\r\n\r\n        window.add(drawing_area);\r\n        window.show_all();\r\n    }\r\n\r\nThis is because rust only has stack closures for now. When `make_window` is finished and it's stack goes out of scope all referenced variables inside the callback become garbage.\r\n\r\nI'll be able to fix this when https://github.com/rust-lang/rfcs/pull/114 gets merged.\r\n\r\n"},"comment":{"url":"https://api.github.com/repos/jeremyletang/rgtk/issues/comments/77045544","html_url":"https://github.com/jeremyletang/rgtk/issues/28#issuecomment-77045544","issue_url":"https://api.github.com/repos/jeremyletang/rgtk/issues/28","id":77045544,"user":{"login":"oakes","id":216147,"avatar_url":"https://avatars.githubusercontent.com/u/216147?v=3","gravatar_id":"","url":"https://api.github.com/users/oakes","html_url":"https://github.com/oakes","followers_url":"https://api.github.com/users/oakes/followers","following_url":"https://api.github.com/users/oakes/following{/other_user}","gists_url":"https://api.github.com/users/oakes/gists{/gist_id}","starred_url":"https://api.github.com/users/oakes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/oakes/subscriptions","organizations_url":"https://api.github.com/users/oakes/orgs","repos_url":"https://api.github.com/users/oakes/repos","events_url":"https://api.github.com/users/oakes/events{/privacy}","received_events_url":"https://api.github.com/users/oakes/received_events","type":"User","site_admin":false},"created_at":"2015-03-03T21:59:31Z","updated_at":"2015-03-03T21:59:31Z","body":"Is there a fundamental problem with unboxed closures that requires boxed closures to be used instead? I don't know enough about Rust internals to understand what the problem is."}}