Rémi Bernon (@rbernon) commented about dlls/win32u/opengl.c:
{ NtCurrentTeb()->glContext = context;
- if (old_draw && old_draw != new_draw && old_draw != new_read && old_draw->client) - set_window_opengl_drawable( old_draw->client->hwnd, old_draw, FALSE ); - if (old_read && old_read != new_draw && old_read != new_read && old_read->client) - set_window_opengl_drawable( old_read->client->hwnd, old_read, FALSE ); + if (old_draw && old_draw != new_draw && old_draw != new_read && old_draw->client && new_draw && new_draw->client) + set_window_opengl_drawable( old_draw->client->hwnd, new_draw, FALSE ); + if (old_read && old_read != new_draw && old_read != new_read && old_read->client && new_read && new_read->client) + set_window_opengl_drawable( old_read->client->hwnd, new_read, FALSE );
`set_window_opengl_drawable( ..., FALSE )` sets the window "unused drawable", which was there to keep for future reuse and avoid frequent drawable deallocation / reallocation. It's wrong to register the newly created and used drawable as unused, as it may then be reused by another thread which will try to make it current there too. This was mostly meant for D3D drawables as they often get switched back and forth but now that we use owned drawable per swapchain DC drawables it's probably not as necessary as it was and we could get rid of it. -- https://gitlab.winehq.org/wine/wine/-/merge_requests/10190#note_130596