Mon 02 Apr 2007 12:56:58 PM UTC, comment #4:
I changed the code to perform the operation in the main appkit thread (not as simple as I had hoped) and added an NSWarnFLog().
I don't think this will make debugging much harder ... the thread where the problem ocurred will block, waiting for the main thre3ad to finish displaying the alert panel, so it should be fairly easy to locate and examine it.
Of course, Riccardo's code may not be reliably portable to MacOS-X, but I think he told me it does work on MacOS-X, so perhaps they are already doing alerts safely?
|
Sun 01 Apr 2007 09:31:39 AM UTC, comment #1:
I reproduced this problem ...
#0 0x00002b216024d605 in DPSgsave (ctxt=0x0)
at ../Headers/AppKit/DPSOperators.h:715
#1 0x00002b216024d1f3 in -[NSWindow _initBackendWindow] (self=0x9ef690,
_cmd=0x2b2160533a30) at NSWindow.m:780
#2 0x00002b216024ffa3 in -[NSWindow orderWindow:relativeTo:] (self=0x9ef690,
_cmd=0x2b2160533cf0, place=NSWindowAbove, otherWin=-1) at NSWindow.m:1576
#3 0x00002b216024fd2a in -[NSWindow orderFrontRegardless] (self=0x9ef690,
_cmd=0x2b216045c240) at NSWindow.m:1508
#4 0x00002b21600cd037 in -[NSApplication beginModalSessionForWindow:] (
self=0x69fa60, _cmd=0x2b216045c970, theWindow=0x9ef690)
at NSApplication.m:1461
#5 0x00002b21600cd40b in -[NSApplication runModalForWindow:] (self=0x69fa60,
_cmd=0x2b2160455490, theWindow=0x9ef690) at NSApplication.m:1535
#6 0x00002b21600c210c in -[GSAlertPanel runModal] (self=0x9ef690,
_cmd=0x2b21604555a0) at NSAlert.m:725
#7 0x00002b21600c330d in NSRunAlertPanel (title=0x50fbe0, msg=0x964c90,
defaultButton=0x50fb60, alternateButton=0x0, otherButton=0x0)
at NSAlert.m:983
#8 0x0000000000405898 in -[AppController showAlertDialog:] (self=0x88bde0,
_cmd=0x5136c0, message=0x964c90) at AppController.m:621
#9 0x00000000004074af in -[ftpclient storeFile:from:beingAt:] (self=0x9f9410,
_cmd=0x510fc0, file=0x9dcd80, localClient=0x9ca500, depth=0)
at ftpclient.m:491
#10 0x00000000004033bf in -[AppController performStoreFile:] (self=0x88bde0,
_cmd=0x510f20, parameters=0x0) at AppController.m:308
#11 0x00002b216078a654 in -[NSObject performSelector:withObject:] (
self=0x88bde0, _cmd=0x2b2160b19000, aSelector=0x510f20, anObject=0x0)
at NSObject.m:1947
#12 0x00002b21607ed08e in -[NSThread _sendThreadMethod] (self=0x8fe760,
_cmd=0x2b2160b18fc0) at NSThread.m:780
#13 0x00002b2160c878d7 in ?? () from /usr/lib/libobjc.so.1
#14 0x00002b2160b65f1a in start_thread () from /lib/libpthread.so.0
#15 0x00002b21610ea602 in clone () from /lib/libc.so.6
#16 0x0000000000000000 in ?? ()
The issue is plainly that the call to NSRunAlertPanel() is not from the main thread and is running up against the fact that gui is not thread-safe so and there is no graphics context available in other threads.
The problem is, I don't know what policy is on how to solve this ... should we aim to make NSRunAlertpanel() and similar functions work from any thread?
I don't think we can hope to make gui thread-safe (even if that term was well defined, which it isn't) in any reasonable timeframe, but we could relatively easily solve the immediate issue by making these functions use the -performSelectorOnMainThread:withObject:waitUntilDone:modes: method to ensure that the actual management of the alert panel is done in the main thread.
Thoughts/comments from core developers solicited ... if nobody tells me about a better solution, I'll probably just modify the alert functions to work in the main thread when I have time.
|
Sat 09 Dec 2006 12:20:17 PM UTC, original submission:
when running FTP from gap (as of CVS sources in today's date) the application crashes when a NSRunAlertPanel should be shown. The easiest way to reproduce it is to log in anonymously into an FTP site and upload a file in a place you don't have permissions to uypload into. Other errors could work too, if they are trapped.
The same code works fine on Macintosh.
The complication is that the download or upload aciton is done in a different thread to maintain the gui responsive so that the progress panel can be updated.
Previously, FTP would run the alert panel direclty in the transfer class, now it sends a message to the controller, but it still crashes.
when the alert panel should ocme up, I get
2006-12-09 11:56:30.107 FTP[11006] The font specified for NSFont, Helvetica, can't be found.
an error log which I do not get wwhen running alert panels from non-threaded applications. Maybe it is a hint to the problem.
|