Author: mordante
Date: Tue May 12 21:51:02 2009
New Revision: 35607
URL: http://svn.gna.org/viewcvs/wesnoth?rev=35607&view=rev
Log:
Fixed UTF-8 handling in the password textbox.
A multi-character in the textbox had its length determined with the
number of characters instead of number of UTF-8 glyphs.
Modified:
trunk/changelog
trunk/players_changelog
trunk/src/gui/widgets/password_box.cpp
Modified: trunk/changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/changelog?rev=35607&r1=35606&r2=35607&view=diff
==============================================================================
--- trunk/changelog (original)
+++ trunk/changelog Tue May 12 21:51:02 2009
@@ -102,6 +102,7 @@
* Debug actions "Create unit" and "Change side" used on unit in a village
now causes a capture of that village.
* Rewrote the layout algoritm (still a work in progress)
+ * Fixed an multi-character UTF-8 handling bug in the password textbox
* WML Engine:
* Added [show_objectives] tag and allowed [show_if] tag in [objective]
tags. (bug #13042)
Modified: trunk/players_changelog
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/players_changelog?rev=35607&r1=35606&r2=35607&view=diff
==============================================================================
--- trunk/players_changelog (original)
+++ trunk/players_changelog Tue May 12 21:51:02 2009
@@ -48,6 +48,7 @@
installing one, and with its entry selected.
* Improved the sorting of the XP and traits columns in the unit list dialog
(part of bug #13360).
+ * Fixed the MP password textbox handling of special characters.
* Miscellaneous and bugfixes
* Fixed missing unit graphics when loading a start-of-scenario savegame.
Modified: trunk/src/gui/widgets/password_box.cpp
URL:
http://svn.gna.org/viewcvs/wesnoth/trunk/src/gui/widgets/password_box.cpp?rev=35607&r1=35606&r2=35607&view=diff
==============================================================================
--- trunk/src/gui/widgets/password_box.cpp (original)
+++ trunk/src/gui/widgets/password_box.cpp Tue May 12 21:51:02 2009
@@ -18,13 +18,23 @@
#include "gui/widgets/password_box.hpp"
#include "gui/auxiliary/log.hpp"
+#include "serialization/string_utils.hpp"
namespace gui2 {
+
+namespace {
+
+size_t get_text_length(const std::string& str)
+{
+ return utils::string_to_wstring(str).size();
+}
+
+} // namespace
void tpassword_box::set_value(const std::string& text) {
ttext_box::set_value(text);
real_value_ = get_value();
- ttext_box::set_value(std::string(real_value_.size(), '*'));
+ ttext_box::set_value(std::string(get_text_length(real_value_), '*'));
}
void tpassword_box::insert_char(const Uint16 unicode) {
@@ -64,7 +74,7 @@
handled = true;
if(get_selection_length() != 0) {
delete_selection();
- } else if (get_selection_start() < text().size()) {
+ } else if (get_selection_start() < get_text_length(text())) {
delete_char(false);
}
@@ -98,7 +108,7 @@
// Get the input back and make ttext_box forget it
real_value_ = get_value();
- ttext_box::set_value(std::string(real_value_.size(), '*'));
+ ttext_box::set_value(std::string(get_text_length(real_value_), '*'));
// See above
set_selection_start(selection_start);
_______________________________________________
Wesnoth-commits mailing list
[email protected]
https://mail.gna.org/listinfo/wesnoth-commits