Changeset 9407


Ignore:
Timestamp:
Oct 25, 2009, 9:30:19 PM (13 years ago)
Author:
livings124
Message:

delay part of generating the message log text until after choosing a location

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/macosx/MessageWindowController.m

    r9342 r9407  
    315315    NSSortDescriptor * descriptor = [[[NSSortDescriptor alloc] initWithKey: @"Index" ascending: YES] autorelease];
    316316    NSArray * descriptors = [[NSArray alloc] initWithObjects: descriptor, nil];
    317     NSArray * sortedMessages = [fMessages sortedArrayUsingDescriptors: descriptors];
     317    NSArray * sortedMessages = [[fMessages sortedArrayUsingDescriptors: descriptors] retain];
    318318    [descriptors release];
    319    
    320     //create the text to output
    321     NSMutableArray * messageStrings = [NSMutableArray arrayWithCapacity: [fMessages count]];
    322     for (NSDictionary * message in sortedMessages)
    323         [messageStrings addObject: [self stringForMessage: message]];
    324    
    325     NSString * fileString = [[messageStrings componentsJoinedByString: @"\n"] retain];
    326319   
    327320    NSSavePanel * panel = [NSSavePanel savePanel];
     
    331324    [panel beginSheetForDirectory: nil file: NSLocalizedString(@"untitled", "Save log panel -> default file name")
    332325            modalForWindow: [self window] modalDelegate: self
    333             didEndSelector: @selector(writeToFileSheetClosed:returnCode:contextInfo:) contextInfo: fileString];
    334 }
    335 
    336 - (void) writeToFileSheetClosed: (NSSavePanel *) panel returnCode: (NSInteger) code contextInfo: (NSString *) string
     326            didEndSelector: @selector(writeToFileSheetClosed:returnCode:contextInfo:) contextInfo: sortedMessages];
     327}
     328
     329- (void) writeToFileSheetClosed: (NSSavePanel *) panel returnCode: (NSInteger) code contextInfo: (NSArray *) messages
    337330{
    338331    if (code == NSOKButton)
    339332    {
    340         if (![string writeToFile: [panel filename] atomically: YES encoding: NSUTF8StringEncoding error: nil])
     333        //create the text to output
     334        NSMutableArray * messageStrings = [NSMutableArray arrayWithCapacity: [fMessages count]];
     335        for (NSDictionary * message in messages)
     336            [messageStrings addObject: [self stringForMessage: message]];
     337   
     338        NSString * fileString = [messageStrings componentsJoinedByString: @"\n"];
     339       
     340        if (![fileString writeToFile: [panel filename] atomically: YES encoding: NSUTF8StringEncoding error: nil])
    341341        {
    342342            NSAlert * alert = [[NSAlert alloc] init];
     
    353353    }
    354354   
    355     [string release];
     355    [messages release];
    356356}
    357357
Note: See TracChangeset for help on using the changeset viewer.