| 10917 | } |
| 10918 | |
| 10919 | static void ImGui::ErrorCheckNewFrameSanityChecks() |
| 10920 | { |
| 10921 | ImGuiContext& g = *GImGui; |
| 10922 | |
| 10923 | // Check user IM_ASSERT macro |
| 10924 | // (IF YOU GET A WARNING OR COMPILE ERROR HERE: it means your assert macro is incorrectly defined! |
| 10925 | // If your macro uses multiple statements, it NEEDS to be surrounded by a 'do { ... } while (0)' block. |
| 10926 | // This is a common C/C++ idiom to allow multiple statements macros to be used in control flow blocks.) |
| 10927 | // #define IM_ASSERT(EXPR) if (SomeCode(EXPR)) SomeMoreCode(); // Wrong! |
| 10928 | // #define IM_ASSERT(EXPR) do { if (SomeCode(EXPR)) SomeMoreCode(); } while (0) // Correct! |
| 10929 | if (true) IM_ASSERT(1); else IM_ASSERT(0); |
| 10930 | |
| 10931 | // Emscripten backends are often imprecise in their submission of DeltaTime. (#6114, #3644) |
| 10932 | // Ideally the Emscripten app/backend should aim to fix or smooth this value and avoid feeding zero, but we tolerate it. |
| 10933 | #ifdef __EMSCRIPTEN__ |
| 10934 | if (g.IO.DeltaTime <= 0.0f && g.FrameCount > 0) |
| 10935 | g.IO.DeltaTime = 0.00001f; |
| 10936 | #endif |
| 10937 | |
| 10938 | // Check user data |
| 10939 | // (We pass an error message in the assert expression to make it visible to programmers who are not using a debugger, as most assert handlers display their argument) |
| 10940 | IM_ASSERT(g.Initialized); |
| 10941 | IM_ASSERT((g.IO.DeltaTime > 0.0f || g.FrameCount == 0) && "Need a positive DeltaTime!"); |
| 10942 | IM_ASSERT((g.FrameCount == 0 || g.FrameCountEnded == g.FrameCount) && "Forgot to call Render() or EndFrame() at the end of the previous frame?"); |
| 10943 | IM_ASSERT(g.IO.DisplaySize.x >= 0.0f && g.IO.DisplaySize.y >= 0.0f && "Invalid DisplaySize value!"); |
| 10944 | IM_ASSERT(g.Style.CurveTessellationTol > 0.0f && "Invalid style setting!"); |
| 10945 | IM_ASSERT(g.Style.CircleTessellationMaxError > 0.0f && "Invalid style setting!"); |
| 10946 | IM_ASSERT(g.Style.Alpha >= 0.0f && g.Style.Alpha <= 1.0f && "Invalid style setting!"); // Allows us to avoid a few clamps in color computations |
| 10947 | IM_ASSERT(g.Style.WindowMinSize.x >= 1.0f && g.Style.WindowMinSize.y >= 1.0f && "Invalid style setting!"); |
| 10948 | IM_ASSERT(g.Style.WindowBorderHoverPadding > 0.0f && "Invalid style setting!"); // Required otherwise cannot resize from borders. |
| 10949 | IM_ASSERT(g.Style.WindowMenuButtonPosition == ImGuiDir_None || g.Style.WindowMenuButtonPosition == ImGuiDir_Left || g.Style.WindowMenuButtonPosition == ImGuiDir_Right); |
| 10950 | IM_ASSERT(g.Style.ColorButtonPosition == ImGuiDir_Left || g.Style.ColorButtonPosition == ImGuiDir_Right); |
| 10951 | IM_ASSERT(g.Style.TreeLinesFlags == ImGuiTreeNodeFlags_DrawLinesNone || g.Style.TreeLinesFlags == ImGuiTreeNodeFlags_DrawLinesFull || g.Style.TreeLinesFlags == ImGuiTreeNodeFlags_DrawLinesToNodes); |
| 10952 | |
| 10953 | // Error handling: we do not accept 100% silent recovery! Please contact me if you feel this is getting in your way. |
| 10954 | if (g.IO.ConfigErrorRecovery) |
| 10955 | IM_ASSERT(g.IO.ConfigErrorRecoveryEnableAssert || g.IO.ConfigErrorRecoveryEnableDebugLog || g.IO.ConfigErrorRecoveryEnableTooltip || g.ErrorCallback != NULL); |
| 10956 | |
| 10957 | #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS |
| 10958 | if (g.IO.FontGlobalScale > 1.0f) |
| 10959 | IM_ASSERT(g.Style.FontScaleMain == 1.0f && "Since 1.92: use style.FontScaleMain instead of g.IO.FontGlobalScale!"); |
| 10960 | |
| 10961 | // Remap legacy names |
| 10962 | if (g.IO.ConfigFlags & ImGuiConfigFlags_NavEnableSetMousePos) |
| 10963 | { |
| 10964 | g.IO.ConfigNavMoveSetMousePos = true; |
| 10965 | g.IO.ConfigFlags &= ~ImGuiConfigFlags_NavEnableSetMousePos; |
| 10966 | } |
| 10967 | if (g.IO.ConfigFlags & ImGuiConfigFlags_NavNoCaptureKeyboard) |
| 10968 | { |
| 10969 | g.IO.ConfigNavCaptureKeyboard = false; |
| 10970 | g.IO.ConfigFlags &= ~ImGuiConfigFlags_NavNoCaptureKeyboard; |
| 10971 | } |
| 10972 | |
| 10973 | // Remap legacy clipboard handlers (OBSOLETED in 1.91.1, August 2024) |
| 10974 | if (g.IO.GetClipboardTextFn != NULL && (g.PlatformIO.Platform_GetClipboardTextFn == NULL || g.PlatformIO.Platform_GetClipboardTextFn == Platform_GetClipboardTextFn_DefaultImpl)) |
| 10975 | g.PlatformIO.Platform_GetClipboardTextFn = [](ImGuiContext* ctx) { return ctx->IO.GetClipboardTextFn(ctx->IO.ClipboardUserData); }; |
| 10976 | if (g.IO.SetClipboardTextFn != NULL && (g.PlatformIO.Platform_SetClipboardTextFn == NULL || g.PlatformIO.Platform_SetClipboardTextFn == Platform_SetClipboardTextFn_DefaultImpl)) |
nothing calls this directly
no outgoing calls
no test coverage detected