在单声道触摸中将绑定类型子类化 [英] Subclassing bound type in mono touch

查看:106
本文介绍了在单声道触摸中将绑定类型子类化的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个问题,当我子类一个类型绑定一个obj-C类型。在某些情况下,它在构建时失败。

I have an issue when I subclass a type which bind an obj-C type. In some cases, it fails at construction time.

我现在可以使用cocos2d绑定和CCSprite重现这个。这是我的子类

I can reproduce this right now with the cocos2d bindings and CCSprite. Here's my subclass

public class MySprite : CCSprite
{
    public MySprite (string filename) : base (filename)
    {}
}



当我实例化它时,

When I instantiate it, it fails:

Stacktrace:

  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.void_objc_msgSendSuper_IntPtr (intptr,intptr,intptr) <IL 0x00025, 0xffffffff>
  at MonoTouch.Cocos2D.CCSprite.set_Texture (MonoTouch.Cocos2D.CCTexture2D) <IL 0x00048, 0x00137>
  at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) <IL 0x00052, 0xffffffff>
  at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_IntPtr (intptr,intptr,intptr) <IL 0x00027, 0xffffffff>
  at MonoTouch.Cocos2D.CCSprite..ctor (string) <IL 0x00072, 0x001a3>
  at Demo.MySprite..ctor (string) <IL 0x00002, 0x00027>
 [...]

Native stacktrace:

    0   Demo                       0x00115b5c mono_handle_native_sigsegv + 284
1   Demo                       0x00089c38 mono_sigsegv_signal_handler + 248
2   libsystem_c.dylib                   0x962af86b _sigtramp + 43
3   ???                                 0xffffffff 0x0 + 4294967295
4   Demo                       0x0003b9d2 -[CCSprite setOpacityModifyRGB:] + 47
5   Demo                       0x0003c18c -[CCSprite updateBlendFunc] + 267
6   Demo                       0x0003c37c -[CCSprite setTexture:] + 488
7   ???                                 0x11cadc94 0x0 + 298507412
8   ???                                 0x11cada78 0x0 + 298506872
9   ???                                 0x11cadbf6 0x0 + 298507254
10  Demo                       0x0008dff2 mono_jit_runtime_invoke + 722
11  Demo                       0x001f0b7e mono_runtime_invoke + 126
12  Demo                       0x00293736 monotouch_trampoline + 3686
13  Demo                       0x0003909e -[CCSprite initWithTexture:rect:rotated:] + 614
14  Demo                       0x0003914d -[CCSprite initWithTexture:rect:] + 70
15  Demo                       0x0003934c -[CCSprite initWithFile:] + 275
16  ???                                 0x11cad803 0x0 + 298506243
17  ???                                 0x11cad6ec 0x0 + 298505964
18  ???                                 0x11cace30 0x0 + 298503728
19  ???                                 0x11cac958 0x0 + 298502488
20  ???                                 0x11ca7f04 0x0 + 298483460
21  ???                                 0x0d7f7258 0x0 + 226456152
22  ???                                 0x0d7f0a7c 0x0 + 226429564
23  ???                                 0x0d7f0dc5 0x0 + 226430405
24  Demo                       0x0008dff2 mono_jit_runtime_invoke + 722
25  Demo                       0x001f0b7e mono_runtime_invoke + 126
26  Demo                       0x00293736 monotouch_trampoline + 3686
27  UIKit                      0x016c59d6 -[UIApplication _callInitializationDelegatesForURL:payload:suspended:] + 1292
28  UIKit                      0x016c68a6 -[UIApplication _runWithURL:payload:launchOrientation:statusBarStyle:statusBarHidden:] + 508
29  UIKit                      0x016d5743 -[UIApplication handleEvent:withNewEvent:] + 1027
30  UIKit                      0x016d61f8 -[UIApplication sendEvent:] + 68
31  UIKit                      0x016c9aa9 _UIApplicationHandleEvent + 8196
32  GraphicsServices           0x042bafa9 PurpleEventCallback + 1274
33  CoreFoundation             0x037231c5 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 53
34  CoreFoundation             0x03688022 __CFRunLoopDoSource1 + 146
35  CoreFoundation             0x0368690a __CFRunLoopRun + 2218
36  CoreFoundation             0x03685db4 CFRunLoopRunSpecific + 212
37  CoreFoundation             0x03685ccb CFRunLoopRunInMode + 123
38  UIKit                      0x016c62a7 -[UIApplication _run] + 576
39  UIKit                      0x016c7a9b UIApplicationMain + 1175
40  ???                        0x0d7ebbc5 0x0 + 226409413
41  ???                        0x0d7e5020 0x0 + 226381856
42  ???                        0x0d7e4390 0x0 + 226378640
43  ???                        0x0d7e44e6 0x0 + 226378982
44  Demo                       0x0008dff2 mono_jit_runtime_invoke + 722
45  Demo                       0x001f0b7e mono_runtime_invoke + 126
46  Demo                       0x001f4d74 mono_runtime_exec_main + 420
47  Demo                       0x001fa165 mono_runtime_run_main + 725
48  Demo                       0x000eb4d5 mono_jit_exec + 149
49  Demo                       0x002889f5 main + 2005
50  Demo                       0x00086f81 start + 53

令我担心的是,我有类似的代码在不同的应用程序中工作。

What worries me is that I have similar code working in a different application.

为了完成,如果我重写了Texture属性来代理base,不会崩溃,但不显示任何东西,所以我怀疑本机对象是不良的形状。

And to be complete, if I override the Texture property to proxy to base, it doesn't crash anymore, but doesn't display anything so I suspect the native object is in bad shape.

我也试过[注册]类,添加默认构造函数覆盖。

I also tried [Register]ing the class, and adding the default constructor overrides.

[UPDATE] 我将这个项目与另一个正在工作的项目进行比较。事实上,两者都在设备上工作,两者都在模拟器中失败。

[UPDATE] I compared this project with the other one that was working. In fact, both are working on device, and both fails the same way in the simulator.

[UPDATE2] 这里是一个触发行为的示例: https://github.com/StephaneDelcroix/ mt-subclassbug Cocos2D.dll 是今天早上从 monotouch-bindings master

[UPDATE2] here's a sample triggering the behaviour: https://github.com/StephaneDelcroix/mt-subclassbug The Cocos2D.dll is a fresh one generated this morning from monotouch-bindings master

推荐答案

回答自己的问题。该bug不在bindings定义中,也不在用于生成它们的工具中,而是在cocos2d的2.1rc0版本中。升级到2.1rc0a固定它。

Answering my own question. The bug was not in the bindings definition, nor in the tools used to generate them, but in the 2.1rc0 version of cocos2d. upgrading to 2.1rc0a fixed it.

这会触发一个新的问题,但是可以追溯到绑定定义,并在这里固定 https://github.com/mono/monotouch-bindings/pull/97

This then triggers a new issue, but that one could be traced down to the bindings definition, and is fixed here https://github.com/mono/monotouch-bindings/pull/97

这篇关于在单声道触摸中将绑定类型子类化的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆