Skip Menu |
 

This queue is for tickets about the Tickit CPAN distribution.

Report information
The Basics
Id: 68271
Status: resolved
Priority: 0/
Queue: Tickit

People
Owner: Nobody in particular
Requestors: TEAM [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.04
Fixed in: 0.05

Attachments
20110517-tickit-numeric-window-comparison.patch



Subject: Numeric comparison for Tickit::Window instances fails due to overload
Download (untitled) / with headers
text/plain 409b
Hi, Looks like there's a few places where numeric comparisons between Tickit::Window objects are used. Verified it still happens in the latest bzr code: Tickit/Widget.pm(97): return if $window and $self->window and $self->window == $window and for this to work, I believe numeric overload is needed as well as the existing string overload. This patch should apply cleanly to latest trunk. cheers, Tom
Subject: 20110517-tickit-numeric-window-comparison.patch
=== modified file 'lib/Tickit/Window.pm' --- lib/Tickit/Window.pm 2011-04-26 18:44:40 +0000 +++ lib/Tickit/Window.pm 2011-05-17 17:55:15 +0000 @@ -649,7 +649,14 @@ return sprintf "%s[%dx%d abs@%d,%d]", ref $self, $self->cols, $self->lines, $self->abs_left, $self->abs_top; -}; +}, +# Numeric comparison is used in a few places, make sure it doesn't fall through to string +'0+' => sub { + my ($self, $x, $y) = @_; + return $self; +}, +# Allow fallback so that refaddr comparisons (==) work as expected +fallback => 1; =head1 AUTHOR === modified file 't/11window.t' --- t/11window.t 2011-05-01 12:55:22 +0000 +++ t/11window.t 2011-05-17 17:54:26 +0000 @@ -2,7 +2,7 @@ use strict; -use Test::More tests => 40; +use Test::More tests => 41; use Test::Fatal; use Test::Identity; use Test::Refcount; @@ -21,6 +21,7 @@ is_refcount( $rootwin, 3, '$rootwin has refcount 3 after ->make_sub' ); is( "$win", 'Tickit::Window[20x4 abs@10,3]', '$win string overload' ); +ok( !($win == $rootwin), '$win numeric ==' ); my $geom_changed = 0; $win->set_on_geom_changed( sub { $geom_changed++ } );
Download (untitled) / with headers
text/plain 561b
On Tue May 17 13:58:54 2011, TEAM wrote: Show quoted text
> Hi, > > Looks like there's a few places where numeric comparisons between > Tickit::Window objects are used. Verified it still happens in the
latest Show quoted text
> bzr code: > > Tickit/Widget.pm(97): > return if $window and $self->window and $self->window == $window > > and for this to work, I believe numeric overload is needed as well as > the existing string overload.
Oops. Well caught. Applied in bzr. Present in new release on CPAN, 0.05. Will update metadata and close ticket once RT picks it up -- Paul Evans


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.