diff --git a/src/slic3r/GUI/GUI.cpp b/src/slic3r/GUI/GUI.cpp index c22fd6f792..45921b5304 100644 --- a/src/slic3r/GUI/GUI.cpp +++ b/src/slic3r/GUI/GUI.cpp @@ -229,10 +229,15 @@ void show_error(wxWindow* parent, const wxString& message) msg.ShowModal(); } +void show_error(wxWindow* parent, const char* message) +{ + show_error(parent, wxString::FromUTF8(message)); +} + void show_error_id(int id, const std::string& message) { auto *parent = id != 0 ? wxWindow::FindWindowById(id) : nullptr; - show_error(parent, from_u8(message)); + show_error(parent, message); } void show_info(wxWindow* parent, const wxString& message, const wxString& title) diff --git a/src/slic3r/GUI/GUI.hpp b/src/slic3r/GUI/GUI.hpp index 0b904bad86..b13e7c042e 100644 --- a/src/slic3r/GUI/GUI.hpp +++ b/src/slic3r/GUI/GUI.hpp @@ -39,6 +39,8 @@ extern void add_menus(wxMenuBar *menu, int event_preferences_changed, int event_ void change_opt_value(DynamicPrintConfig& config, const t_config_option_key& opt_key, const boost::any& value, int opt_index = 0); void show_error(wxWindow* parent, const wxString& message); +void show_error(wxWindow* parent, const char* message); +inline void show_error(wxWindow* parent, const std::string& message) { show_error(parent, message.c_str()); } void show_error_id(int id, const std::string& message); // For Perl void show_info(wxWindow* parent, const wxString& message, const wxString& title); void warning_catcher(wxWindow* parent, const wxString& message); diff --git a/src/slic3r/GUI/GUI_App.cpp b/src/slic3r/GUI/GUI_App.cpp index 2e01e3552b..ad76dc37fb 100644 --- a/src/slic3r/GUI/GUI_App.cpp +++ b/src/slic3r/GUI/GUI_App.cpp @@ -244,7 +244,7 @@ bool GUI_App::on_init_inner() try { preset_bundle->load_presets(*app_config); } catch (const std::exception &ex) { - show_error(nullptr, from_u8(ex.what())); + show_error(nullptr, ex.what()); } register_dpi_event(); @@ -1241,7 +1241,7 @@ void GUI_App::check_updates(const bool verbose) } } catch (const std::exception & ex) { - show_error(nullptr, from_u8(ex.what())); + show_error(nullptr, ex.what()); } diff --git a/src/slic3r/GUI/I18N.hpp b/src/slic3r/GUI/I18N.hpp index bf3103f771..8cf226a730 100644 --- a/src/slic3r/GUI/I18N.hpp +++ b/src/slic3r/GUI/I18N.hpp @@ -67,10 +67,10 @@ namespace I18N { inline wxString translate(const std::string &s, const char* ctx) { return _wxGetTranslation_ctx(wxString(s.c_str(), wxConvUTF8), ctx); } inline wxString translate(const std::wstring &s, const char* ctx) { return _wxGetTranslation_ctx(s.c_str(), ctx); } - inline wxString translate_utf8(const char *s, const char* ctx) { return _wxGetTranslation_ctx(wxString(s, wxConvUTF8), ctx).ToUTF8().data(); } - inline wxString translate_utf8(const wchar_t *s, const char* ctx) { return _wxGetTranslation_ctx(s, ctx).ToUTF8().data(); } - inline wxString translate_utf8(const std::string &s, const char* ctx) { return _wxGetTranslation_ctx(wxString(s.c_str(), wxConvUTF8), ctx).ToUTF8().data(); } - inline wxString translate_utf8(const std::wstring &s, const char* ctx) { return _wxGetTranslation_ctx(s.c_str(), ctx).ToUTF8().data(); } + inline std::string translate_utf8(const char *s, const char* ctx) { return _wxGetTranslation_ctx(wxString(s, wxConvUTF8), ctx).ToUTF8().data(); } + inline std::string translate_utf8(const wchar_t *s, const char* ctx) { return _wxGetTranslation_ctx(s, ctx).ToUTF8().data(); } + inline std::string translate_utf8(const std::string &s, const char* ctx) { return _wxGetTranslation_ctx(wxString(s.c_str(), wxConvUTF8), ctx).ToUTF8().data(); } + inline std::string translate_utf8(const std::wstring &s, const char* ctx) { return _wxGetTranslation_ctx(s.c_str(), ctx).ToUTF8().data(); } #undef _wxGetTranslation_ctx } // namespace I18N diff --git a/src/slic3r/GUI/Plater.cpp b/src/slic3r/GUI/Plater.cpp index 9e003aac53..14f24a9993 100644 --- a/src/slic3r/GUI/Plater.cpp +++ b/src/slic3r/GUI/Plater.cpp @@ -3074,10 +3074,10 @@ unsigned int Plater::priv::update_background_process(bool force_validation, bool auto *top_level_wnd = dynamic_cast(p); if (! postpone_error_messages && top_level_wnd && top_level_wnd->IsActive()) { // The error returned from the Print needs to be translated into the local language. - GUI::show_error(this->q, _(err)); + GUI::show_error(this->q, err); } else { // Show the error message once the main window gets activated. - this->delayed_error_message = _(err).ToUTF8(); + this->delayed_error_message = err; } return_state |= UPDATE_BACKGROUND_PROCESS_INVALID; } diff --git a/src/slic3r/GUI/PrintHostDialogs.cpp b/src/slic3r/GUI/PrintHostDialogs.cpp index d083895379..6707dc0ed0 100644 --- a/src/slic3r/GUI/PrintHostDialogs.cpp +++ b/src/slic3r/GUI/PrintHostDialogs.cpp @@ -275,7 +275,7 @@ void PrintHostQueueDialog::on_error(Event &evt) on_list_select(); - GUI::show_error(nullptr, std::move(errormsg)); + GUI::show_error(nullptr, errormsg); } void PrintHostQueueDialog::on_cancel(Event &evt) diff --git a/src/slic3r/GUI/Tab.cpp b/src/slic3r/GUI/Tab.cpp index ed3a93007f..fefc8e1135 100644 --- a/src/slic3r/GUI/Tab.cpp +++ b/src/slic3r/GUI/Tab.cpp @@ -3032,7 +3032,7 @@ void Tab::save_preset(std::string name /*= ""*/) const Preset &preset = m_presets->get_selected_preset(); auto default_name = preset.is_default ? "Untitled" : // preset.is_system ? (boost::format(_utf8(L("%1% - Copy"))) % preset.name).str() : - preset.is_system ? (boost::format(_CTX_utf8(L_CONTEXT("%1% - Copy", "PresetName"), "PresetName").ToUTF8()) % preset.name).str() : + preset.is_system ? (boost::format(_CTX_utf8(L_CONTEXT("%1% - Copy", "PresetName"), "PresetName")) % preset.name).str() : preset.name; bool have_extention = boost::iends_with(default_name, ".ini"); diff --git a/src/slic3r/Utils/PresetUpdater.cpp b/src/slic3r/Utils/PresetUpdater.cpp index 4e33e9d6bc..909595cc08 100644 --- a/src/slic3r/Utils/PresetUpdater.cpp +++ b/src/slic3r/Utils/PresetUpdater.cpp @@ -423,7 +423,7 @@ Updates PresetUpdater::priv::get_config_updates(const Semver &old_slic3r_version // Any published config shall be always found in the latest config index. auto message = (boost::format("Preset bundle `%1%` version not found in index: %2%") % idx.vendor() % vp.config_version.to_string()).str(); BOOST_LOG_TRIVIAL(error) << message; - GUI::show_error(nullptr, GUI::from_u8(message)); + GUI::show_error(nullptr, message); continue; }