Hi, I’ve incorporated the Tree Controller in SourceView. SourceView shows a Split View with a tree structure on the left and either shows the contents of a URL or a List of Files on the right, depending on which item is selected in the left view.
The SourceView project is built using ARC, but my App uses Manual Memory Management. When I moved the code over, I changed it to use release etc. and changed any properties or iVar’s to use retain or assign. The problem builds with no analyser warnings (which doesn’t mean as much as it used to, because I’ve found that the Analyser in XCode 6.3 is buggy). When I run the App, it displays the Tree View fine and Populates the two sections, but it crashes due to an over-release if I select a file based item - I found this by using NSZombies - it gives the error: *** -[NSImage release]: message sent to deallocated instance 0x20e5b9fc0 I traced the problem down to the method copies below - please see comments in code. I’ve stopped it crashing by adding a retain although it doesn’t display the Files Correctly so there is something else wrong. I can’t figure out why I need this extra retain since everything seems to balanced without it. Any ideas how to debug this would be greatly appreciated. All the Best Dave - (void)outlineView:(NSOutlineView *)olv willDisplayCell:(NSCell*)cell forTableColumn:(NSTableColumn *)tableColumn item:(id) item { NSImage* iconImage; NSString* urlStr; ImageAndTextCell* myCell; ChildNode* myChildNode; if ([[tableColumn identifier] isEqualToString:COLUMNID_NAME] == NO) return; // we are displaying the single and only column if ([cell isKindOfClass:[ImageAndTextCell class]] == NO) return; iconImage = nil; myChildNode = [item representedObject]; if (myChildNode != nil) { if (myChildNode.isLeaf == YES) { urlStr = myChildNode.urlString; if (urlStr != nil) { if ([myChildNode.urlString hasPrefix:HTTP_PREFIX]) { myChildNode.nodeIcon = self.pURLImage; } else { iconImage = [[[NSWorkspace sharedWorkspace] iconForFile:urlStr] copy]; //Crashes without retain or if I remove the copy and and release statement below LogIfDave(@"Before Get File iconImage - retainCount: %ld",[iconImage retainCount]); myChildNode.nodeIcon = iconImage; //***** [iconImage release]; //** Crashes if Present!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! LogIfDave(@"After set Item iconImage - retainCount: %ld",[iconImage retainCount]); } } } } else //** //** Check if it's a special folder (PLACES or BOOKMARKS), we don't want it to have an icon //** { if ([self isSpecialGroup:myChildNode]) { myChildNode.nodeIcon = nil; } else { myChildNode.nodeIcon = self.pFolderImage; } } // set the cell's image [myChildNode.nodeIcon setSize:NSMakeSize(kIconImageSize,kIconImageSize)]; myCell = (ImageAndTextCell*) cell; iconImage = myChildNode.nodeIcon; if (iconImage != nil) LogIfDave(@"Before set pTextCellImage - retainCount: %ld",[iconImage retainCount]); //*** This line causes a crash if the [iconImage release]; statement above is executed!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! myCell.pTextCellImage = iconImage; if (iconImage != nil) LogIfDave(@"After set Item pTextCellImage - retainCount: %ld",[iconImage retainCount]); } _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) 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: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com