Skip to content

Commit c40b76c

Browse files
committed
weaken extra refs to ::Viewport objects so undefining causes destroy
1 parent e5970ef commit c40b76c

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

lib/PDL/Graphics/TriD/ButtonControl.pm

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ the Event loop.
3737
package PDL::Graphics::TriD::ButtonControl;
3838
use strict;
3939
use warnings;
40+
use Scalar::Util qw(weaken);
4041
use fields qw/Win W H SC/;
4142

4243
$PDL::Graphics::TriD::verbose //= 0;
@@ -45,7 +46,7 @@ sub new {
4546
my ($class,$win) = @_;
4647

4748
my $self = fields::new($class);
48-
$self->{Win} = $win;
49+
weaken($self->{Win} = $win);
4950

5051
$self;
5152
}

lib/PDL/Graphics/TriD/Window.pm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,14 +181,16 @@ sub set_material {
181181
package # hide from PAUSE
182182
PDL::Graphics::TriD::EventHandler;
183183
use fields qw/X Y Buttons VP/;
184+
use Scalar::Util qw(weaken);
185+
184186
sub new {
185187
my $class = shift;
186188
my $vp = shift;
187189
my $self = fields::new($class);
188190
$self->{X} = -1;
189191
$self->{Y} = -1;
190192
$self->{Buttons} = [];
191-
$self->{VP} = $vp;
193+
weaken($self->{VP} = $vp);
192194
$self;
193195
}
194196
sub event {

0 commit comments

Comments
 (0)