view release on metacpan or search on metacpan
devel/container.pm view on Meta::CPAN
sub new {
$emission_hook_id ||= Gtk2::Widget->signal_add_emission_hook
(parent_set => \&_do_parent_set);
my $self = shift->SUPER::new(@_);
Scalar::Util::weaken
($self->{'object'}->{'Glib_Ex_ConnectProperties_container'}->{$self+0} = $self);
return $self;
}
sub DESTROY {
view all matches for this distribution
view release on metacpan or search on metacpan
devel/SignalHookIds.pm view on Meta::CPAN
# validate the first arg now
(Scalar::Util::blessed($object) && $object->isa('Glib::Object'))
or croak 'Glib::Ex::SignalHookIds->new(): first param must be the target object';
my $self = bless [ $object ], $class;
Scalar::Util::weaken ($self->[0]);
$self->add (@ids);
return $self;
}
sub add {
my ($self, @ids) = @_;
devel/SignalHookIds.pm view on Meta::CPAN
}
The C<$model &&> part allows C<undef> for no model, in which case the
C<model_ids> becomes undef. Either way any previous SignalHookIds object in
C<model_ids> is discarded and it disconnects the previous model. (Note in
the signal user data you won't want C<$self> but something weakened, to
avoid a circular reference, the same as with all signal connections.)
The key to this kind of usage is that the target object may change and you
want a convenient way to connect to the new and disconnect from the old. If
however a sub-object or sub-widget belongs exclusively to you, never
devel/SignalHookIds.pm view on Meta::CPAN
=head2 Weakening
SignalHookIds keeps only a weak reference to the target object, letting whoever
or whatever has connected the IDs manage the target lifetime. In particular
this weakening means a SignalHookIds object can be kept in the instance data of
the target object itself without creating a circular reference.
If the target object is destroyed then all its signals are disconnected.
SignalHookIds knows no explicit disconnects are needed in that case. SignalHookIds
also knows some forms of weakening and Perl's "global destruction" stage can
give slightly odd situations where the target object has disconnected its
signals but Perl hasn't yet zapped references to the object. SignalHookIds
therefore checks whether its IDs are still connected before disconnecting,
to avoid warnings from Glib.
devel/SignalHookIds.pm view on Meta::CPAN
$obj->signal_connect_after (bar => \&do_bar));
=item C<< $sigids->object() >>
Return the object held in C<$sigids>, or C<undef> if it's been destroyed
(zapped by weakening).
=item C<< $sigids->disconnect() >>
Disconnect the signal IDs held in C<$sigids>, if not already disconnected.
This is done automatically when C<$sigids> is garbage collected, but you can
view all matches for this distribution
view release on metacpan or search on metacpan
BEGIN { require './t/inc/setup.pl' };
use strict;
use warnings;
use Scalar::Util qw/weaken/;
plan tests => 47;
# Use the provided constructor.
{
isa_ok ($boxed, 'GI::BoxedStruct');
is ($boxed->long_, 0);
is ($boxed->g_strv, undef);
is ($boxed->long_ (42), 0);
$boxed->inv;
weaken $boxed;
is ($boxed, undef);
}
# Use our generic constructor.
{
my $boxed = GI::BoxedStruct::returnv ();
isa_ok ($boxed, 'GI::BoxedStruct');
is ($boxed->long_, 42);
is_deeply ($boxed->g_strv, [qw/0 1 2/]);
$boxed->inv;
weaken $boxed;
is ($boxed, undef);
# make sure we haven't destroyed the static object
isa_ok (GI::BoxedStruct::returnv (), 'GI::BoxedStruct');
isa_ok (GI::BoxedStruct::returnv ()->copy, 'GI::BoxedStruct');
}
unless check_gi_version (0, 12, 0);
my $boxed = GI::BoxedStruct::out ();
isa_ok ($boxed, 'GI::BoxedStruct');
is ($boxed->long_, 42);
# $boxed->g_strv contains garbage
weaken $boxed;
is ($boxed, undef);
# make sure we haven't destroyed the static object
isa_ok (GI::BoxedStruct::out (), 'GI::BoxedStruct');
isa_ok (GI::BoxedStruct::out ()->copy, 'GI::BoxedStruct');
}
my $boxed = GI::BoxedStruct::inout ($boxed_out);
isa_ok ($boxed, 'GI::BoxedStruct');
is ($boxed->long_, 0);
is ($boxed_out->long_, 42);
# $boxed->g_strv contains garbage
weaken $boxed;
is ($boxed, undef);
}
# --------------------------------------------------------------------------- #
my $boxed = Regress::TestSimpleBoxedA::const_return ();
isa_ok ($boxed, 'Regress::TestSimpleBoxedA');
isa_ok ($boxed, 'Glib::Boxed');
my $copy = $boxed->copy;
ok ($boxed->equals ($copy));
weaken $boxed;
is ($boxed, undef);
weaken $copy;
is ($copy, undef);
}
{
my $boxed = Regress::TestBoxed->new;
isa_ok ($boxed, 'Glib::Boxed');
my $copy = $boxed->copy;
isa_ok ($boxed, 'Regress::TestBoxed');
isa_ok ($boxed, 'Glib::Boxed');
ok ($boxed->equals ($copy));
weaken $boxed;
is ($boxed, undef);
weaken $copy;
is ($copy, undef);
$boxed = Regress::TestBoxed->new_alternative_constructor1 (23);
isa_ok ($boxed, 'Regress::TestBoxed');
isa_ok ($boxed, 'Glib::Boxed');
weaken $boxed;
is ($boxed, undef);
$boxed = Regress::TestBoxed->new_alternative_constructor2 (23, 42);
isa_ok ($boxed, 'Regress::TestBoxed');
isa_ok ($boxed, 'Glib::Boxed');
weaken $boxed;
is ($boxed, undef);
$boxed = Regress::TestBoxed->new_alternative_constructor3 ("perl");
isa_ok ($boxed, 'Regress::TestBoxed');
isa_ok ($boxed, 'Glib::Boxed');
weaken $boxed;
is ($boxed, undef);
}
view all matches for this distribution
view release on metacpan or search on metacpan
my $sigid = $my->signal_connect ('nosuchsignal' => $subr);
Glib::Log->remove_handler ('GLib-GObject', $logid);
ok(! $sigid, 34, "'nosuchsignal' not connected");
require Scalar::Util;
Scalar::Util::weaken ($subr);
ok(! defined $subr, 35, "subr gc'ed after bad signal name");
}
}
pass(36);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Global/IPC/ppport.h view on Meta::CPAN
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Global/ppport.h view on Meta::CPAN
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view all matches for this distribution
view release on metacpan or search on metacpan
use warnings;
use utf8;
use Env;
use POSIX qw/:fcntl_h/;
use Scalar::Util qw/weaken/;
use Test::Most;
use FFI::Platypus;
use FFI::Platypus::Buffer;
use FFI::Platypus::Memory qw/strdup calloc free/;
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Gnuplot/Builder/Dataset.pm view on Meta::CPAN
package Gnuplot::Builder::Dataset;
use strict;
use warnings;
use Gnuplot::Builder::PrototypedData;
use Scalar::Util qw(weaken blessed);
use Carp;
use overload '""' => 'to_string';
sub new {
my ($class, $source, @set_option_args) = @_;
lib/Gnuplot/Builder/Dataset.pm view on Meta::CPAN
return $class->new->set_file('-')->set_data($data_provider)->set_option(@set_option_args);
}
sub _init_pdata {
my ($self) = @_;
weaken $self;
$self->{pdata} = Gnuplot::Builder::PrototypedData->new(
entry_evaluator => sub {
my ($key, $coderef) = @_;
return $coderef->($self, $key);
},
view all matches for this distribution
view release on metacpan or search on metacpan
sv_release_COW|||
sv_release_IVX|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.006000||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.006000||p
view all matches for this distribution
view release on metacpan or search on metacpan
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view all matches for this distribution
view release on metacpan or search on metacpan
src/ppport.h view on Meta::CPAN
SvROK_off|5.003007|5.003007|
SvROK_on|5.003007|5.003007|
SvRV|5.003007|5.003007|
SvRV_const|5.010001||Viu
SvRV_set|5.009003|5.003007|p
sv_rvunweaken|5.027004|5.027004|
sv_rvweaken|5.006000|5.006000|
SvRVx|5.003007||Viu
SvRX|5.009005|5.003007|p
SvRXOK|5.009005|5.003007|p
SV_SAVED_COPY|5.009005||Viu
SvSCREAM|5.003007||Viu
view all matches for this distribution
view release on metacpan or search on metacpan
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view all matches for this distribution
view release on metacpan or search on metacpan
bench/stress.pl view on Meta::CPAN
{
use lib 'lib';
$|++;
}
use Scalar::Util qw/weaken/;
use Time::HiRes qw/time/;
use Data::Dumper;
use Graph::Easy;
my $N1 = shift || 5000;
bench/stress.pl view on Meta::CPAN
{
my $o = new_object($i);
$container->{nodes}->{$i} = $o;
$o->{graph} = $container;
weaken($o->{graph});
if ($old_object)
{
my $link = new_link($old_object, $o, $i);
$container->{edges}->{$i} = $link;
$link->{graph} = $container;
{
no warnings;
weaken($link->{graph});
weaken($link->{to}->{graph});
weaken($link->{from}->{graph});
}
}
$old_object = $o;
}
view all matches for this distribution
view release on metacpan or search on metacpan
t/MyTestHelpers.pm view on Meta::CPAN
} else {
MyTestHelpers::diag ("Devel::FindRef not available -- ", $@);
}
}
sub test_weaken_show_leaks {
my ($leaks) = @_;
$leaks || return;
my $unfreed = $leaks->unfreed_proberefs;
my $unfreed_count = scalar(@$unfreed);
view all matches for this distribution
view release on metacpan or search on metacpan
Newc(__LINE__, private, sizeof(struct private) + (2*state->dimensions-1) * sizeof(aglo_real), char, struct private);
private->closure = SvREFCNT_inc(POPs);
private->state_sv = newRV(state_sv);
/* private->state_sv is effectively a self-reference */
sv_rvweaken(private->state_sv);
private->force_sv = newRV(force_sv);
PUTBACK;
FREETMPS;
LEAVE;
return private;
view all matches for this distribution
view release on metacpan or search on metacpan
t/MyTestHelpers.pm view on Meta::CPAN
} else {
MyTestHelpers::diag ("Devel::FindRef not available -- ", $@);
}
}
sub test_weaken_show_leaks {
my ($leaks) = @_;
$leaks || return;
my $unfreed = $leaks->unfreed_proberefs;
my $unfreed_count = scalar(@$unfreed);
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Graph/TransitiveClosure/Matrix.pm view on Meta::CPAN
use strict;
use warnings;
use Graph::AdjacencyMatrix;
use Graph::Matrix;
use Scalar::Util qw(weaken);
use List::Util qw(min);
sub _A() { 0 } # adjacency
sub _D() { 1 } # distance
sub _S() { 2 } # successors
lib/Graph/TransitiveClosure/Matrix.pm view on Meta::CPAN
return 1 if $want_transitive;
my %V; @V{ @V } = @V;
$am->[0] = \@ai;
$dm->[0] = \@di if defined $dm;
$sm->[0] = \@si if defined $sm;
weaken(my $og = $g);
bless [ $am, $dm, $sm, \%V, $og ], $class;
}
sub new {
my ($class, $g, %opt) = @_;
view all matches for this distribution
view release on metacpan or search on metacpan
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view all matches for this distribution
view release on metacpan or search on metacpan
XS/ppport.h view on Meta::CPAN
sv_ref||5.015004|
sv_replace|||
sv_report_used|||
sv_resetpvn|||
sv_reset|||
sv_rvweaken||5.006000|
sv_sethek|||
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
view all matches for this distribution
view release on metacpan or search on metacpan
sv_release_COW|||
sv_release_IVX|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.006000||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.006000||p
view all matches for this distribution
view release on metacpan or search on metacpan
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view all matches for this distribution
view release on metacpan or search on metacpan
sv_reftype|||
sv_release_COW|||
sv_replace|||
sv_report_used|||
sv_reset|||
sv_rvweaken||5.006000|
sv_setiv_mg|5.004050||p
sv_setiv|||
sv_setnv_mg|5.006000||p
sv_setnv|||
sv_setpv_mg|5.004050||p
view all matches for this distribution
view release on metacpan or search on metacpan
lib/Gtk2/CV/ImageWindow.pm view on Meta::CPAN
return if $self->{image};
$title_image ||= Gtk2::CV::require_image "cv.png";
$self->set_image ($title_image);
Scalar::Util::weaken $title_image;
}
=item $img->load_image ($path)
Tries to load the given file (if it is an image), or embeds mpv (if
view all matches for this distribution
view release on metacpan or search on metacpan
devel/unmapped.pl view on Meta::CPAN
}
my $events = Gtk2::Ex::WidgetEvents->new ($widget, 'visibility-notify-mask');
my $self = bless { widget => $widget,
events => $events,
}, $class;
Scalar::Util::weaken ($self->{'widget'});
return $self;
}
package Gtk2::Ex::Visibility;
use strict;
devel/unmapped.pl view on Meta::CPAN
my $self = bless { widget => $widget,
visibility_state => '',
events => Gtk2::Ex::WidgetEvents->new ($widget, 'visibility-notify-mask'),
ids => $ids,
}, $class;
Scalar::Util::weaken ($self->{'widget'});
Scalar::Util::weaken (my $weak_self = $self);
my $self->{'ids'} = Glib::Ex::SignalIds->new
($widget,
$widget->signal_connect ('visibility_notify_event',
\&_do_visibility_notify_event,
\$weak_self));
view all matches for this distribution