Changeset 118

Show
Ignore:
Timestamp:
02/07/08 11:11:47 (1 year ago)
Author:
mike
Message:

[new] QDocument savepanel while saving
[new] QDocument loadpanel while reverting
[new] QDocument saveAs
[fix] QControlController memory leak

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/QControl/QControlController.m

    r116 r118  
    123123        [VMs release]; 
    124124 
    125     VMs = [[[NSMutableArray alloc] init] retain]; 
     125    VMs = [[NSMutableArray alloc] init]; 
    126126    NSString *qvmFile; 
    127127        NSMutableDictionary *tempVM; 
  • trunk/QDocument/QDocument.m

    r117 r118  
    161161    if (driveFileNames) 
    162162                [driveFileNames release]; 
     163        if (configuration) 
     164                [configuration release]; 
    163165    if([[NSFileManager defaultManager] fileExistsAtPath:[NSString stringWithFormat:@"/tmp/qDocument_%D.vga", uniqueDocumentID]]) 
    164166        [[NSFileManager defaultManager] removeFileAtPath:[NSString stringWithFormat:@"/tmp/qDocument_%D.vga", uniqueDocumentID] handler: nil]; 
     
    251253} 
    252254 
     255- (void)savePanelDidEnd:(NSOpenPanel *)panel returnCode:(int)returnCode  contextInfo:(void  *)contextInfo 
     256{ 
     257        Q_DEBUG(@"savePanelDidEnd"); 
     258 
     259        NSFileManager *fileManager; 
     260        NSMutableArray *knownVMs; 
     261 
     262    if (returnCode == NSOKButton) { 
     263 
     264                fileManager = [NSFileManager defaultManager]; 
     265                 
     266                // move untitled Document to named document 
     267                if ([fileManager movePath:[[[configuration objectForKey:@"Temporary"] objectForKey:@"URL"] path] toPath:[panel filename] handler:nil]) { 
     268                        [[configuration objectForKey:@"Temporary"] setObject:[panel URL] forKey:@"URL"]; 
     269                        [self setFileURL:[panel URL]]; 
     270         
     271                        // if outside default path, add to knownVNs 
     272                        if (![[[panel filename] stringByDeletingLastPathComponent] isEqual:[[qApplication userDefaults] objectForKey:@"dataPath"]]) { 
     273                                if (![[[qApplication userDefaults] objectForKey:@"knownVMs"] containsObject:[panel filename]]) { 
     274                                        knownVMs = [[[[qApplication userDefaults] objectForKey:@"knownVMs"] mutableCopy] autorelease]; 
     275                                        [knownVMs addObject:[panel filename]]; 
     276                                        [[qApplication userDefaults] setObject:knownVMs forKey:@"knownVMs"]; 
     277                                } 
     278                        } 
     279                         
     280                        [[NSNotificationCenter defaultCenter] postNotificationName:@"QVMStatusDidChange" object:nil]; //communicate new state 
     281                } else { 
     282                        [self defaultAlertMessage:@"Could not save %@" informativeText:[NSString stringWithFormat:@"There was an error while saving %@", [self displayName],  [self displayName]]]; 
     283                } 
     284    } 
     285} 
     286 
     287- (IBAction)saveDocumentAs:(id)sender 
     288{ 
     289        Q_DEBUG(@"saveDocumentAs"); 
     290 
     291        if (VMState == QDocumentShutdown || VMState == QDocumentSaved) {         
     292                NSSavePanel *savePanel = [NSSavePanel savePanel]; 
     293                [savePanel setAllowedFileTypes:[NSArray arrayWithObject:@"qvm"]]; 
     294                [savePanel setCanSelectHiddenExtension:YES]; 
     295                [savePanel beginSheetForDirectory:[[qApplication userDefaults] objectForKey:@"dataPath"] file:[self displayName] modalForWindow:[screenView window] modalDelegate:self didEndSelector:@selector(savePanelDidEnd:returnCode:contextInfo:) contextInfo:nil]; 
     296        } else { 
     297                [self defaultAlertMessage:@"VM is running" informativeText:@"Please shutdown the VM before saving the VM to a new Name"]; 
     298        } 
     299} 
     300 
    253301- (IBAction) saveDocument:(id)sender 
    254302{ 
    255303        Q_DEBUG(@"saveDocument"); 
    256304         
    257         // Todo: 
    258         // implement saving as following: 
    259         // if VM is shutdown/saved: 
    260         //     - save the .qvm package with the save name 
    261         //     - save configuration.plis
    262         // if the VM is running 
    263         //     - save a snapshot 
    264  
    265     [distributedObject setCommand:'W' arg1:0 arg2:0 arg3:0 arg4:0]; 
     305        // Todo: Document was not yet saved with a proper name, we call a savepanel and move the VM 
     306        if (VMState == QDocumentShutdown || VMState == QDocumentSaved) { 
     307               [self saveDocumentAs:self]; 
     308 
     309        // if the VM is running, we make a snapsho
     310        } else if (VMState == QDocumentPaused || VMState == QDocumentRunning) { 
     311               [self setVMState:QDocumentSaving]; 
     312                [distributedObject setCommand:'W' arg1:0 arg2:0 arg3:0 arg4:0]; 
     313        } 
    266314} 
    267315 
     
    270318        Q_DEBUG(@"revertDocumentToSaved"); 
    271319         
    272         // Todo 
    273         // only revert running machines 
    274  
    275     [distributedObject setCommand:'X' arg1:0 arg2:0 arg3:0 arg4:0]; 
     320        if (VMState == QDocumentPaused || VMState == QDocumentRunning) { 
     321               [self setVMState:QDocumentLoading]; 
     322                [distributedObject setCommand:'X' arg1:0 arg2:0 arg3:0 arg4:0]; 
     323        } 
    276324} 
    277325 
  • trunk/QShared/QPopUpButtonCell.m

    r114 r118  
    5252- (void) dealloc 
    5353{ 
    54         [image release]; 
    5554        [imageNormal release]; 
    5655        [super dealloc]; 
  • trunk/qemu/patches/cocoa.m

    r108 r118  
    397397                break; 
    398398            case 'W': // save VM 
     399                                savedVm_running = FALSE; 
    399400                do_savevm([@"kju_saved" cString]); 
    400401                break; 
    401402            case 'X': // revert to previous saved state 
     403                                savedVm_running = FALSE; 
    402404                if (vm_running) 
    403405                    vm_stop(0);