[aseprite] 119/196: Fix bug pressing warning icon to add palette color when active locale is non-English
Tobias Hansen
thansen at moszumanska.debian.org
Wed Apr 20 18:50:09 UTC 2016
This is an automated email from the git hooks/post-receive script.
thansen pushed a commit to branch master
in repository aseprite.
commit 27b55030e26e93c5e8d9e7e21206c8709d46ff22
Author: David Capello <davidcapello at gmail.com>
Date: Mon Mar 28 15:30:00 2016 -0300
Fix bug pressing warning icon to add palette color when active locale is non-English
It looks like Allegro library was changing the locale to the active
one, and it can break things like strtod() (which is used to convert
colors from string format in AddColor command). In this case, if we added
a HSV color with double floating-point precision, it was added incorrectly
because strtod() wasn't taking the decimal part.
---
src/allegro/src/x/xkeyboard.c | 2 ++
src/main/main.cpp | 11 +++++++++--
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/src/allegro/src/x/xkeyboard.c b/src/allegro/src/x/xkeyboard.c
index 1697d60..f121e62 100644
--- a/src/allegro/src/x/xkeyboard.c
+++ b/src/allegro/src/x/xkeyboard.c
@@ -697,9 +697,11 @@ static int x_keyboard_init(void)
#ifdef ALLEGRO_XWINDOWS_WITH_XIM
/* Otherwise we are restricted to ISO-8859-1 characters. */
+/* [dacap] Don't call setlocale()
if (setlocale(LC_ALL, "") == NULL) {
TRACE(PREFIX_W "Could not set default locale.\n");
}
+*/
/* TODO: is this needed?
modifiers = XSetLocaleModifiers("@im=none");
diff --git a/src/main/main.cpp b/src/main/main.cpp
index 94cfcfe..e69932a 100644
--- a/src/main/main.cpp
+++ b/src/main/main.cpp
@@ -1,5 +1,5 @@
// Aseprite
-// Copyright (C) 2001-2015 David Capello
+// Copyright (C) 2001-2016 David Capello
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2 as
@@ -22,6 +22,7 @@
#include "she/scoped_handle.h"
#include "she/system.h"
+#include <clocale>
#include <cstdlib>
#include <ctime>
#include <iostream>
@@ -48,8 +49,14 @@ namespace {
// Aseprite entry point. (Called from she library.)
int app_main(int argc, char* argv[])
{
+ // Initialize the locale. Aseprite isn't ready to handle numeric
+ // fields with other locales (e.g. we expect strings like "10.32" be
+ // used in std::strtod(), not something like "10,32").
+ std::setlocale(LC_ALL, "en-US");
+ ASSERT(std::strtod("10.32", nullptr) == 10.32);
+
// Initialize the random seed.
- std::srand(static_cast<unsigned int>(std::time(NULL)));
+ std::srand(static_cast<unsigned int>(std::time(nullptr)));
#ifdef _WIN32
::CoInitialize(NULL);
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/aseprite.git
More information about the Pkg-games-commits
mailing list