From c4c6c38dbde32fa9478977740864f5c141dff092 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sun, 24 Apr 2016 00:37:53 -0400 Subject: [PATCH] do NOT use Glib::ustring unless you know that the contents are UTF-8 AND that you need to iterate glyph by glyph This fixes a Glib::ConvertError that occured when using Glib::ustring::operator<< inside a compose operation. This implicitly uses Glib::locale_from_utf8(), and if the string is not legal UTF-8, an exception will be thrown. std::string should be used EVERYWHERE unless glyph-by-glyph iteration is required. This is very rare in the Ardour codebase, so you really shouldn't see Glib::ustring anywhere. The main exception is handling user-input for a few specific cases. --- gtk2_ardour/rc_option_editor.cc | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gtk2_ardour/rc_option_editor.cc b/gtk2_ardour/rc_option_editor.cc index 599c4c46c8..8f80c473b7 100644 --- a/gtk2_ardour/rc_option_editor.cc +++ b/gtk2_ardour/rc_option_editor.cc @@ -374,7 +374,7 @@ public: _insert_note_button_adjustment (3, 1, 5), _insert_note_button_spin (_insert_note_button_adjustment) { - const Glib::ustring restart_msg = _("\nChanges to this setting will only persist after your project has been saved."); + const std::string restart_msg = _("\nChanges to this setting will only persist after your project has been saved."); /* internationalize and prepare for use with combos */ vector dumb; @@ -667,9 +667,9 @@ public: set_popdown_strings (_snap_modifier_combo, dumb); _snap_modifier_combo.signal_changed().connect (sigc::mem_fun(*this, &KeyboardOptions::snap_modifier_chosen)); #ifdef __APPLE__ - Glib::ustring mod_str = string_compose (X_("%1-%2"), Keyboard::level4_modifier_name (), Keyboard::tertiary_modifier_name ()); + std::string mod_str = string_compose (X_("%1-%2"), Keyboard::level4_modifier_name (), Keyboard::tertiary_modifier_name ()); #else - Glib::ustring mod_str = Keyboard::secondary_modifier_name(); + std::string mod_str = Keyboard::secondary_modifier_name(); #endif Gtkmm2ext::UI::instance()->set_tip (_snap_modifier_combo, (string_compose (_("Recommended Setting: %1%2"), mod_str, restart_msg))); @@ -1028,8 +1028,8 @@ public: Label* l = manage (new Label (_("GUI and Font scaling:"))); l->set_name ("OptionsLabel"); - const Glib::ustring dflt = _("Default"); - const Glib::ustring empty = X_(""); // despite gtk-doc saying so, NULL does not work as reference + const std::string dflt = _("Default"); + const std::string empty = X_(""); // despite gtk-doc saying so, NULL does not work as reference _dpi_slider.set_name("FontScaleSlider"); _dpi_slider.set_update_policy (UPDATE_DISCONTINUOUS);