Writing string to pasteboard on 10.5 causes crash
Writing string to pasteboard on 10.5 causes crash
- Subject: Writing string to pasteboard on 10.5 causes crash
- From: Martin Hewitson <email@hidden>
- Date: Mon, 1 Mar 2010 17:03:13 +0100
Dear list,
I have developed an app on SL but at all times compiled the app for 10.5. Today I got my hands on a leopard test machine to try out the app, and I get crashes due to various things. Some of these I've fixed, but I'm stuck at this one:
Part of the app has an NSTableView filled with strings. I am able to drag these strings from this 'library of strings' to another NSTextView. This all works find on SL, but on Leopard it sends the app either in to spinning beachball mode or it crashes. In the spinning beachball case I have to 'force quit' the app, and then I get a very long report which I can't extract any useful information from. The 'crash' actually happens before I reach a dragging destination, so it must be something at the source end. When the app crashes (rather than beachballs) I get the following (extract) crash report:
Thread 0 Crashed:
0 com.apple.CoreFoundation 0x00007fff8068e24f CFDictionaryRemoveValue + 63
1 com.apple.AppKit 0x00007fff80f3cec8 -[NSPasteboard setData:forType:] + 211
2 com.apple.AppKit 0x00007fff80f3cdcf -[NSPasteboard setString:forType:] + 122
3 com.mhsoft.TeXnicle 0x0000000100015d7c -[LibraryController tableView:writeRowsWithIndexes:toPasteboard:] + 651
4 com.apple.AppKit 0x00007fff80ddda72 -[NSTableView _performDragFromMouseDown:] + 651
5 com.apple.AppKit 0x00007fff80ddbbf8 -[NSTableView mouseDown:] + 653
6 com.apple.AppKit 0x00007fff80d93783 -[NSWindow sendEvent:] + 5068
7 com.apple.AppKit 0x00007fff80d60d46 -[NSApplication sendEvent:] + 5089
8 com.apple.AppKit 0x00007fff80cbb562 -[NSApplication run] + 497
9 com.apple.AppKit 0x00007fff80c882f0 NSApplicationMain + 373
10 com.mhsoft.TeXnicle 0x0000000100005d40 main + 33
11 com.mhsoft.TeXnicle 0x00000001000017c0 start + 52
Here's the bit of code that writes the string to the pasteboard:
- (BOOL)tableView:(NSTableView *)aTableView
writeRowsWithIndexes:(NSIndexSet *)rowIndexes
toPasteboard:(NSPasteboard*)pboard
{
if (aTableView == itemsTable) {
NSArray *items = [[contentsController arrangedObjects] objectsAtIndexes:rowIndexes];
NSMutableArray *strings = [NSMutableArray array];
for (NSDictionary *item in items) {
[strings addObject:[item valueForKey:@"Code"]];
}
// id str = [[strings componentsJoinedByString:@"\n"] retain];
id str = [strings componentsJoinedByString:@"\n"];
NSLog(@"Writing to pboard: %@", str);
return [pboard setString:str forType:NSStringPboardType];
}
return NO;
}
At one point I became unsure about the autoreleased string I create by 'componentsJoinedByString:' and if the pasteboard retains that or now, but I tested retaining and not, and it doesn't change anything. Can anyone see any obvious error?
More info: this can really screw up the system pasteboard because sometimes after this crash I can no longer drag-n-drop text in any app and need to reboot to get things working again!
I'm hoping to avoid setting up a build environment on the Leopard machine, but maybe that's a little optimistic.
Any advice gratefully received.
I'd gladly send the app to anyone interested in running it.
The SL working version can be found at: http://web.me.com/martinhewitson/BOBsoft/TeXnicle.html
Thanks in advance,
Martin
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Martin Hewitson
Albert-Einstein-Institut
Max-Planck-Institut fuer
Gravitationsphysik und Universitaet Hannover
Callinstr. 38, 30167 Hannover, Germany
Tel: +49-511-762-17121, Fax: +49-511-762-5861
E-Mail: email@hidden
WWW: http://www.aei.mpg.de/~hewitson
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden