TextWrapped will cause too-many-vertices error for long single-line strings #7496

Closed
opened 2024-04-15 10:28:08 +00:00 by achabense · 0 comments
achabense commented 2024-04-15 10:28:08 +00:00 (Migrated from github.com)

Version/Branch of Dear ImGui:

Version 1.90.5

Back-ends:

imgui_impl_sdl2.cpp + imgui_impl_sdlrenderer2.cpp

Compiler, OS:

Windows 10 + MSVC 2022

Full config/build information:

No response

Details:

ImGui::TextWrapped and other text functions using wrap-pos settings will cause too-many-vertices error when displaying long single-line strings.
image
Background: I met this problem when trying to TextWrapped the lines getline-ed from files. I got the assertion failure after unexpectedly opening a large non-text file (which does not contain \n).
Similar issue: #5720

Screenshots/Video:

The effect for the first example below:
image

Minimal, Complete and Verifiable Example code:

ImGui::SetNextWindowSize(ImVec2(300, 50), ImGuiCond_Always);
if (ImGui::Begin("Failed")) {
    std::string long_single_line(20000, 'a');
    ImGui::TextWrapped("%s", long_single_line.c_str());
}
ImGui::End();

The problem is not limited to TextWrapped. It can affect every text function via wrap-pos settings:

ImGui::SetNextWindowSize(ImVec2(300, 50), ImGuiCond_Always);
if (ImGui::Begin("Failed")) {
    ImGui::PushTextWrapPos(200);
    std::string long_single_line(20000, 'a');
    ImGui::TextUnformatted(long_single_line.data(), long_single_line.data() + long_single_line.size());
    ImGui::PopTextWrapPos();
}
ImGui::End();
### Version/Branch of Dear ImGui: Version 1.90.5 ### Back-ends: imgui_impl_sdl2.cpp + imgui_impl_sdlrenderer2.cpp ### Compiler, OS: Windows 10 + MSVC 2022 ### Full config/build information: _No response_ ### Details: `ImGui::TextWrapped` and other text functions using wrap-pos settings will cause `too-many-vertices` error when displaying long `single-line` strings. ![image](https://github.com/ocornut/imgui/assets/60953653/6a315b57-eed3-40cd-be29-0471c7d29ae1) Background: I met this problem when trying to `TextWrapped` the lines `getline`-ed from files. I got the assertion failure after unexpectedly opening a large non-text file (which does not contain `\n`). Similar issue: #5720 ### Screenshots/Video: The effect for the first example below: ![image](https://github.com/ocornut/imgui/assets/60953653/83a015bc-0b72-491b-b696-e93e565307e5) ### Minimal, Complete and Verifiable Example code: ```cpp ImGui::SetNextWindowSize(ImVec2(300, 50), ImGuiCond_Always); if (ImGui::Begin("Failed")) { std::string long_single_line(20000, 'a'); ImGui::TextWrapped("%s", long_single_line.c_str()); } ImGui::End(); ``` The problem is not limited to `TextWrapped`. It can affect every text function via wrap-pos settings: ```cpp ImGui::SetNextWindowSize(ImVec2(300, 50), ImGuiCond_Always); if (ImGui::Begin("Failed")) { ImGui::PushTextWrapPos(200); std::string long_single_line(20000, 'a'); ImGui::TextUnformatted(long_single_line.data(), long_single_line.data() + long_single_line.size()); ImGui::PopTextWrapPos(); } ImGui::End(); ```
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
ocornut/imgui#7496
No description provided.