-
-
Notifications
You must be signed in to change notification settings - Fork 10.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
nullptr backend ptr after resources clean #8239
Comments
Could you share the callstack at the crashing site? |
You can right click to load symbols for standard DLL and have better callstack I assume. |
Did you call |
Yes of course. 2024-12-18-14-32-53.mp4 |
Can you also step in ImGuiViewport* main_viewport = ImGui::GetMainViewport();
::SetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)bd->PrevWndProc);
bd->PrevWndProc = nullptr; Check that all values are correct, does the HWND value match the one you see at the crash site? |
It doesn't seem to be referring to the same HWND. See PlatformHandleRaw value in Shutdown call vs your HWND value. I could easily silently return when bd==null but I would only do that if proven that it is absolutely required, as that sort of silent return tends to be hiding errors. |
I see... |
You can see what ImGui_ImplGlfw_Init() and ImGui_ImplGlfw_Shutdown() are doing: ImGui_ImplGlfw_Init saves old WndProc value, set ours. // Windows: register a WndProc hook so we can intercept some messages.
#ifdef _WIN32
bd->PrevWndProc = (WNDPROC)::GetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC);
IM_ASSERT(bd->PrevWndProc != nullptr);
::SetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)ImGui_ImplGlfw_WndProc);
#endif ImGui_ImplGlfw_Shutdown restores: ImGuiViewport* main_viewport = ImGui::GetMainViewport();
::SetWindowLongPtrW((HWND)main_viewport->PlatformHandleRaw, GWLP_WNDPROC, (LONG_PTR)bd->PrevWndProc);
bd->PrevWndProc = nullptr; It's normally restoring the WndProc which was installed before so we don't expect ImGui_ImplGlfw_WndProc to be called again after this call. Knowing that you can use a debugger and try to find out what's going wrong. |
Version/Branch of Dear ImGui:
Version 1.91.6 Branch: Docking
Back-ends:
imgui_impl_glfw.cpp + imgui_impl_vulkan.cpp
Compiler, OS:
Windows 11 + MSVC 2022, Ubuntu 22.04 + g++ 11
Full config/build information:
Windows: Compiler line: cl /nologo /EHsc /Zi /Od /W4 /WX /MTd /std:c++20 /c /I....\include /I....\deps\include /IC:\VulkanSDK\1.3.283.0\Include /IC:\OpenAL_1.1_SDK\include /DDEBUG /D_DEBUG /D_REENTRANT /D_THREAD_SAFE file.cpp /Fo: obj_folder/file.obj
Linux:
g++ -fdiagnostics-color=always -g3 -O0 -Wall -Wextra -Werror -Wpedantic -Wconversion -std::c++20 -Bstatic -m64 -c ./file_path/file_name.cpp -o ./obj/file_name.o -I../../include -I../../deps/include -DDEBUG -D_DEBUG -D_THREAD_SAFE -D_REENTRANT
Details:
I have multiple imgui contexts to have multiple windows, but when i close one window (Freeing all resources: imgui, glfw, vulkan)
The function make break trying to acces in a nullptr (Because the resources was freed)
This only happens in windows, when i compile the exact same code in linux this doesn't happen.
Screenshots/Video:
2024-12-18-10-21-56.mp4
Minimal, Complete and Verifiable Example code:
The text was updated successfully, but these errors were encountered: