mirror of
				https://github.com/ocornut/imgui.git
				synced 2025-10-26 12:27:30 +00:00 
			
		
		
		
	Backends: Win32: Removed silent return when calling ImGui_ImplWin32_WndProcHandler() with no active context! (#6275)
Better standardized similar checks in other backends.
This commit is contained in:
		| @@ -21,6 +21,7 @@ | ||||
|  | ||||
| // CHANGELOG | ||||
| // (minor and older changes stripped away, please see git history for details) | ||||
| //  2024-05-07: Removed silent return when calling ImGui_ImplWin32_WndProcHandler() with no active context! If you don't always have an active context, check that ImGui::GetCurrentContext() != nullptr before calling this. | ||||
| //  2023-10-05: Inputs: Added support for extra ImGuiKey values: F13 to F24 function keys, app back/forward keys. | ||||
| //  2023-09-25: Inputs: Synthesize key-down event on key-up for VK_SNAPSHOT / ImGuiKey_PrintScreen as Windows doesn't emit it (same behavior as GLFW/SDL). | ||||
| //  2023-09-07: Inputs: Added support for keyboard codepage conversion for when application is compiled in MBCS mode and using a non-Unicode window. | ||||
| @@ -382,9 +383,9 @@ static void ImGui_ImplWin32_UpdateGamepads() | ||||
|  | ||||
| void    ImGui_ImplWin32_NewFrame() | ||||
| { | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|     ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData(); | ||||
|     IM_ASSERT(bd != nullptr && "Did you call ImGui_ImplWin32_Init()?"); | ||||
|     IM_ASSERT(bd != nullptr && "Context or backend not initialized? Did you call ImGui_ImplWin32_Init()?"); | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|  | ||||
|     // Setup display size (every frame to accommodate for window resizing) | ||||
|     RECT rect = { 0, 0, 0, 0 }; | ||||
| @@ -580,11 +581,12 @@ static ImGuiMouseSource GetMouseSourceFromMessageExtraInfo() | ||||
|  | ||||
| IMGUI_IMPL_API LRESULT ImGui_ImplWin32_WndProcHandler(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | ||||
| { | ||||
|     if (ImGui::GetCurrentContext() == nullptr) | ||||
|         return 0; | ||||
|  | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|     // Before 2024-05-07 we were silently returning if ImGui::GetCurrentContext() == nullptr, | ||||
|     // which was inconsistent with other backends. Make sure you call this after initializing the imgui context, | ||||
|     // other add an 'if (ImGui::GetCurrentContext() != NULL)` check before calling ImGui_ImplWin32_WndProcHandler(). | ||||
|     ImGui_ImplWin32_Data* bd = ImGui_ImplWin32_GetBackendData(); | ||||
|     IM_ASSERT(bd != nullptr && "Context or backend not initialized! Did you call ImGui_ImplWin32_Init()?"); | ||||
|     ImGuiIO& io = ImGui::GetIO(); | ||||
|  | ||||
|     switch (msg) | ||||
|     { | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 ocornut
					ocornut