Skip to content

Commit

Permalink
fix(axevent): Allow undeclaring without callback
Browse files Browse the repository at this point in the history
`apps/send_event/src/main.rs`:
- Consistently undeclare declarations and run event loop to work around
  a memory leak that would otherwise present in `ax_event_handler_new`.

Change-Id: Iaa8aeb67150c777e0bdc72cf5e2fa148035e93c8
  • Loading branch information
apljungquist committed Dec 16, 2024
1 parent 8b00c7d commit ec5fbe0
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
5 changes: 4 additions & 1 deletion apps/send_event/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,8 +163,11 @@ mod tests {
#[test]
fn can_declare_without_callback() {
let handler = Handler::new();
handler
let declaration = handler
.declare::<fn(axevent::flex::Declaration)>(&topic().unwrap(), true, None)
.unwrap();
handler.undeclare(&declaration).unwrap();
let main_context = glib::MainContext::default();
while main_context.iteration(false) {}
}
}
3 changes: 1 addition & 2 deletions crates/axevent/src/flex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,7 @@ impl Handler {
self.declaration_callbacks
.lock()
.unwrap()
.remove(declaration)
.unwrap();
.remove(declaration);
}
result
}
Expand Down

0 comments on commit ec5fbe0

Please sign in to comment.