On line 90, you add the JSB_ScrollViewDelegate as a child in js_cocos2dx_CCScrollView_setDelegate(). If you iterate through all of the child nodes in JS, it hits the assert in ccarray_to_jsval(). I’m not sure why the JSB_ScrollViewDelegate is failing the proxy check at the beginning:
I didn’t find a good way to delete instance that created by new JSB_ScrollViewDelegate.
Since CCScrollView::setDelegate is a weak reference function, I don’t know when the JSB_ScrollViewDelegate needs to be deleted.
Therefore, I added it to the CCScrollView and make JSB_ScrollViewDelegate inherited from CCNode.
Then, JSB_ScrollViewDelegate will get notification when its parent is onExit.
I didn’t find a better way to resolve this issue.
Any suggestion or solution will be appreciated. Thanks.
What do you mean by invoking the destructor of JSB_ScrollViewDelegate? If I make these two changes, I’m getting compile errors on `oldDelegate->removeFromParent();@
If I comment that line out, it appears to work fine.
Yes, the binding of CCTableView, CCEditBox also need to be updated. @Joel Poloney
Was the destructor of JSB_ScrollViewDelegate invoked?
Mutoo Lau wrote:
I think so, the same problems occur to CCTableView (JSB_TableViewDataSource also);
>
Joel Poloney wrote:
> Yep, that appears to work. Should I make the same changes to CCTableView and CCEditBox as well?
@Joel Poloney
Was the destructor of JSB_ScrollViewDelegate invoked?
>
We only ever set the delegate once, so there’s no old delegate to remove. So, I added the same delegate again in our JS (called setDelegate twice in a row) and it went through to the destructor just fine.
Yes, cobj->setUserObject(NULL); is not needed indeed. Glad to hear that it works now.
Joel Poloney wrote:
James Chen wrote:
> @Joel Poloney
> Was the destructor of JSB_ScrollViewDelegate invoked?
>
>
We only ever set the delegate once, so there’s no old delegate to remove. So, I added the same delegate again in our JS (called setDelegate twice in a row) and it went through to the destructor just fine.
I tried this solution for JSB_TableViewDataSource but failed;
I think it’s because of a CCTableView may need a JSB_TableViewDelegate and a JSB_TableViewDataSource but cobj~~>setUserObject just keeps one;
James Chen wrote:
Yes, cobj~~>setUserObject(NULL); is not needed indeed. Glad to hear that it works now.
>
Joel Poloney wrote:
> James Chen wrote:
> > @Joel Poloney
> > Was the destructor of JSB_ScrollViewDelegate invoked?
> >
>
> We only ever set the delegate once, so there’s no old delegate to remove. So, I added the same delegate again in our JS (called setDelegate twice in a row) and it went through to the destructor just fine.
Yes, it’s a problem…… No thoughts about that now….
Mutoo Lau wrote:
I tried this solution for JSB_TableViewDataSource but failed;
>
I think it’s because of a CCTableView may need a JSB_TableViewDelegate and a JSB_TableViewDataSource but cobj~~>setUserObject just keeps one;
>
James Chen wrote:
> Yes, cobj~~>setUserObject(NULL); is not needed indeed. Glad to hear that it works now.
>
> Joel Poloney wrote:
> > James Chen wrote:
> > > @Joel Poloney
> > > Was the destructor of JSB_ScrollViewDelegate invoked?
> > >
> >
> > We only ever set the delegate once, so there’s no old delegate to remove. So, I added the same delegate again in our JS (called setDelegate twice in a row) and it went through to the destructor just fine.
It would not be a good idea…
> JSB_TableViewDelegate and JSB_TableViewDataSource aren’t in the same place to be added into CCTableView;
>
James Chen wrote:
> Hey, I think you could create a CCArray, and set the CCArray to setUserObject. That’ll be able to work.