Deinit devmode more cleanly

This commit is contained in:
Mitchell Hashimoto
2022-11-06 17:26:01 -08:00
parent 135b859b8f
commit fd304c9338
4 changed files with 45 additions and 34 deletions

View File

@@ -393,6 +393,9 @@ pub fn create(alloc: Allocator, app: *App, config: *const Config) !*Window {
// Add our window to the instance if it isn't set.
DevMode.instance.window = self;
// Let our renderer setup
try renderer_impl.initDevMode(window);
}
// Give the renderer one more opportunity to finalize any window
@@ -427,18 +430,22 @@ pub fn destroy(self: *Window) void {
self.renderer.threadEnter(self.window) catch unreachable;
self.renderer_thread.deinit();
// If we are devmode-owning, clean that up.
if (DevMode.enabled and DevMode.instance.window == self) {
// Let our renderer clean up
self.renderer.deinitDevMode();
// Clear the window
DevMode.instance.window = null;
// Uninitialize imgui
self.imgui_ctx.destroy();
}
// Deinit our renderer
self.renderer.deinit();
}
if (DevMode.enabled and DevMode.instance.window == self) {
// Clear the window
DevMode.instance.window = null;
// Uninitialize imgui
self.imgui_ctx.destroy();
}
{
// Stop our IO thread
self.io_thread.stop.send() catch |err|