Re: [Pyobjc-dev] Multiple Document App Template
Brought to you by:
ronaldoussoren
From: Bill B. <bb...@co...> - 2003-01-14 21:07:49
|
Nothing so complex -- it is just a bug in NSApplicationMain(). NSApplicationMain() ignores the array of arguments passed to it and uses [[NSProcessInfo processInfo] arguments] instead. Since the first 'argument' that NSApplicationMain() sees is the __main__.py script in the app wrapper and the app knows nothing about the .py type, the app assumes that it is openeing a document, but that the document type is uknown. End result: nothing happens on launch -- no blank window. It was easy to fix and the fix has been committed -- the multiple document app template now works just like the Cocoa-ObjC counterpart. However, the fix is very evil. The following can be found in _AppKit.m in the NSApplicationMain() wrapper: { typedef struct { @defs(NSProcessInfo) } NSProcessInfoStruct; // everything in this scope is evil and wrong. It leaks, too. NSMutableArray *args = [[NSMutableArray alloc] init]; NSProcessInfo *processInfo = [NSProcessInfo processInfo]; char **anArg = argv; while(*anArg) { [args addObject: [NSString stringWithUTF8String: *anArg]]; anArg++; } ((NSProcessInfoStruct *)processInfo)->arguments = args; } res = NSApplicationMain(argc, argv); Evil and wrong, but works. When Apple fixes the bug in NSApplicationMain(), this can be removed. (What is really happening is that NSApplicationMain() ends up with the command line that was passed *to the python interpreter* when it should end up with the command line passed *to the script*...) b.bum |