diff options
author | mescalinum <mescalinum@users.sourceforge.net> | 2011-11-28 23:59:13 +0000 |
---|---|---|
committer | mescalinum <mescalinum@users.sourceforge.net> | 2011-11-28 23:59:13 +0000 |
commit | ef18d8daab4aad16f833fe17fe8be97671eebe71 (patch) | |
tree | 96cab517ef9f0be374e506341aaff8eddc38b902 | |
parent | d08fb1df93b9f9585f401b1cf156df627c1cf024 (diff) |
Fix pd_bind crash in [bitmap] (bug #3429577).
This commit causes [bitmap] to break further, because there are now two string
representations of a t_pd*:
1. the one provided by SWIG, unaccessible by tclpd;
2. the tclpd synthetic one
In order to be fixed, hashtable must become a bidirectional hashmap, so that a
reverse lookup in the object_table is possible (needed in order to make a
%typemap(out) t_pd *).
svn path=/trunk/externals/loaders/tclpd/; revision=15801
-rw-r--r-- | examples/bitmap.tcl | 18 | ||||
-rw-r--r-- | tclpd.i | 8 |
2 files changed, 21 insertions, 5 deletions
diff --git a/examples/bitmap.tcl b/examples/bitmap.tcl index e1d0495..c54d51f 100644 --- a/examples/bitmap.tcl +++ b/examples/bitmap.tcl @@ -60,13 +60,20 @@ proc+ bitmap::constructor {self args} { 0_config $self {*}$args set @rcvLoadData {#bitmap} + + set x [pd_findbyclass $@rcvLoadData bitmap] + if {$x ne "NULL"} { + # prevent crash due to stale bound receivers: + pd_unbind $x $@rcvLoadData + } + pd_bind $self $@rcvLoadData } proc+ bitmap::destructor {self} { - if {$@rcvLoadData ne {}} { - #should not happen! - pd_unbind $self $@rcvLoadData + set x [pd_findbyclass $@rcvLoadData bitmap] + if {$x ne "NULL"} { + pd_unbind $x $@rcvLoadData } if {[dict get $@config -receivesymbol] ne {}} { pd_unbind $self $@recv @@ -248,9 +255,10 @@ proc+ bitmap::0_setdata {self args} { } set @data [list] foreach i $d {lappend @data [expr {int($i)}]} - if {$@rcvLoadData ne {}} { + + set x [pd_findbyclass $@rcvLoadData bitmap] + if {$x ne "NULL"} { pd_unbind $self $@rcvLoadData - set @rcvLoadData {} } } @@ -88,6 +88,7 @@ void name_setitem(type *ary, int index, type value) const char *str = Tcl_GetStringFromObj($input, NULL); $1 = object_table_get(str); SWIG_contract_assert($1, "not a t_pd * instance") {}; + // XXX: %typemap(out) missing!!! } %typemap(in) t_text * { @@ -107,6 +108,13 @@ void name_setitem(type *ary, int index, type value) $1 = &x->o; } +%typemap(in) struct _class * { + const char *str = Tcl_GetStringFromObj($input, NULL); + t_class *c = class_table_get(str); + SWIG_contract_assert(c, "invalid class name") {}; + $1 = c; +} + /* functions that are in m_pd.h but don't exist in modern versions of pd */ %ignore pd_getfilename; %ignore pd_getdirname; |