mirror of
				https://github.com/SoftFever/OrcaSlicer.git
				synced 2025-11-02 20:51:23 -07:00 
			
		
		
		
	Replaced all wxString.ToStdString() with wxString.ToUTF8().data()
to be sure that the strings are correctly converted to UTF8.
This commit is contained in:
		
							parent
							
								
									b099d5c05e
								
							
						
					
					
						commit
						8d1b854acb
					
				
					 11 changed files with 23 additions and 24 deletions
				
			
		| 
						 | 
				
			
			@ -404,7 +404,7 @@ void ConfigBase::load_from_gcode_file(const std::string &file)
 | 
			
		|||
 | 
			
		||||
    size_t key_value_pairs = load_from_gcode_string(data.data());
 | 
			
		||||
    if (key_value_pairs < 80)
 | 
			
		||||
        throw std::runtime_error((boost::format("Suspiciously low number of configuration values extracted from %1: %2") % file % key_value_pairs).str());
 | 
			
		||||
        throw std::runtime_error((boost::format("Suspiciously low number of configuration values extracted from %1%: %2%") % file % key_value_pairs).str());
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Load the config keys from the given string.
 | 
			
		||||
| 
						 | 
				
			
			@ -536,7 +536,7 @@ void DynamicConfig::read_cli(const std::vector<std::string> &tokens, t_config_op
 | 
			
		|||
    args.emplace_back(const_cast<char*>(""));
 | 
			
		||||
    for (size_t i = 0; i < tokens.size(); ++ i)
 | 
			
		||||
        args.emplace_back(const_cast<char *>(tokens[i].c_str()));
 | 
			
		||||
    this->read_cli(args.size(), &args[0], extra);
 | 
			
		||||
    this->read_cli(int(args.size()), &args[0], extra);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool DynamicConfig::read_cli(int argc, char** argv, t_config_option_keys* extra)
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -126,7 +126,7 @@ public:
 | 
			
		|||
    }
 | 
			
		||||
 | 
			
		||||
    inline std::string get_name() const {
 | 
			
		||||
        return fpath.GetName().ToStdString();
 | 
			
		||||
        return fpath.GetName().ToUTF8().data();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    template<class T> inline LayerWriter& operator<<(const T& arg) {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -305,7 +305,7 @@ void BedShapePanel::load_stl()
 | 
			
		|||
	dialog->GetPaths(input_file);
 | 
			
		||||
	dialog->Destroy();
 | 
			
		||||
 | 
			
		||||
	std::string file_name = input_file[0].ToStdString();
 | 
			
		||||
	std::string file_name = input_file[0].ToUTF8().data();
 | 
			
		||||
 | 
			
		||||
	Model model;
 | 
			
		||||
	try {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -72,8 +72,7 @@ PrinterPicker::PrinterPicker(wxWindow *parent, const VendorProfile &vendor, cons
 | 
			
		|||
	std::vector<wxPanel*> variants_panels;
 | 
			
		||||
 | 
			
		||||
	for (const auto &model : models) {
 | 
			
		||||
		auto bitmap_file = wxString::Format("printers/%s_%s.png", vendor.id, model.id);
 | 
			
		||||
		wxBitmap bitmap(GUI::from_u8(Slic3r::var(bitmap_file.ToStdString())), wxBITMAP_TYPE_PNG);
 | 
			
		||||
		wxBitmap bitmap(GUI::from_u8(Slic3r::var((boost::format("printers/%1%_%2%.png") % vendor.id % model.id).str())), wxBITMAP_TYPE_PNG);
 | 
			
		||||
 | 
			
		||||
		auto *title = new wxStaticText(this, wxID_ANY, model.name, wxDefaultPosition, wxDefaultSize, wxALIGN_LEFT);
 | 
			
		||||
		title->SetFont(namefont);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -188,7 +188,7 @@ void Field::get_value_by_opt_type(wxString& str)
 | 
			
		|||
            }
 | 
			
		||||
        }
 | 
			
		||||
    
 | 
			
		||||
        m_value = str.ToStdString();
 | 
			
		||||
        m_value = str.ToUTF8().data();
 | 
			
		||||
		break; }
 | 
			
		||||
	default:
 | 
			
		||||
		break;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -509,7 +509,7 @@ void GUI_App::save_language()
 | 
			
		|||
    if (m_wxLocale)
 | 
			
		||||
        language = m_wxLocale->GetCanonicalName();
 | 
			
		||||
 | 
			
		||||
    app_config->set("translation_language", language.ToStdString());
 | 
			
		||||
    app_config->set("translation_language", language.ToUTF8().data());
 | 
			
		||||
    app_config->save();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -298,13 +298,13 @@ void ObjectList::update_name_in_model(const wxDataViewItem& item)
 | 
			
		|||
    if (obj_idx < 0) return;
 | 
			
		||||
 | 
			
		||||
    if (m_objects_model->GetParent(item) == wxDataViewItem(0)) {
 | 
			
		||||
        (*m_objects)[obj_idx]->name = m_objects_model->GetName(item).ToStdString();
 | 
			
		||||
        (*m_objects)[obj_idx]->name = m_objects_model->GetName(item).ToUTF8().data();
 | 
			
		||||
        return;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    const int volume_id = m_objects_model->GetVolumeIdByItem(item);
 | 
			
		||||
    if (volume_id < 0) return;
 | 
			
		||||
    (*m_objects)[obj_idx]->volumes[volume_id]->name = m_objects_model->GetName(item).ToStdString();
 | 
			
		||||
    (*m_objects)[obj_idx]->volumes[volume_id]->name = m_objects_model->GetName(item).ToUTF8().data();
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ObjectList::init_icons()
 | 
			
		||||
| 
						 | 
				
			
			@ -657,7 +657,7 @@ void ObjectList::append_menu_item_add_generic(wxMenuItem* menu, const int type)
 | 
			
		|||
    std::vector<std::string> menu_items = { L("Box"), L("Cylinder"), L("Sphere"), L("Slab") };
 | 
			
		||||
    for (auto& item : menu_items) {
 | 
			
		||||
        append_menu_item(sub_menu, wxID_ANY, _(item), "",
 | 
			
		||||
            [this, type, item](wxCommandEvent&) { load_generic_subobject(_(item).ToStdString(), type); }, "", menu->GetMenu());
 | 
			
		||||
            [this, type, item](wxCommandEvent&) { load_generic_subobject(_(item).ToUTF8().data(), type); }, "", menu->GetMenu());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    menu->SetSubMenu(sub_menu);
 | 
			
		||||
| 
						 | 
				
			
			@ -683,10 +683,10 @@ void ObjectList::append_menu_items_add_volume(wxMenu* menu)
 | 
			
		|||
        append_menu_item(menu, wxID_ANY, _(L("Add part")), "",
 | 
			
		||||
            [this](wxCommandEvent&) { load_subobject(ModelVolume::MODEL_PART); }, *m_bmp_vector[ModelVolume::MODEL_PART]);
 | 
			
		||||
        append_menu_item(menu, wxID_ANY, _(L("Add support enforcer")), "",
 | 
			
		||||
            [this](wxCommandEvent&) { load_generic_subobject(_(L("Box")).ToStdString(), ModelVolume::SUPPORT_ENFORCER); }, 
 | 
			
		||||
            [this](wxCommandEvent&) { load_generic_subobject(_(L("Box")).ToUTF8().data(), ModelVolume::SUPPORT_ENFORCER); }, 
 | 
			
		||||
            *m_bmp_vector[ModelVolume::SUPPORT_ENFORCER]);
 | 
			
		||||
        append_menu_item(menu, wxID_ANY, _(L("Add support blocker")), "",
 | 
			
		||||
            [this](wxCommandEvent&) { load_generic_subobject(_(L("Box")).ToStdString(), ModelVolume::SUPPORT_BLOCKER); }, 
 | 
			
		||||
            [this](wxCommandEvent&) { load_generic_subobject(_(L("Box")).ToUTF8().data(), ModelVolume::SUPPORT_BLOCKER); }, 
 | 
			
		||||
            *m_bmp_vector[ModelVolume::SUPPORT_BLOCKER]);
 | 
			
		||||
 | 
			
		||||
        return;
 | 
			
		||||
| 
						 | 
				
			
			@ -823,7 +823,7 @@ void ObjectList::load_part( ModelObject* model_object,
 | 
			
		|||
    wxArrayString input_files;
 | 
			
		||||
    wxGetApp().import_model(parent, input_files);
 | 
			
		||||
    for (int i = 0; i < input_files.size(); ++i) {
 | 
			
		||||
        std::string input_file = input_files.Item(i).ToStdString();
 | 
			
		||||
        std::string input_file = input_files.Item(i).ToUTF8().data();
 | 
			
		||||
 | 
			
		||||
        Model model;
 | 
			
		||||
        try {
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -488,7 +488,7 @@ void MainFrame::quick_slice(const int qs)
 | 
			
		|||
//     });
 | 
			
		||||
 | 
			
		||||
    // keep model around
 | 
			
		||||
    auto model = Slic3r::Model::read_from_file(input_file.ToStdString());
 | 
			
		||||
    auto model = Slic3r::Model::read_from_file(input_file.ToUTF8().data());
 | 
			
		||||
 | 
			
		||||
//     sprint->apply_config(config);
 | 
			
		||||
//     sprint->set_model(model);
 | 
			
		||||
| 
						 | 
				
			
			@ -630,7 +630,7 @@ void MainFrame::export_config()
 | 
			
		|||
    if (!file.IsEmpty()) {
 | 
			
		||||
        wxGetApp().app_config->update_config_dir(get_dir_name(file));
 | 
			
		||||
        m_last_config = file;
 | 
			
		||||
        config.save(file.ToStdString());
 | 
			
		||||
        config.save(file.ToUTF8().data());
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -649,7 +649,7 @@ void MainFrame::load_config_file(wxString file/* = wxEmptyString*/)
 | 
			
		|||
        dlg->Destroy();
 | 
			
		||||
    }
 | 
			
		||||
    try {
 | 
			
		||||
        wxGetApp().preset_bundle->load_config_file(file.ToStdString()); 
 | 
			
		||||
        wxGetApp().preset_bundle->load_config_file(file.ToUTF8().data()); 
 | 
			
		||||
    } catch (const std::exception &ex) {
 | 
			
		||||
        show_error(this, ex.what());
 | 
			
		||||
        return;
 | 
			
		||||
| 
						 | 
				
			
			@ -682,7 +682,7 @@ void MainFrame::export_configbundle()
 | 
			
		|||
        // Export the config bundle.
 | 
			
		||||
        wxGetApp().app_config->update_config_dir(get_dir_name(file));
 | 
			
		||||
        try {
 | 
			
		||||
            wxGetApp().preset_bundle->export_configbundle(file.ToStdString()); 
 | 
			
		||||
            wxGetApp().preset_bundle->export_configbundle(file.ToUTF8().data()); 
 | 
			
		||||
        } catch (const std::exception &ex) {
 | 
			
		||||
			show_error(this, ex.what());
 | 
			
		||||
        }
 | 
			
		||||
| 
						 | 
				
			
			@ -710,7 +710,7 @@ void MainFrame::load_configbundle(wxString file/* = wxEmptyString, const bool re
 | 
			
		|||
 | 
			
		||||
    auto presets_imported = 0;
 | 
			
		||||
    try {
 | 
			
		||||
        presets_imported = wxGetApp().preset_bundle->load_configbundle(file.ToStdString());
 | 
			
		||||
        presets_imported = wxGetApp().preset_bundle->load_configbundle(file.ToUTF8().data());
 | 
			
		||||
    } catch (const std::exception &ex) {
 | 
			
		||||
        show_error(this, ex.what());
 | 
			
		||||
        return;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -2083,7 +2083,7 @@ void Plater::priv::on_select_preset(wxCommandEvent &evt)
 | 
			
		|||
    //! So, to get selected string we do 
 | 
			
		||||
    //!     combo->GetString(combo->GetSelection()) 
 | 
			
		||||
    //! instead of 
 | 
			
		||||
    //!     combo->GetStringSelection().ToStdString()); 
 | 
			
		||||
    //!     combo->GetStringSelection().ToUTF8().data()); 
 | 
			
		||||
 | 
			
		||||
    std::string selected_string = combo->GetString(combo->GetSelection()).ToUTF8().data();
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -209,7 +209,7 @@ void Tab::create_preset_tab()
 | 
			
		|||
	m_presets_choice->Bind(wxEVT_COMBOBOX, ([this](wxCommandEvent e) {
 | 
			
		||||
		//! Because of The MSW and GTK version of wxBitmapComboBox derived from wxComboBox, 
 | 
			
		||||
		//! but the OSX version derived from wxOwnerDrawnCombo, instead of:
 | 
			
		||||
		//! select_preset(m_presets_choice->GetStringSelection().ToStdString()); 
 | 
			
		||||
		//! select_preset(m_presets_choice->GetStringSelection().ToUTF8().data()); 
 | 
			
		||||
		//! we doing next:
 | 
			
		||||
		int selected_item = m_presets_choice->GetSelection();
 | 
			
		||||
		if (m_selected_preset_item == selected_item && !m_presets->current_is_dirty())
 | 
			
		||||
| 
						 | 
				
			
			@ -2804,7 +2804,7 @@ wxSizer* Tab::compatible_widget_create(wxWindow* parent, PresetDependencies &dep
 | 
			
		|||
			selections.Clear();
 | 
			
		||||
			selections = dlg.GetSelections();
 | 
			
		||||
			for (auto idx : selections)
 | 
			
		||||
				value.push_back(presets[idx].ToStdString());
 | 
			
		||||
				value.push_back(presets[idx].ToUTF8().data());
 | 
			
		||||
			if (value.empty()) {
 | 
			
		||||
				deps.checkbox->SetValue(1);
 | 
			
		||||
				deps.btn->Disable();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -422,13 +422,13 @@ bool PrusaObjectDataViewModelNode::update_settings_digest(const std::vector<std:
 | 
			
		|||
    if (!m_name.IsEmpty())
 | 
			
		||||
        m_name.erase(m_name.Length()-2, 2); // Delete last "; "
 | 
			
		||||
 | 
			
		||||
    wxBitmap *bmp = m_bitmap_cache->find(m_name.ToStdString());
 | 
			
		||||
    wxBitmap *bmp = m_bitmap_cache->find(m_name.ToUTF8().data());
 | 
			
		||||
    if (bmp == nullptr) {
 | 
			
		||||
        std::vector<wxBitmap> bmps;
 | 
			
		||||
        for (auto& cat : m_opt_categories)
 | 
			
		||||
            bmps.emplace_back(categories_icon.find(cat) == categories_icon.end() ?
 | 
			
		||||
                              wxNullBitmap : categories_icon.at(cat));
 | 
			
		||||
        bmp = m_bitmap_cache->insert(m_name.ToStdString(), bmps);
 | 
			
		||||
        bmp = m_bitmap_cache->insert(m_name.ToUTF8().data(), bmps);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    m_bmp = *bmp;
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue