mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-15 15:35:52 +08:00
notification manager fix n°4
fix an infinite loop when long word.
This commit is contained in:
parent
0206f41389
commit
16e2db0cd6
@ -420,22 +420,23 @@ void NotificationManager::PopNotification::init()
|
|||||||
next_space = next_space_candidate;
|
next_space = next_space_candidate;
|
||||||
next_space_candidate = text.find_first_of(' ', next_space + 1);
|
next_space_candidate = text.find_first_of(' ', next_space + 1);
|
||||||
}
|
}
|
||||||
// when one word longer than line.
|
} else {
|
||||||
if (ImGui::CalcTextSize(text.substr(last_end, next_space - last_end).c_str()).x > m_window_width - m_window_width_offset) {
|
next_space = text.length();
|
||||||
float width_of_a = ImGui::CalcTextSize("a").x;
|
|
||||||
int letter_count = (int)((m_window_width - m_window_width_offset) / width_of_a);
|
|
||||||
while (last_end + letter_count < text.size() && ImGui::CalcTextSize(text.substr(last_end, letter_count).c_str()).x < m_window_width - m_window_width_offset) {
|
|
||||||
letter_count++;
|
|
||||||
}
|
|
||||||
m_endlines.push_back(last_end + letter_count);
|
|
||||||
last_end += letter_count;
|
|
||||||
} else {
|
|
||||||
m_endlines.push_back(next_space);
|
|
||||||
last_end = next_space + 1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
// when one word longer than line.
|
||||||
else {
|
if (ImGui::CalcTextSize(text.substr(last_end, next_space - last_end).c_str()).x > m_window_width - m_window_width_offset) {
|
||||||
|
float width_of_a = ImGui::CalcTextSize("a").x;
|
||||||
|
int letter_count = (int)((m_window_width - m_window_width_offset) / width_of_a);
|
||||||
|
while (last_end + letter_count < text.size() && ImGui::CalcTextSize(text.substr(last_end, letter_count).c_str()).x < m_window_width - m_window_width_offset) {
|
||||||
|
letter_count++;
|
||||||
|
}
|
||||||
|
m_endlines.push_back(last_end + letter_count);
|
||||||
|
last_end += letter_count;
|
||||||
|
} else {
|
||||||
|
m_endlines.push_back(next_space);
|
||||||
|
last_end = next_space + 1;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
m_endlines.push_back(text.length());
|
m_endlines.push_back(text.length());
|
||||||
last_end = text.length();
|
last_end = text.length();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user