From 8fc620375c1566d8b0c6becd4f6ed770c276d967 Mon Sep 17 00:00:00 2001 From: YuSanka Date: Tue, 30 Nov 2021 12:32:28 +0100 Subject: [PATCH] Fix for #7384 - From/To UTF8 conversation issue for text controls in Settings Tabs + BitmapComboBox: fixed warning under MSW --- src/slic3r/GUI/BitmapComboBox.cpp | 7 ++++++- src/slic3r/GUI/Field.cpp | 8 ++++---- src/slic3r/GUI/OptionsGroup.cpp | 4 ++-- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/slic3r/GUI/BitmapComboBox.cpp b/src/slic3r/GUI/BitmapComboBox.cpp index fcbc4b66623..24bc8dcfd20 100644 --- a/src/slic3r/GUI/BitmapComboBox.cpp +++ b/src/slic3r/GUI/BitmapComboBox.cpp @@ -167,7 +167,12 @@ int BitmapComboBox::Append(const wxString& item) //3. Set this empty bitmap to the at list one item and BitmapCombobox will be recreated correct wxBitmap bitmap(1, int(1.6 * wxGetApp().em_unit() + 1)); - bitmap.SetWidth(0); + { + // bitmap.SetWidth(0); is depricated now + // so, use next code + bitmap.UnShare();// AllocExclusive(); + bitmap.GetGDIImageData()->m_width = 0; + } OnAddBitmap(bitmap); const int n = wxComboBox::Append(item); diff --git a/src/slic3r/GUI/Field.cpp b/src/slic3r/GUI/Field.cpp index f7ed84238ba..67f78d26ed1 100644 --- a/src/slic3r/GUI/Field.cpp +++ b/src/slic3r/GUI/Field.cpp @@ -316,7 +316,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true } else if (((m_opt.sidetext.rfind("mm/s") != std::string::npos && val > m_opt.max) || (m_opt.sidetext.rfind("mm ") != std::string::npos && val > /*1*/m_opt.max_literal)) && - (m_value.empty() || std::string(str.ToUTF8().data()) != boost::any_cast(m_value))) + (m_value.empty() || into_u8(str) != boost::any_cast(m_value))) { if (!check_value) { m_value.clear(); @@ -340,7 +340,7 @@ void Field::get_value_by_opt_type(wxString& str, const bool check_value/* = true } } - m_value = std::string(str.ToUTF8().data()); + m_value = into_u8(str); break; } case coPoints: { @@ -1286,7 +1286,7 @@ void Choice::msw_rescale() size_t counter = 0; bool labels = ! m_opt.enum_labels.empty(); for (const std::string &el : labels ? m_opt.enum_labels : m_opt.enum_values) { - wxString text = labels ? _(el) : wxString::FromUTF8(el.c_str()); + wxString text = labels ? _(el) : from_u8(el); field->Append(text); if (text == selection) idx = counter; @@ -1574,7 +1574,7 @@ void StaticText::BUILD() if (m_opt.height >= 0) size.SetHeight(m_opt.height*m_em_unit); if (m_opt.width >= 0) size.SetWidth(m_opt.width*m_em_unit); - const wxString legend = wxString::FromUTF8(m_opt.get_default_value()->value.c_str()); + const wxString legend = from_u8(m_opt.get_default_value()->value); auto temp = new wxStaticText(m_parent, wxID_ANY, legend, wxDefaultPosition, size, wxST_ELLIPSIZE_MIDDLE); temp->SetFont(Slic3r::GUI::wxGetApp().normal_font()); temp->SetBackgroundStyle(wxBG_STYLE_PAINT); diff --git a/src/slic3r/GUI/OptionsGroup.cpp b/src/slic3r/GUI/OptionsGroup.cpp index 2e0d8384de1..c4c123a484d 100644 --- a/src/slic3r/GUI/OptionsGroup.cpp +++ b/src/slic3r/GUI/OptionsGroup.cpp @@ -870,7 +870,7 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config } break; case coString: - ret = static_cast(config.opt_string(opt_key)); + ret = from_u8(config.opt_string(opt_key)); break; case coStrings: if (opt_key == "compatible_printers" || opt_key == "compatible_prints") { @@ -891,7 +891,7 @@ boost::any ConfigOptionsGroup::get_config_value(const DynamicPrintConfig& config ret = text_value; } else - ret = static_cast(config.opt_string(opt_key, static_cast(idx))); + ret = from_u8(config.opt_string(opt_key, static_cast(idx))); break; case coBool: ret = config.opt_bool(opt_key);