fix crash when closing platform popups

This commit is contained in:
2026-03-05 19:07:26 -05:00
parent a0875fd1ff
commit b11402f842
3 changed files with 12 additions and 5 deletions

View File

@@ -1919,12 +1919,16 @@ static void do_frame(AppState *app) {
}
ui_widgets_begin_frame(input);
if (app->master_layout == 0) ui_piano_update_input(&app->piano_state);
update_panel_splitters(app);
// Build UI with Clay
ui_begin_frame(app->ui, (F32)w, (F32)h, input.mouse_pos, input.mouse_down,
input.scroll_delta, dt);
// These query previous frame's Clay layout data (Clay_GetElementData,
// Clay_PointerOver) so they must run after ui_begin_frame sets the context.
if (app->master_layout == 0) ui_piano_update_input(&app->piano_state);
update_panel_splitters(app);
build_ui(app);
Clay_RenderCommandArray render_commands = ui_end_frame(app->ui);
@@ -2078,6 +2082,7 @@ int main(int argc, char **argv) {
}
popup_close_all();
platform_set_frame_callback(window, nullptr, nullptr);
audio_destroy(audio);
midi_destroy(midi);
ui_destroy(ui);

View File

@@ -86,7 +86,8 @@ static LRESULT CALLBACK win32_wndproc(HWND hwnd, UINT msg, WPARAM wparam, LPARAM
pw->should_close = true;
return 0;
case WM_DESTROY:
PostQuitMessage(0);
if (pw == g_main_window)
PostQuitMessage(0);
return 0;
case WM_SYSCOMMAND:
if ((wparam & 0xfff0) == SC_KEYMENU)

View File

@@ -80,11 +80,12 @@ void popup_close(PopupWindow *popup) {
if (popup->open_flag)
*popup->open_flag = 0;
popup->alive = 0;
platform_set_frame_callback(popup->platform_window, nullptr, nullptr);
ui_destroy(popup->ui_ctx);
renderer_destroy(popup->renderer);
platform_destroy_window(popup->platform_window);
popup->alive = 0;
}
void popup_do_frame(PopupWindow *popup, F32 dt) {