Set os::Window user data to nullptr before setting mouse cursors

In this way we don't process any queued native message for the display
as it will be deleted. This could be a possible fix for some crashes
reported in set_native_cursor_on_all_displays() (#2907)
This commit is contained in:
David Capello 2022-01-11 11:43:05 -03:00
parent 0f04e016b6
commit 07cf70361b

View File

@ -1503,6 +1503,11 @@ void Manager::_closeWindow(Window* window, bool redraw_background)
window->setBounds(newBounds);
}
// Set the native window user data to nullptr so any other queued
// native message is not processed.
window->setDisplay(nullptr, false);
windowDisplay->nativeWindow()->setUserData<void*>(nullptr);
// Remove all messages for this display.
removeMessagesForDisplay(windowDisplay);
@ -1510,9 +1515,6 @@ void Manager::_closeWindow(Window* window, bool redraw_background)
// delete.
_internal_set_mouse_display(parentDisplay);
window->setDisplay(nullptr, false);
windowDisplay->nativeWindow()->setUserData<void*>(nullptr);
// The ui::Display should destroy the os::Window
delete windowDisplay;