[Rubycocoa-devel 941] Re: parameters in callback are different from original objects
Laurent Sansonetti
lsansonetti at apple.com
Hi Satoshi-san,
On Jun 3, 2007, at 6:14 AM, Satoshi Nakagawa wrote:
> Hi.
>
> I found a problem that parameters in callback are different original
> objects.
>
> For example,
> ----
> class TableManager < OSX::NSObject
> ib_outlet :table
>
> def awakeFromNib
> @table.setDataSource(self)
> end
>
> def numberOfRowsInTableView(sender)
> p sender
> p @table
> if sender == @table
> ...
> else
> ...
> end
> end
> end
> ----
>
> The output is:
> ----
> #<OSX::NSTableView:0xa16990 class='NSTableView' id=0xf9b44a0>
> #<OSX::NSTableView:0xa1744e class='NSTableView' id=0xf9b44a0>
> ----
>
> Sender value passed to numberOfRowsInTableView is different from
> @table.
> Therefore I cannot compare these objects by 'sender == @table'.
> I must compare using 'sender.__ocid__ == @table.__ocid__'.
>
> This problem might be caused by the fix of [Rubycocoa-devel 893].
Yeah, this is a regression introduced by the previous fix :-(
Does this patch work for you (and also fix the previous bug)?
Laurent
Index: framework/src/objc/ocdata_conv.m
===================================================================
--- framework/src/objc/ocdata_conv.m (revision 1806)
+++ framework/src/objc/ocdata_conv.m (working copy)
@@ -684,17 +684,14 @@
if (ocid == nil)
return Qnil;
- ok = NO;
- if (context_obj != Qfalse) {
- // Cache new Ruby object addresses in an internal table to
- // avoid duplication.
- //
- // We are locking the access to the cache twice (lookup + insert)
as
- // ocobj_s_new is succeptible to call us again, to avoid a
deadlock.
- CACHE_LOCK(&oc2rbCacheLock);
- ok = st_lookup(oc2rbCache, (st_data_t)ocid, (st_data_t *)&result);
- CACHE_UNLOCK(&oc2rbCacheLock);
- }
+ // Cache new Ruby object addresses in an internal table to
+ // avoid duplication.
+ //
+ // We are locking the access to the cache twice (lookup + insert) as
+ // ocobj_s_new is succeptible to call us again, to avoid a deadlock.
+ CACHE_LOCK(&oc2rbCacheLock);
+ ok = st_lookup(oc2rbCache, (st_data_t)ocid, (st_data_t *)&result);
+ CACHE_UNLOCK(&oc2rbCacheLock);
if (!ok) {
struct bsConst * bs_const;
More information about the Rubycocoa-devel mailing list |