Commit 6229db7a authored by Torsten Schönfeld's avatar Torsten Schönfeld

Fix compatibility with perl 5.20 and non-dot locales

In locales with something else than a dot as the decimal separator, the
combination of perl >= 5.20 and Gtk2 lead to errors wherever perl tried to
parse version numbers, as in "use 5.8.0" or "use Encode 0.5".  Fix by making
sure we notify perl when the locale might have changed behind its back.
parent c0fcf02f
{{$NEXT}}
* Fix compatibility with perl 5.20 and non-dot locales.
Overview of changes in Gtk3 0.016 [2014-02-19]
==============================================
......
......@@ -1471,6 +1471,49 @@ sub Pango::Layout::set_text {
@_ == 3 ? @_ : (@_[0,1], -1)); # wants length in bytes
}
# - Fixes ------------------------------------------------------------------- #
# Compatibility with perl 5.20 and non-dot locales. Wrap all functions that
# might end up calling setlocale() such that POSIX::setlocale() is also called
# to ensure perl knows about the current locale. See the discussion in
# <https://rt.perl.org/Public/Bug/Display.html?id=121930>,
# <https://rt.perl.org/Public/Bug/Display.html?id=121317>,
# <https://rt.perl.org/Public/Bug/Display.html?id=120723>.
if ($^V ge v5.20.0) {
require POSIX;
no strict 'refs';
no warnings 'redefine';
my $disable_setlocale = 0;
my $orig = \&Gtk3::disable_setlocale;
*{Gtk3::disable_setlocale} = sub {
$disable_setlocale = 1;
$orig->(@_);
};
# These two already have overrides.
foreach my $function (qw/Gtk3::init Gtk3::init_check/) {
my $orig = \&{$function};
*{$function} = sub {
if (!$disable_setlocale) {
POSIX::setlocale (POSIX::LC_ALL (), '');
}
$orig->(@_);
};
}
# These do not.
foreach my $function (qw/init_with_args parse_args/) {
*{'Gtk3::' . $function} = sub {
if (!$disable_setlocale) {
POSIX::setlocale (POSIX::LC_ALL (), '');
}
Glib::Object::Introspection->invoke (
$_GTK_BASENAME, undef, $function, @_);
};
}
}
# - Helpers ----------------------------------------------------------------- #
sub _common_tree_model_new {
......
......@@ -10,12 +10,16 @@ my $success = eval { Gtk3->import; 1 };
BAIL_OUT ("Cannot load Gtk3: $@")
unless $success;
plan tests => 1;
plan tests => 2;
SKIP: {
@ARGV = qw(--help --name gtk2perl --urgs tree);
skip 'Gtk3::init_check failed, probably unable to open DISPLAY', 1
skip 'Gtk3::init_check failed, probably unable to open DISPLAY', 2
unless Gtk3::init_check ();
Gtk3::init ();
is_deeply (\@ARGV, [qw(--help --urgs tree)]);
# Ensure that version parsing still works after the setlocale() done by
# Gtk3::init().
ok (defined eval 'use 5.8.0; 1');
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment