diff options
| author | Andre Weissflog <floooh@gmail.com> | 2025-08-30 13:33:14 +0200 |
|---|---|---|
| committer | Andre Weissflog <floooh@gmail.com> | 2025-08-30 13:33:14 +0200 |
| commit | dc95ec1f75c705754feb4ef708c417e4319088e0 (patch) | |
| tree | ae80935dc874ebbe0cb9507a1c57e8f9bb2f8107 | |
| parent | 96e3fe6a5b05dc8b6e5baf7dc56b7bf104c69dc2 (diff) | |
sokol_app.h win32: simplify the unbind custom cursor before destroy from last commit
| -rw-r--r-- | sokol_app.h | 24 |
1 files changed, 10 insertions, 14 deletions
diff --git a/sokol_app.h b/sokol_app.h index 3158eb12..272c32cc 100644 --- a/sokol_app.h +++ b/sokol_app.h @@ -12403,27 +12403,23 @@ SOKOL_APP_API_DECL void sapp_unbind_mouse_cursor_image(sapp_mouse_cursor cursor) SOKOL_ASSERT((cursor >= 0) && (cursor < _SAPP_MOUSECURSOR_NUM)); uint64_t* slot = &_sapp.custom_mouse_cursors[(int) cursor]; if (*slot) { - // at least on win32 attempting to destroy a cursor that's currently - // active is an error, so when trying to destroy the active cursor - // first make the cursor invisible which 'breaks' the dependency - const bool shown = _sapp.mouse.shown; + uint64_t platform_cursor_handle = *slot; + // if this is the active cursor, first restore it to its default image, + // this must be done before attempting to destroy any cursor image + // resources which at least on win32 would fail if the cursor is still in use + *slot = 0; if (_sapp.mouse.current_cursor == cursor) { - _sapp_update_cursor(cursor, false); + _sapp_update_cursor(cursor, _sapp.mouse.shown); } #if defined(_SAPP_MACOS) - _sapp_macos_destroy_custom_mouse_cursor(*slot); + _sapp_macos_destroy_custom_mouse_cursor(platform_cursor_handle); #elif defined(_SAPP_EMSCRIPTEN) - _sapp_emsc_destroy_custom_mouse_cursor(cursor); + _sapp_emsc_destroy_custom_mouse_cursor(platform_cursor_handle); #elif defined(_SAPP_WIN32) - _sapp_win32_destroy_custom_mouse_cursor(*slot); + _sapp_win32_destroy_custom_mouse_cursor(platform_cursor_handle); #elif defined(_SAPP_LINUX) - _sapp_x11_destroy_custom_mouse_cursor(*slot); + _sapp_x11_destroy_custom_mouse_cursor(platform_cursor_handle); #endif - *slot = 0; - // update the displayed cursor in case the current cursor is the one we just unbound - if (_sapp.mouse.current_cursor == cursor) { - _sapp_update_cursor(cursor, shown); - } } } |