Bizarre locking issue
Bizarre locking issue
- Subject: Bizarre locking issue
- From: Tom Davie <email@hidden>
- Date: Sun, 24 Jan 2010 15:34:26 +0000
Hi,
I have a project, based on the non-document-based core data application
template. I've added a small amount of UI, and a tiny bit of code to fill
an NSOutlineView with one item. Since doing so though, I'm getting a bit of
an odd error. When my outline view's data is first loaded, I get the error
**** -[NSRecursiveLock unlock]: lock (<NSRecursiveLock: 0x200032720>
'(null)') unlocked when not locked*
**** Break on _NSLockError() to debug.*
*on the console. Commenting out a line that (on it's first attempt) loads
an object out of CoreData gets the log to go away, and it doesn't appear to
be producing any adverse affects other than the log message, but I'd like to
understand what's going on here.*
*
*
Here's the code that seems to be causing the problem:
In the app delegate:
- (Library *)library
{
if (nil == library)
{
NSError *error = nil;
NSFetchRequest *fetchRequest = [[NSFetchRequest alloc] init];
NSManagedObjectContext *moc = [self managedObjectContext];
[fetchRequest setEntity:[NSEntityDescription entityForName:@"Library"
inManagedObjectContext:moc]];
NSArray *libraries = [moc executeFetchRequest:fetchRequest error:&error];
if (nil == libraries || [libraries count] < 1)
{
library = [[Library alloc] initWithEntity:[[[self managedObjectModel]
entitiesByName] objectForKey:@"Library"] insertIntoManagedObjectContext
:moc];
if (![moc save:&error])
{
[NSApp presentError:error];
}
}
else
{
library = [libraries objectAtIndex:0];
}
}
return library;
}
In my view controller:
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
{
return NO;
}
- (NSInteger)outlineView:(NSOutlineView *)outlineView
numberOfChildrenOfItem:(id)item
{
if (nil == item)
{
return 1;
}
else
{
return 0;
}
}
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index
ofItem:(id)item
{
if (nil == item)
{
return self.library;
}
else
{
return nil;
}
}
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(
NSTableColumn *)tableColumn byItem:(id)item
{
return @"Library";
// if (item == self.library)
// {
// return @"Library";
// }
}
Note that commenting out both lines that requests self.library cause the
error to go away.
Any help would be much appreciated.
Thanks
Tom Davie
p.s. Here's a stack trace when the lock error is logged (breaking on
_NSLockError doesn't work)
#0 0x7fff87e0528f in NSLog
#1 0x7fff87d96fee in -[NSRecursiveLock unlock]
#2 0x7fff883473c1 in -[NSOutlineView
_rowEntryForRow:requiredRowEntryLoadMask:]
#3 0x7fff88347664 in -[NSOutlineView _frameOfOutlineCellAtRow:]
#4 0x7fff8834759c in -[NSOutlineView frameOfOutlineCellAtRow:]
#5 0x7fff88347abd in -[NSOutlineView _adjustDrawingTestFrame:atRow:column:]
#6 0x7fff88346bc1 in -[NSTableView drawRow:clipRect:]
#7 0x7fff883465cb in -[NSTableView drawRowIndexes:clipRect:]
#8 0x7fff8834644c in -[NSOutlineView drawRowIndexes:clipRect:]
#9 0x7fff88344f78 in -[NSTableView drawRect:]
#10 0x7fff8833afae in -[NSView _drawRect:clip:]
#11 0x7fff88339c21 in -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:]
#12 0x7fff88339f8b in -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:]
#13 0x7fff88339f8b in -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:]
#14 0x7fff88339f8b in -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:]
#15 0x7fff88339f8b in -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:]
#16 0x7fff88339f8b in -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:]
#17 0x7fff88339f8b in -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:]
#18 0x7fff88339f8b in -[NSView
_recursiveDisplayAllDirtyWithLockFocus:visRect:]
#19 0x7fff883382f3 in -[NSView
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
#20 0x7fff88337e17 in -[NSThemeFrame
_recursiveDisplayRectIfNeededIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:topView:]
#21 0x7fff883346bf in -[NSView
_displayRectIgnoringOpacity:isVisibleRect:rectIsVisibleRectForView:]
#22 0x7fff882adf37 in -[NSView displayIfNeeded]
#23 0x7fff88275f87 in -[NSWindow
_reallyDoOrderWindow:relativeTo:findKey:forCounter:force:isModal:]
#24 0x7fff88275b1c in -[NSWindow orderWindow:relativeTo:]
#25 0x7fff88241a2c in -[NSIBObjectData
nibInstantiateWithOwner:topLevelObjects:]
#26 0x7fff8823fb49 in loadNib
#27 0x7fff8823f059 in +[NSBundle(NSNibLoading)
_loadNibFile:nameTable:withZone:ownerBundle:]
#28 0x7fff8823ee91 in +[NSBundle(NSNibLoading) loadNibNamed:owner:]
#29 0x7fff8823c413 in NSApplicationMain
#30 0x100000fb5 in main at main.m:13
_______________________________________________
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