Subject: | SDL::App resize method discards new surface pointer |
The SDL::App resize method includes code like:
$self = \SDL::SetVideoMode($w,$h,$bpp,$flags);
and then returns.
Since it creates a new reference in $self instead of $self the value
from SetVideoMode is effectively discarded.
Now it appears that SetVideoMode always returns the same surface handle
for the video surface so this doesn't make itself felt at runtime, but
if SetVideoMode is ever changed so that a different surface pointer is
returned then this is going to start crashing.
Returning the same pointer makes this hard to test for too <sigh>.
My proposed patch (also attached):
--- lib/SDL/App.pm.orig 2006-01-10 14:55:35.000000000 +1100
+++ lib/SDL/App.pm 2006-01-10 15:10:39.000000000 +1100
@@ -96,7 +96,8 @@
my $flags = SDL::SurfaceFlags($$self);
if ( $flags & SDL::SDL_RESIZABLE()) {
my $bpp = SDL::SurfaceBitsPerPixel($$self);
- $self = \SDL::SetVideoMode($w,$h,$bpp,$flags);
+ $$self = SDL::SetVideoMode($w,$h,$bpp,$flags)
+ or die "resize: ", SDL::GetError();
}
}
--- lib/SDL/App.pm.orig 2006-01-10 14:55:35.000000000 +1100
+++ lib/SDL/App.pm 2006-01-10 15:10:39.000000000 +1100
@@ -96,7 +96,8 @@
my $flags = SDL::SurfaceFlags($$self);
if ( $flags & SDL::SDL_RESIZABLE()) {
my $bpp = SDL::SurfaceBitsPerPixel($$self);
- $self = \SDL::SetVideoMode($w,$h,$bpp,$flags);
+ $$self = SDL::SetVideoMode($w,$h,$bpp,$flags)
+ or die "resize: ", SDL::GetError();
}
}