Skip to content
Browse files

Instead of croaking set hard limits to surface boundaries

  • Loading branch information...
1 parent 4e98c2e commit 529d9f7aa18b86471623c4a4401d5da70a876b96 @kthakore kthakore committed Sep 27, 2010
Showing with 13 additions and 8 deletions.
  1. +2 −2 Build.PL
  2. +9 −4 src/SDLx/Surface.xs
  3. +2 −2 t/lib/SDL/TestTool.pm
View
4 Build.PL
@@ -558,11 +558,11 @@ my $build = $package->new(
'File::Find' => '0',
'File::ShareDir' => '0',
'Tie::Simple' => '0',
- 'IO::CaptureOutput' => '0',
+ 'Capture::Tiny' => '0',
},
build_requires => {
'Test::Simple' => '0.88',
- 'IO::CaptureOutput' => '0',
+ 'Capture::Tiny' => '0',
'Test::Most' => '0.21',
'Alien::SDL' => '1.413',
'File::ShareDir' => '0',
View
13 src/SDLx/Surface.xs
@@ -114,10 +114,15 @@ surfacex_get_pixel_xs ( surface, x, y )
int x
int y
CODE:
- if( x < 0 || y < 0 || x > surface->w || y > surface->h)
- {
- croak(" Invalid location for pixel (%d, %d) on surface dims (%d, %d)", x,y,surface->w, surface->h);
- }
+ if( x < 0 )
+ x = 0;
+ else if ( x > surface->w)
+ x = surface->w;
+
+ if ( y < 0 )
+ y = 0;
+ else if ( y > surface->h)
+ y = surface->h;
int offset;
offset = _calc_offset( surface, x, y);
View
4 t/lib/SDL/TestTool.pm
@@ -1,7 +1,7 @@
package SDL::TestTool;
use strict;
use warnings;
-use IO::CaptureOutput qw(capture);
+use Capture::Tiny qw(capture);
use SDL;
use SDL::AudioSpec;
use SDL::Audio;
@@ -36,7 +36,7 @@ sub init {
SDL::quit();
}
- capture { SDL::init($init) } \$stdout, \$stderr;
+ ($stdout, $stderr ) = capture { SDL::init($init) };
if ( $stderr ne '' ) {
warn 'Init ' . $inits{$init} . ' failed with SDL error: ' . SDL::get_error() . "\nand stderr $stderr\n";
}

0 comments on commit 529d9f7

Please sign in to comment.
Something went wrong with that request. Please try again.