[perl-Glib] Call "set" magic default SET_PROPERTY implementation
- From: Torsten Schönfeld <tsch src gnome org>
- To: svn-commits-list gnome org
- Subject: [perl-Glib] Call "set" magic default SET_PROPERTY implementation
- Date: Sun, 19 Jul 2009 11:20:11 +0000 (UTC)
commit c6d5841fd5658dda4481d22a58aafbb9940a8f90
Author: Kevin Ryde <user42 zip com au>
Date: Sun Jul 19 13:14:06 2009 +0200
Call "set" magic default SET_PROPERTY implementation
Use SvSetMagicSV instead of SvSetSV for setting properties to make sure that
any "set" magic is properly invoked.
Fixes GNOME #585927.
Signed-off-by: Torsten Schönfeld <kaffeetisch gmx de>
GType.xs | 2 +-
t/tied_set_property.t | 58 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 59 insertions(+), 1 deletions(-)
---
diff --git a/GType.xs b/GType.xs
index f47522c..cda2d27 100644
--- a/GType.xs
+++ b/GType.xs
@@ -1747,7 +1747,7 @@ gperl_type_set_property (GObject * object,
(object, g_param_spec_get_name (pspec), TRUE);
if (val) {
SV * newval = sv_2mortal (gperl_sv_from_value (value));
- SvSetSV (val, newval);
+ SvSetMagicSV (val, newval);
} else {
/* XXX couldn't create the key. what to do? */
}
diff --git a/t/tied_set_property.t b/t/tied_set_property.t
new file mode 100644
index 0000000..043ee92
--- /dev/null
+++ b/t/tied_set_property.t
@@ -0,0 +1,58 @@
+#!/usr/bin/perl
+
+package main;
+use strict;
+use warnings;
+use Test::More tests => 1;
+
+#------------------------------------------------------------------------------
+
+package MaiTai;
+use strict;
+use warnings;
+
+sub TIESCALAR {
+ my ($class) = @_;
+ return bless {}, $class;
+}
+
+my $mai_tai_store_called;
+
+sub STORE {
+ my ($self) = @_;
+ $mai_tai_store_called = 1;
+}
+
+#------------------------------------------------------------------------------
+
+package MyObject;
+use strict;
+use warnings;
+use Glib;
+
+use Glib::Object::Subclass
+ Glib::Object::,
+ properties => [ Glib::ParamSpec->int ('myprop',
+ 'myprop',
+ 'Blurb',
+ 0, 100,
+ 0,
+ [qw/writable readable/]),
+ ];
+
+sub INIT_INSTANCE {
+ my $self = shift;
+ tie $self->{'myprop'}, 'MaiTai';
+}
+
+#------------------------------------------------------------------------------
+
+package main;
+my $obj = MyObject->new;
+
+$mai_tai_store_called = 0;
+$obj->set (myprop => 50);
+is ($mai_tai_store_called, 1,
+ 'MaiTai tied store function called');
+
+exit 0;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]