Skip Menu |

This queue is for tickets about the Math-Polygon CPAN distribution.

Report information
The Basics
Id: 26765
Status: resolved
Priority: 0/
Queue: Math-Polygon

People
Owner: Nobody in particular
Requestors: ville9 [...] softpres.org
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: (no value)



Subject: "Can't use an undefined value as an ARRAY reference" when trying to fillClip1() a polygon without points
Ok, the is literally pointless: When trying to call fillClip1() on a polygon object that doesn't have any points, Perl croaks with "Can't use an undefined value as an ARRAY reference". This can happen for example when sequentially clipping a polygon (and no points have been left)... Regards, Christian
Subject: Re: [rt.cpan.org #26765] "Can't use an undefined value as an ARRAY reference" when trying to fillClip1() a polygon without points
Date: Sun, 29 Apr 2007 12:23:23 +0200
To: Christian Sauer via RT <bug-Math-Polygon [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* Christian Sauer via RT (bug-Math-Polygon@rt.cpan.org) [070428 15:58]: Show quoted text
> Ok, the is literally pointless: > When trying to call fillClip1() on a polygon object that doesn't have > any points, Perl croaks with "Can't use an undefined value as an ARRAY > reference". > This can happen for example when sequentially clipping a polygon (and no > points have been left)...
It's a bit hard to find the cause of that error message without line number, but probably, this is missing sub fillClip1($$$$) { my ($self, @bbox) = @_; my @clip = polygon_fill_clip1 \@bbox, $self->points; + @clip or return undef; $self->new(points => \@clip); } -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions drs Mark A.C.J. Overmeer MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
From: ville9 [...] softpres.org
On So. 29. Apr. 2007, 06:25:07, Mark@Overmeer.net wrote: Show quoted text
> * Christian Sauer via RT (bug-Math-Polygon@rt.cpan.org) [070428 15:58]:
> > Ok, the is literally pointless: > > When trying to call fillClip1() on a polygon object that doesn't have > > any points, Perl croaks with "Can't use an undefined value as an ARRAY > > reference". > > This can happen for example when sequentially clipping a polygon (and no > > points have been left)...
> > It's a bit hard to find the cause of that error message without line > number, but probably, this is missing > sub fillClip1($$$$) > { my ($self, @bbox) = @_; > my @clip = polygon_fill_clip1 \@bbox, $self->points; > + @clip or return undef; > $self->new(points => \@clip); > } >
Sorry for omitting the line number! It is line 45 in Math/Polygon/Clip.pm It can be fixed either the way you did (by returning undef) or in polygon_fill_clip1 so that fillClip1() returns an empty (or Null) Math::Polygon object. It's up to you - but Null Objects have their advantages... :) Regards, Christian
Subject: Re: [rt.cpan.org #26765] "Can't use an undefined value as an ARRAY reference" when trying to fillClip1() a polygon without points
Date: Mon, 30 Apr 2007 13:58:36 +0200
To: Christian Sauer via RT <bug-Math-Polygon [...] rt.cpan.org>
From: Mark Overmeer <mark [...] overmeer.net>
* Christian Sauer via RT (bug-Math-Polygon@rt.cpan.org) [070429 16:37]: Show quoted text
> > sub fillClip1($$$$) > > { my ($self, @bbox) = @_; > > my @clip = polygon_fill_clip1 \@bbox, $self->points; > > + @clip or return undef; > > $self->new(points => \@clip); > > } > >
> > Sorry for omitting the line number! It is line 45 in Math/Polygon/Clip.pm
Ok, that means a second fix is needed. Of course, it is not really useful to clip an empty polygon to a box... but it should be handled without error. Show quoted text
> It can be fixed either the way you did (by returning undef) or in > polygon_fill_clip1 so that fillClip1() returns an empty (or Null) > Math::Polygon object. > It's up to you - but Null Objects have their advantages... :)
I think that not all operations are definable on an empty polygon, so that doesn't look like a good choice. Besides, I really like constructions like: my $clipped = $poly->clip(...) or next; better than my $clipped = $poly->clip(...); next if $clipped->isEmpty; -- Regards, MarkOv ------------------------------------------------------------------------ Mark Overmeer MSc MARKOV Solutions Mark@Overmeer.net solutions@overmeer.net http://Mark.Overmeer.net http://solutions.overmeer.net
From: ville9 [...] softpres.org
On Mo. 30. Apr. 2007, 07:58:55, Mark@Overmeer.net wrote: Show quoted text
> * Christian Sauer via RT (bug-Math-Polygon@rt.cpan.org) [070429 16:37]:
> > > sub fillClip1($$$$) > > > { my ($self, @bbox) = @_; > > > my @clip = polygon_fill_clip1 \@bbox, $self->points; > > > + @clip or return undef; > > > $self->new(points => \@clip); > > > } > > >
> > > > Sorry for omitting the line number! It is line 45 in
Math/Polygon/Clip.pm Show quoted text
> > Ok, that means a second fix is needed. Of course, it is not really > useful to clip an empty polygon to a box... but it should be handled > without error.
Yes. Show quoted text
> > It can be fixed either the way you did (by returning undef) or in > > polygon_fill_clip1 so that fillClip1() returns an empty (or Null) > > Math::Polygon object. > > It's up to you - but Null Objects have their advantages... :)
> > I think that not all operations are definable on an empty polygon, > so that doesn't look like a good choice. Besides, I really like > constructions like: > my $clipped = $poly->clip(...) or next; > better than > my $clipped = $poly->clip(...); > next if $clipped->isEmpty;
That's fine with me. And fillClip1() was documented as returning undef (instead of an empty polygon) anyway... Thanks, Christian
previous release contained the fixes