qt: do not create platform window in `WinId()` in mainctx_win32.cpp
Previously the window handle was retrieved through private platform interface. It was recently changed to use `QWindow::winId()` instead, as it is public and more convenient to use. However, `QWindow::winId()` creates the platform window if it does not exist. This is normally not a problem, but since `WinId()` is may be called within the native event handler, it is a problem. I did not realize that `WinId()` was called at inappropriate times (either during destruction of the platform window when the window is destroyed, or after that as we don't want to re-create the platform window when closing the interface), that's why I did not pay attention on having a check here. Now that the problem is obvious, we should fix this mistake made in 7e063c67. This is trivial to fix, we can simply check if the pointer returned by either `QWindow::handle()` or `QSurface::surfaceHandle()` is a null pointer, and return early if it is before calling `QWindow::winId()`. As a side note, I believe that having a const method named as `winId()` which mutates the window by creating platform window if it does not exist is a really bad idea. I really wonder why Qt behaves like that, especially considering there is already `QWindow::create()` that creates the platform window.
parent
c3e5f6c6
No related branches found
No related tags found
Please register or sign in to comment