Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/prusa3d/PrusaSlicer.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVojtech Bubnik <bubnikv@gmail.com>2022-01-31 13:08:55 +0300
committerVojtech Bubnik <bubnikv@gmail.com>2022-01-31 13:09:13 +0300
commite3ef90941f0ddcc18f604b6c528aa5ea602bbc4a (patch)
treea6392848e6cefd1913ed8d1df41ee27a4d2c4d5c
parent1a57db092f57cd72280fa0cfecf890fbfea1633f (diff)
Hopefully fixed get_wraped_wxString() and did not introduce new bugs.
-rw-r--r--src/slic3r/GUI/MsgDialog.cpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/src/slic3r/GUI/MsgDialog.cpp b/src/slic3r/GUI/MsgDialog.cpp
index 79ff4214a..368bc8618 100644
--- a/src/slic3r/GUI/MsgDialog.cpp
+++ b/src/slic3r/GUI/MsgDialog.cpp
@@ -294,37 +294,38 @@ InfoDialog::InfoDialog(wxWindow* parent, const wxString &title, const wxString&
wxString get_wraped_wxString(const wxString& text_in, size_t line_len /*=80*/)
{
#ifdef __WXMSW__
- char slash = '\\';
+ static constexpr const char slash = '\\';
#else
- char slash = '/';
+ static constexpr const char slash = '/';
#endif
- char space = ' ';
- char new_line = '\n';
+ static constexpr const char space = ' ';
+ static constexpr const char new_line = '\n';
wxString text = text_in;
int idx = -1;
size_t cur_len = 0;
- size_t text_len = text.Len();
+ size_t text_len = text.size();
- for (size_t i = 0; i < text_len; i++) {
- cur_len++;
- if (text[i] == space || text[i] == slash)
- idx = i;
+ for (size_t i = 0; i < text_len; ++ i) {
if (text[i] == new_line) {
idx = -1;
cur_len = 0;
- continue;
- }
- if (cur_len >= line_len && idx >= 0) {
- if (text[idx] == slash) {
- text.insert(static_cast<size_t>(idx) + 1, 1, new_line);
- idx++;
- text_len++;
+ } else {
+ ++ cur_len;
+ if (text[i] == space || text[i] == slash)
+ idx = i;
+ if (cur_len >= line_len && idx >= 0) {
+ if (text[idx] == slash) {
+ text.insert(static_cast<size_t>(++ idx), 1, new_line);
+ ++ text_len;
+ ++ i;
+ }
+ else // space
+ text[idx] = new_line;
+ cur_len = i - static_cast<size_t>(idx);
+ idx = -1;
}
- else // space
- text[idx] = new_line;
- cur_len = i - static_cast<size_t>(idx);
}
}
return text;