iMediaSandboxing / iMedia

The Karelia iMedia Browser, framework and application for browsing media on Mac OS X
http://www.karelia.com/imedia/
Other
18 stars 12 forks source link

Exception on unarchiving node icon #27

Closed jjac closed 12 years ago

jjac commented 12 years ago

When a folder node (like Movies or Photo Booth) is unarchived in the app's process after being sent from the folder XPC service it often (but not always) causes the following exception to be thrown:

iMediaTester[55258:303] * Terminating app due to uncaught exception 'NSRangeException', reason: '* -[NSArrayI objectAtIndex:]: index 0 beyond bounds for empty array' *\ First throw call stack: ( 0 CoreFoundation 0x00007fff96ed7716 exceptionPreprocess + 198 1 libobjc.A.dylib 0x00007fff9779c470 objc_exception_throw + 43 2 CoreFoundation 0x00007fff96e8a803 -[NSArrayI objectAtIndex:] + 163 3 AppKit 0x00007fff8cc82d1a -[NSImage initWithCoder:] + 3871 4 Foundation 0x00007fff96404c39 _decodeObjectBinary + 2741 5 Foundation 0x00007fff96403fe4 _decodeObject + 226 6 iMedia 0x0000000100031be8 -[IMBNode initWithCoder:] + 1960 7 Foundation 0x00007fff96404c39 _decodeObjectBinary + 2741 8 Foundation 0x00007fff96403fe4 _decodeObject + 226 9 Foundation 0x00007fff964770d3 +[NSKeyedUnarchiver unarchiveObjectWithData:] + 92 10 XPCKit 0x00000001001836ab +[NSData(XPCParse) objectWithXPCObject:] + 123 11 XPCKit 0x0000000100183391 +[NSObject(XPCParse) objectWithXPCObject:] + 257 12 XPCKit 0x0000000100183b79 50+[NSArray(XPCParse) arrayWithContentsOfXPCObject:]_block_invoke_0 + 57 13 libxpc.dylib 0x00007fff94971db8 xpc_array_apply + 50 14 XPCKit 0x0000000100183b03 +[NSArray(XPCParse) arrayWithContentsOfXPCObject:] + 179 15 XPCKit 0x0000000100183318 +[NSObject(XPCParse) objectWithXPCObject:] + 136 16 XPCKit 0x000000010018536c -[XPCMessage objectForKey:] + 124 17 XPCKit 0x0000000100186505 -[XPCMessage(XPCKitInternal) invocationReturnValue:] + 53 18 XPCKit 0x0000000100181644 __67-[XPCConnection sendSelector:withTarget:object:returnValueHandler:]_block_invoke_0 + 68 19 XPCKit 0x000000010018122f block_global_0 + 383 20 libxpc.dylib 0x00007fff9497083c _xpc_connection_call_reply + 31 21 libdispatch.dylib 0x00007fff931e70fa _dispatch_client_callout + 8 22 libdispatch.dylib 0x00007fff931ec104 _dispatch_main_queue_callback_4CF + 275 23 CoreFoundation 0x00007fff96e7981e CFRunLoopRun + 1614 24 CoreFoundation 0x00007fff96e78dd2 CFRunLoopRunSpecific + 290 25 HIToolbox 0x00007fff9442d774 RunCurrentEventLoopInMode + 209 26 HIToolbox 0x00007fff9442d512 ReceiveNextEventCommon + 356 27 HIToolbox 0x00007fff9442d3a3 BlockUntilNextEventMatchingListInMode + 62 28 AppKit 0x00007fff8ccc5fa3 _DPSNextEvent + 685 29 AppKit 0x00007fff8ccc5862 -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 128 30 AppKit 0x00007fff8ccbcc03 -[NSApplication run] + 517 31 AppKit 0x00007fff8cc61656 NSApplicationMain + 869 32 iMediaTester 0x0000000100005067 main + 119 33 iMediaTester 0x00000001000017f4 start + 52 )

Also note the following circumstances:

The problem seems to be gone after I updated the "Photo Booth" directory to the new "Photo Booth Library"

This is a hard one.

peterb180369 commented 12 years ago

Made this more robust by catching the exception and substituting a generic folder icon in this case.

peterb180369 commented 12 years ago

This solution should suffice, so I'm closing this issue.