Skip to content

Commit

Permalink
Remove debug callbacks during context drop
Browse files Browse the repository at this point in the history
  • Loading branch information
grovesNL committed Jan 22, 2024
1 parent e94890f commit 8e67e95
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/native.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3268,6 +3268,25 @@ impl HasContext for Context {
}
}

impl Drop for Context {
fn drop(&mut self) {
if let Some(_) = self.debug_callback.take() {
} else {
return;
}

// Unset the debug callback before destroying the context.
unsafe {
let gl = &self.raw;
if gl.DebugMessageCallback_is_loaded() {
gl.DebugMessageCallback(None, std::ptr::null());
} else {
gl.DebugMessageCallbackKHR(None, std::ptr::null());
}
}
}
}

extern "system" fn raw_debug_message_callback(
source: u32,
gltype: u32,
Expand Down

0 comments on commit 8e67e95

Please sign in to comment.