• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSImage allocation issues
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSImage allocation issues


  • Subject: Re: NSImage allocation issues
  • From: Jesus De Meyer <email@hidden>
  • Date: Fri, 30 Apr 2004 15:45:47 +0200

Well, I do release the menu item. Here's the full method for building the files menu. Perhaps the bug is very obvious but I just can't see it.

Thanks for the help though:

- (void)buildFilesMenu:(NSMenu*)menu fromArray:(NSArray*)items withPath:(NSString*)path {
NSEnumerator *theEnumerator = [items objectEnumerator];
NSMenu *subMenu;
NSString *theItem;

while (theItem = [theEnumerator nextObject]) {
NSString *itemPath;
NSString *itemType;

itemPath = [NSString stringWithFormat:@"%@/%@", path, theItem];
itemType = [[fileManager fileAttributesAtPath:itemPath traverseLink:NO] objectForKey:NSFileType];

BOOL isExe = [self fileIsApp:itemPath];

if ([itemType isEqualTo:NSFileTypeDirectory]) {
if (!isExe) {
subMenu = [[NSMenu alloc] init];

NSMenuItem *mi = [[NSMenuItem alloc] initWithTitle:theItem action:nil keyEquivalent:@""];
NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:itemPath];

if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"showIcons"] intValue] && icon) {
[icon setSize:NSMakeSize(16, 16)];
[mi setImage:icon];
}
[menu addItem:mi];

if (wasExecutable) {
wasExecutable = NO;
[self buildFilesMenu:subMenu fromArray:[fileManager directoryContentsAtPath:itemPath] withPath:path];
} else {
[self buildFilesMenu:subMenu fromArray:[fileManager directoryContentsAtPath:itemPath] withPath:itemPath];
}

[menu setSubmenu:subMenu forItem:mi];
[mi release];
[subMenu release];
}
}
if (![itemType isEqualTo:NSFileTypeDirectory] || isExe) {
NSString *displayName;
displayName = [[fileManager displayNameAtPath:itemPath] copy];

if (isExe)
wasExecutable = YES;

if ([self fileVisible:itemPath] && ![displayName hasPrefix:@"Icon"]) {
NSMenuItem *mi = [[NSMenuItem alloc] initWithTitle:displayName action:@selector(selectItem:) keyEquivalent:@""];

[mi setTarget:self];
[mi setTag:[filesArray count]];
[filesArray addObject:itemPath];

NSImage *icon = [[NSWorkspace sharedWorkspace] iconForFile:itemPath];

if ([[[NSUserDefaults standardUserDefaults] objectForKey:@"showIcons"] intValue] && icon) {
[icon setSize:NSMakeSize(16, 16)];
[mi setImage:icon];
}
[menu addItem:mi];
[mi release];
}
}
}
}
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.


References: 
 >NSImage allocation issues (From: Jesus De Meyer <email@hidden>)
 >Re: NSImage allocation issues (From: Jeremy Dronfield <email@hidden>)

  • Prev by Date: SIGPIPE with dataWithPDFInsideRect
  • Next by Date: Getting updated insertion point from NSDraggingInfo
  • Previous by thread: Re: NSImage allocation issues
  • Next by thread: OT? Why are list archive search results so lame?
  • Index(es):
    • Date
    • Thread