aboutsummaryrefslogtreecommitdiff
path: root/examples/bitmap.tcl
diff options
context:
space:
mode:
Diffstat (limited to 'examples/bitmap.tcl')
-rw-r--r--examples/bitmap.tcl18
1 files changed, 13 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 {}
}
}