2011-01-17 7 views
1

Mon MonoTouch Infos Version: ID de sortie: 20401003 révision Git: 2f1746af36f421d262dcd2b0542ce86b12158f02 Date de construction: 2010-12-23 23: 13: 38 + 0000MonoTouch App Crashes De retour MFMailComposeViewController Lorsque

Le MFMailComposeViewController est affiché et fonctionne correctement comme une boîte de dialogue en utilisant le code suivant:

if (MFMailComposeViewController.CanSendMail) { 
    MFMailComposeViewController mail; 

    mail = new MFMailComposeViewController(); 
    mail.SetSubject ("Subject Test"); 
    mail.SetMessageBody ("Body Test", false); 
    mail.Finished += HandleMailFinished; 

    this.navigationController.PresentModalViewController (mail, true); 
    } else { 
    new UIAlertView ("Mail Failed", "Mail Failed", null, "OK", null).Show(); 
    } 

Cependant, une fois que l'utilisateur sélectionne Annuler | Supprimer brouillon ou Annuler | Enregistrer le brouillon ou Envoyer, l'App lance une erreur d'exécution comme ce qui suit:

Stacktrace: 

    at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0x00004> 
    at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain (int,string[],intptr,intptr) <0x00004> 
    at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00038] in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:26 
    at MonoTouch.UIKit.UIApplication.Main (string[]) [0x00000] in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:31 
    at MailDialog.Application.Main (string[]) [0x00000] in /Users/rrkhan/Projects/Sandbox/MailDialog/Main.cs:15 
    at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) <IL 0x0001d, 0x00043> 

Native stacktrace: 

0 MailDialog       0x000be66f mono_handle_native_sigsegv + 343 
1 MailDialog       0x0000e43e mono_sigsegv_signal_handler + 313 
2 libSystem.B.dylib     0x903e946b _sigtramp + 43 
3 ???         0xffffffff 0x0 + 4294967295 
4 MessageUI       0x01a9f6b7 -[MFMailComposeController _close] + 284 
5 UIKit        0x01f682f1 -[UIActionSheet(Private) _buttonClicked:] + 258 
6 UIKit        0x01be1a6e -[UIApplication sendAction:to:from:forEvent:] + 119 
7 UIKit        0x01c701b5 -[UIControl sendAction:to:forEvent:] + 67 
8 UIKit        0x01c72647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527 
9 UIKit        0x01c711f4 -[UIControl touchesEnded:withEvent:] + 458 
10 UIKit        0x01c060d1 -[UIWindow _sendTouchesForEvent:] + 567 
11 UIKit        0x01be737a -[UIApplication sendEvent:] + 447 
12 UIKit        0x01bec732 _UIApplicationHandleEvent + 7576 
13 GraphicsServices     0x03eb7a36 PurpleEventCallback + 1550 
14 CoreFoundation      0x00df9064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52 
15 CoreFoundation      0x00d596f7 __CFRunLoopDoSource1 + 215 
16 CoreFoundation      0x00d56983 __CFRunLoopRun + 979 
17 CoreFoundation      0x00d56240 CFRunLoopRunSpecific + 208 
18 CoreFoundation      0x00d56161 CFRunLoopRunInMode + 97 
19 GraphicsServices     0x03eb6268 GSEventRunModal + 217 
20 GraphicsServices     0x03eb632d GSEventRun + 115 
21 UIKit        0x01bf042e UIApplicationMain + 1160 
22 ???         0x0a1e4bd9 0x0 + 169757657 
23 ???         0x0a1e4b12 0x0 + 169757458 
24 ???         0x0a1e4515 0x0 + 169755925 
25 ???         0x0a1e4451 0x0 + 169755729 
26 ???         0x0a1e44ac 0x0 + 169755820 
27 MailDialog       0x0000e202 mono_jit_runtime_invoke + 1360 
28 MailDialog       0x001c92af mono_runtime_invoke + 137 
29 MailDialog       0x001caf6b mono_runtime_exec_main + 714 
30 MailDialog       0x001ca891 mono_runtime_run_main + 812 
31 MailDialog       0x00094fe8 mono_jit_exec + 200 
32 MailDialog       0x0027cf05 main + 3494 
33 MailDialog       0x00002ca1 _start + 208 
34 MailDialog       0x00002bd0 start + 40 

Debug info from gdb: 

warning: Could not find object file "/var/folders/Ny/NyElTwhDGD8kZMqIEeLGXE+++TI/-Tmp-//cc6F1tBs.o" - no debug information available for "template.m". 

warning: .o file "/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator4.2.sdk/usr/lib/libmonotouch.a(zlib-helper.x86.42.o)" more recent than executable timestamp in "/Users/rrkhan/Library/Application Support/iPhone Simulator/4.2/Applications/52AF1D24-AADA-48ED-B373-ED08E89E4985/MailDialog.app/MailDialog" 
warning: Could not open OSO file /Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator4.2.sdk/usr/lib/libmonotouch.a(zlib-helper.x86.42.o) to scan for pubtypes for objfile /Users/rrkhan/Library/Application Support/iPhone Simulator/4.2/Applications/52AF1D24-AADA-48ED-B373-ED08E89E4985/MailDialog.app/MailDialog 
warning: .o file "/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator4.2.sdk/usr/lib/libmonotouch.a(monotouch-glue.x86.42.o)" more recent than executable timestamp in "/Users/rrkhan/Library/Application Support/iPhone Simulator/4.2/Applications/52AF1D24-AADA-48ED-B373-ED08E89E4985/MailDialog.app/MailDialog" 
warning: Could not open OSO file /Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator4.2.sdk/usr/lib/libmonotouch.a(monotouch-glue.x86.42.o) to scan for pubtypes for objfile /Users/rrkhan/Library/Application Support/iPhone Simulator/4.2/Applications/52AF1D24-AADA-48ED-B373-ED08E89E4985/MailDialog.app/MailDialog 
warning: .o file "/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator4.2.sdk/usr/lib/libmonotouch.a(gc.x86.42.o)" more recent than executable timestamp in "/Users/rrkhan/Library/Application Support/iPhone Simulator/4.2/Applications/52AF1D24-AADA-48ED-B373-ED08E89E4985/MailDialog.app/MailDialog" 
warning: Could not open OSO file /Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator4.2.sdk/usr/lib/libmonotouch.a(gc.x86.42.o) to scan for pubtypes for objfile /Users/rrkhan/Library/Application Support/iPhone Simulator/4.2/Applications/52AF1D24-AADA-48ED-B373-ED08E89E4985/MailDialog.app/MailDialog 
Error connecting stdout and stderr (127.0.0.1:10001) 
warning: .o file "/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator4.2.sdk/usr/lib/libmonotouch.a(monotouch-glue.x86.42.o)" more recent than executable timestamp in "/Users/rrkhan/Library/Application Support/iPhone Simulator/4.2/Applications/52AF1D24-AADA-48ED-B373-ED08E89E4985/MailDialog.app/MailDialog" 
warning: Couldn't open object file '/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator4.2.sdk/usr/lib/libmonotouch.a(monotouch-glue.x86.42.o)' 
Attaching to process 9992. 
Reading symbols for shared libraries . done 
Reading symbols for shared libraries ....................................................................................................................... done 
0x9038e459 in read$UNIX2003() 
    8         0x903a8a12 in __workq_kernreturn() 
    7 "WebThread"      0x903830fa in mach_msg_trap() 
    6         0x903b10a6 in __semwait_signal() 
    5         0x90383136 in semaphore_wait_trap() 
    4         0x903830fa in mach_msg_trap() 
    3         0x903a8a12 in __workq_kernreturn() 
    2 "com.apple.libdispatch-manager" 0x903a9982 in kevent() 
* 1 "com.apple.main-thread"   0x9038e459 in read$UNIX2003() 

Thread 8 (process 9992): 
#0 0x903a8a12 in __workq_kernreturn() 
#1 0x903a8fa8 in _pthread_wqthread() 
#2 0x903a8bc6 in start_wqthread() 

Thread 7 (process 9992): 
#0 0x903830fa in mach_msg_trap() 
#1 0x90383867 in mach_msg() 
#2 0x00df94a6 in __CFRunLoopServiceMachPort() 
#3 0x00d56874 in __CFRunLoopRun() 
#4 0x00d56240 in CFRunLoopRunSpecific() 
#5 0x00d56161 in CFRunLoopRunInMode() 
#6 0x04f7c423 in RunWebThread() 
#7 0x903b085d in _pthread_start() 
#8 0x903b06e2 in thread_start() 

Thread 6 (process 9992): 
#0 0x903b10a6 in __semwait_signal() 
#1 0x903dcee5 in nanosleep$UNIX2003() 
#2 0x903dce23 in usleep$UNIX2003() 
#3 0x0027714c in monotouch_pump_gc() 
#4 0x903b085d in _pthread_start() 
#5 0x903b06e2 in thread_start() 

Thread 5 (process 9992): 
#0 0x90383136 in semaphore_wait_trap() 
#1 0x0015ae1d in finalizer_thread (unused=0x0) at ../../../../mono/metadata/gc.c:1026 
#2 0x002034a3 in start_wrapper (data=0x7b16ba0) at ../../../../mono/metadata/threads.c:661 
#3 0x002448e2 in thread_start_routine (args=0x8037e34) at ../../../../mono/io-layer/wthreads.c:286 
#4 0x00274357 in GC_start_routine (arg=0x6ff7f60) at ../../../libgc/pthread_support.c:1390 
#5 0x903b085d in _pthread_start() 
#6 0x903b06e2 in thread_start() 

Thread 4 (process 9992): 
#0 0x903830fa in mach_msg_trap() 
#1 0x90383867 in mach_msg() 
#2 0x0011cc46 in mach_exception_thread (arg=0x0) at ../../../../mono/mini/mini-darwin.c:138 
#3 0x903b085d in _pthread_start() 
#4 0x903b06e2 in thread_start() 

Thread 3 (process 9992): 
#0 0x903a8a12 in __workq_kernreturn() 
#1 0x903a8fa8 in _pthread_wqthread() 
#2 0x903a8bc6 in start_wqthread() 

Thread 2 (process 9992): 
#0 0x903a9982 in kevent() 
#1 0x903aa09c in _dispatch_mgr_invoke() 
#2 0x903a9559 in _dispatch_queue_invoke() 
#3 0x903a92fe in _dispatch_worker_thread2() 
#4 0x903a8d81 in _pthread_wqthread() 
#5 0x903a8bc6 in start_wqthread() 

Thread 1 (process 9992): 
#0 0x9038e459 in read$UNIX2003() 
#1 0x000be81f in mono_handle_native_sigsegv (signal=11, ctx=0xbfffd238) at ../../../../mono/mini/mini-exceptions.c:1826 
#2 0x0000e43e in mono_sigsegv_signal_handler (_dummy=10, info=0xbfffd1f8, context=0xbfffd238) at ../../../../mono/mini/mini.c:4846 
#3 <signal handler called> 
#4 0x028d6a63 in objc_msgSend() 
#5 0x01ad469f in __func__.24012() 
#6 0x01a9f6b7 in -[MFMailComposeController _close]() 
#7 0x01f682f1 in -[UIActionSheet(Private) _buttonClicked:]() 
#8 0x01be1a6e in -[UIApplication sendAction:to:from:forEvent:]() 
#9 0x01c701b5 in -[UIControl sendAction:to:forEvent:]() 
#10 0x01c72647 in -[UIControl(Internal) _sendActionsForEvents:withEvent:]() 
#11 0x01c711f4 in -[UIControl touchesEnded:withEvent:]() 
#12 0x01c060d1 in -[UIWindow _sendTouchesForEvent:]() 
#13 0x01be737a in -[UIApplication sendEvent:]() 
#14 0x01bec732 in _UIApplicationHandleEvent() 
#15 0x03eb7a36 in PurpleEventCallback() 
#16 0x00df9064 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__() 
#17 0x00d596f7 in __CFRunLoopDoSource1() 
#18 0x00d56983 in __CFRunLoopRun() 
#19 0x00d56240 in CFRunLoopRunSpecific() 
#20 0x00d56161 in CFRunLoopRunInMode() 
#21 0x03eb6268 in GSEventRunModal() 
#22 0x03eb632d in GSEventRun() 
#23 0x01bf042e in UIApplicationMain() 
#24 0x0a1e4bd9 in ??() 
#25 0x0a1e4b12 in ??() 
#26 0x0a1e4515 in ??() 
#27 0x0a1e4451 in ??() 
#28 0x0a1e44ac in ??() 
#29 0x0000e202 in mono_jit_runtime_invoke (method=0xa806e6c, obj=0x0, params=0xbfffedbc, exc=0x0) at ../../../../mono/mini/mini.c:4733 
#30 0x001c92af in mono_runtime_invoke (method=0xa806e6c, obj=0x0, params=0xbfffedbc, exc=0x0) at ../../../../mono/metadata/object.c:2615 
#31 0x001caf6b in mono_runtime_exec_main (method=0xa806e6c, args=0xa6a34e0, exc=0x0) at ../../../../mono/metadata/object.c:3581 
#32 0x001ca891 in mono_runtime_run_main (method=0xa806e6c, argc=0, argv=0xbfffeef4, exc=0x0) at ../../../../mono/metadata/object.c:3355 
#33 0x00094fe8 in mono_jit_exec (domain=0x6f8fe58, assembly=0xa200730, argc=1, argv=0xbfffeef0) at ../../../../mono/mini/driver.c:1094 
#34 0x0027cf05 in main() 

================================================================= 
Got a SIGSEGV while executing native code. This usually indicates 
a fatal error in the mono runtime or one of the native libraries 
used by your application. 
================================================================= 


Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object 
    at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr) 
    at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:26 
    at MonoTouch.UIKit.UIApplication.Main (System.String[] args) [0x00000] in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:31 
    at MailDialog.Application.Main (System.String[] args) [0x00000] in /Users/rrkhan/Projects/Sandbox/MailDialog/Main.cs:15 

J'ai un exemple de projet très simple qui illustre le problème. Je peux vous envoyer si nécessaire.

Répondre

2

Vous autorisez votre MFMailComposeViewController à recueillir avant que vous soyez C# état est fait avec elle, factoriser votre classe pour être fondamentalement comme ceci:

public class Container { 
     MFMailComposeViewController mail; 

     public void Foo() { 
      if (MFMailComposeViewController.CanSendMail) { 
       mail = new MFMailComposeViewController(); 

       mail.SetSubject ("Subject Test"); 
       mail.SetMessageBody ("Body Test", false); 

       mail.Finished += HandleMailFinished; 

       this.navigationController.PresentModalViewController (mail, true); 
      } 
     } 

     public void HandleMailFinished (...) { 
      // existing logic 
      mail.Dispose(); 
      mail = null; 
     } 
    } 
+0

Mais pourquoi serait-il se recueillir? Le contrôleur de courrier est présenté de manière modale, il existe donc au moins une référence à celui-ci. Ou PresentModalViewController() utilise-t-il uniquement la vue du contrôleur? Cela expliquerait pourquoi le contrôleur est collecté. – Krumelur

+0

Correct, l'interface utilisateur conserve les références via la pile View, mais les vues ne possèdent pas leurs contrôleurs. –

+0

Ah. La méthode PresentModalViewController() implique en quelque sorte qu'il garde aussi une référence au contrôleur. Bon à savoir. – Krumelur

Questions connexes