Changeset 112

Show
Ignore:
Timestamp:
02/06/08 19:40:17 (1 year ago)
Author:
mike
Message:

[fix] QDocumentTableViewController unified thumnailloading
[fix] QDocumentOpenGLView better Window updates
[fix] QApplicationController Memory Leak
[fix] QControlController Memory Leak

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/English.lproj/QDocument.nib/info.nib

    r106 r112  
    1111        <key>IBOpenObjects</key> 
    1212        <array> 
    13                 <integer>5</integer> 
     13                <integer>6</integer> 
    1414        </array> 
    1515        <key>IBSystem Version</key> 
  • trunk/Q.xcodeproj/project.pbxproj

    r110 r112  
    8888                        containerPortal = 2A37F4A9FDCFA73011CA2CEA /* Project object */; 
    8989                        proxyType = 1; 
    90                         remoteGlobalIDString = 2796F6680D58E9E8006DA3A0 /* qemu */
     90                        remoteGlobalIDString = 2796F6680D58E9E8006DA3A0
    9191                        remoteInfo = qemu; 
    9292                }; 
  • trunk/QApplication/QApplicationController.m

    r107 r112  
    2525#import "QApplicationController.h" 
    2626 
    27 // #define QAPPLICATIONCONTROLLER_DEBUG 1 
    2827 
    2928 
     
    3736 
    3837                // preferences 
    39                 [[NSUserDefaults standardUserDefaults] registerDefaults:[[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects: 
     38                [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects: 
    4039                        [NSNumber numberWithBool:FALSE], // disable log to console 
    4140                        [NSNumber numberWithBool:TRUE], // yellow 
  • trunk/QControl/QControlController.m

    r106 r112  
    136136        // add knownVMs 
    137137        int i; 
    138         NSMutableArray *knownVMs = [[[qApplication userDefaults] objectForKey:@"knownVMs"] mutableCopy]; 
     138        NSMutableArray *knownVMs = [[[[qApplication userDefaults] objectForKey:@"knownVMs"] mutableCopy] autorelease]; 
    139139        for (i = [knownVMs count] - 1; i > -1; i--) { 
    140140                // does it still exist? 
  • trunk/QControl/QControlTableViewController.h

    r106 r112  
    3333        IBOutlet QControlTableView *table; 
    3434        IBOutlet QControlController* qControl; 
     35        NSImage *shutdownImage; 
    3536        NSMutableArray *VMsImages; 
    3637        NSArray *cpuTypes; 
     
    3839} 
    3940- (void) tableDoubleClick:(id)sender; 
     41- (NSImage *) loadThumbnailForVM:(NSMutableDictionary *)VM; 
    4042- (void) updateThumbnails:(id)sender; 
    4143@end 
  • trunk/QControl/QControlTableViewController.m

    r109 r112  
    3737        if (super) { 
    3838         
     39                // cache shutdown image 
     40                shutdownImage = [NSImage imageNamed: @"q_table_shutdown.png"]; 
     41                [shutdownImage retain]; 
     42         
    3943                // Listen to VM updates 
    4044        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateThumbnails:) name:@"QVMStatusDidChange" object:nil]; 
     
    4953    [[NSNotificationCenter defaultCenter] removeObserver:self]; 
    5054        [VMsImages release]; 
     55        [shutdownImage release]; 
    5156        [super dealloc]; 
    5257} 
     
    239244 
    240245#pragma mark create tumbnails 
     246- (NSImage *) loadThumbnailForVM:(NSMutableDictionary *)VM 
     247{ 
     248        Q_DEBUG(@"loadThumbnailForVM"); 
     249 
     250        NSImage *thumbnail; 
     251        NSImage *savedImage; 
     252 
     253        if ([[[VM objectForKey:@"PC Data"] objectForKey:@"state"] isEqual:@"saved"]) { // only return thumbnail for saved VMs 
     254                savedImage = [[[NSImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/QuickLook/Thumbnail.png", [[[VM objectForKey:@"Temporary"] objectForKey:@"URL"] path]]] autorelease]; 
     255                if (savedImage) { // try screen.png 
     256                        thumbnail = [[[NSImage alloc] initWithSize:NSMakeSize(100.0,  75.0)] autorelease]; 
     257                        [thumbnail lockFocus]; 
     258                        [savedImage drawInRect:NSMakeRect(0.0, 0.0, 100.0, 75.0) fromRect:NSMakeRect(0.0, 0.0, [savedImage size].width, [savedImage size].height) operation:NSCompositeSourceOver fraction:1.0]; 
     259                        [thumbnail unlockFocus]; 
     260                        return thumbnail; 
     261                } else { // try old thumbnail.png 
     262                        savedImage = [[[NSImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/thumbnail.png", [[[VM objectForKey:@"Temporary"] objectForKey:@"URL"] path]]] autorelease]; 
     263                        if (savedImage) { 
     264                                return savedImage; 
     265                        } 
     266                } 
     267        } 
     268        return shutdownImage; 
     269} 
     270 
    241271- (void) updateThumbnails:(id)sender 
    242272{ 
     
    247277        QDocument *qDocument; 
    248278        NSImage *thumbnail; 
    249         NSImage *savedImage; 
    250279         
    251280        updateAll = FALSE; 
     
    258287        } 
    259288    for (i = 0; i < [[qControl VMs] count]; i++ ) { 
    260  
    261289                qDocument = [[NSDocumentController sharedDocumentController] documentForURL:[[[[qControl VMs] objectAtIndex:i] objectForKey:@"Temporary"] objectForKey:@"URL"]]; 
    262290        if (qDocument) { 
     
    268296                                        [VMsImages replaceObjectAtIndex:i withObject:thumbnail]; 
    269297                                        break; 
     298                                case QDocumentShutdown: 
     299                                        [VMsImages replaceObjectAtIndex:i withObject:shutdownImage]; 
     300                                        break; 
    270301                                default: 
    271302                                        if (updateAll) { 
    272                                                 savedImage = [[[NSImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/QuickLook/Thumbnail.png", [[[[[qControl VMs] objectAtIndex:i] objectForKey:@"Temporary"] objectForKey:@"URL"] path]]] autorelease]; 
    273                                                 if (savedImage) { 
    274                                                         thumbnail = [[[NSImage alloc] initWithSize:NSMakeSize(100.0,  75.0)] autorelease]; 
    275                                                         [thumbnail lockFocus]; 
    276                                                         [savedImage drawInRect:NSMakeRect(0.0, 0.0, 100.0, 75.0) fromRect:NSMakeRect(0.0, 0.0, [savedImage size].width, [savedImage size].height) operation:NSCompositeSourceOver fraction:1.0]; 
    277                                                         [thumbnail unlockFocus]; 
    278                                                 } else { 
    279                                                         [VMsImages addObject:[NSImage imageNamed: @"q_table_shutdown.png"]]; 
    280                                                 } 
    281                                                 [VMsImages addObject:thumbnail]; 
     303                                                [VMsImages addObject:[self loadThumbnailForVM:[[qControl VMs] objectAtIndex:i]]]; 
    282304                                        } 
    283305                                        break; 
    284306                        } 
    285307        } else if (updateAll) { 
    286                         if ([[[[[qControl VMs] objectAtIndex:i] objectForKey:@"PC Data"] objectForKey:@"state"] isEqual:@"saved"]) { 
    287                                 savedImage = [[[NSImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/QuickLook/Thumbnail.png", [[[[[qControl VMs] objectAtIndex:i] objectForKey:@"Temporary"] objectForKey:@"URL"] path]]] autorelease]; 
    288                                 if (savedImage) { 
    289                                         thumbnail = [[[NSImage alloc] initWithSize:NSMakeSize(100.0,  75.0)] autorelease]; 
    290                                         [thumbnail lockFocus]; 
    291                                         [savedImage drawInRect:NSMakeRect(0.0, 0.0, 100.0, 75.0) fromRect:NSMakeRect(0.0, 0.0, [savedImage size].width, [savedImage size].height) operation:NSCompositeSourceOver fraction:1.0]; 
    292                                         [thumbnail unlockFocus]; 
    293                                         [VMsImages addObject:thumbnail]; 
    294                                 } else { // no screen.png, try old thumbnail.png 
    295                                         savedImage = [[[NSImage alloc] initWithContentsOfFile:[NSString stringWithFormat:@"%@/thumbnail.png", [[[[[qControl VMs] objectAtIndex:i] objectForKey:@"Temporary"] objectForKey:@"URL"] path]]] autorelease]; 
    296                                         if (savedImage) { 
    297                                                 [VMsImages addObject:savedImage]; 
    298                                         } else { // no thumbnail, set shutdown 
    299                                                 [VMsImages addObject:[NSImage imageNamed: @"q_table_shutdown.png"]]; 
    300                                         } 
    301                                 } 
    302                         } else { // set shutdown 
    303                                 [VMsImages addObject:[NSImage imageNamed: @"q_table_shutdown.png"]]; 
    304                         } 
     308                        [VMsImages addObject:[self loadThumbnailForVM:[[qControl VMs] objectAtIndex:i]]]; 
    305309        } 
    306310    } 
  • trunk/QDocument/QDocumentOpenGLView.m

    r110 r112  
    263263         
    264264        [[self openGLContext] makeCurrentContext]; 
    265         [self setFrame:NSMakeRect(displayProperties.x, displayProperties.y, displayProperties.width, displayProperties.height)]; 
    266     glViewport(0.0, 0.0, displayProperties.width, displayProperties.height); 
     265    glViewport([self bounds].origin.x, [self bounds].origin.y, [self bounds].size.width, [self bounds].size.height); 
    267266} 
    268267 
     
    344343                textures[QDocumentOpenGLTextureScreen] = 1; 
    345344                 
    346                 //calculate the texure rect 
     345                // calculate the texure rect 
    347346                NSRect clipRect; 
    348347                clipRect = NSMakeRect( 
     
    354353                unsigned char *startPointer = screenBuffer; 
    355354 
    356                 //adapt the drawRect to the textureRect 
     355                // adapt the drawRect to the textureRect 
    357356                rect = NSMakeRect( 
    358357                        0.0, // we update the whole width, as QEMU in vga is always updating whole memory pages) 
     
    399398                } 
    400399                glEnd(); 
    401                 glDisable( GL_TEXTURE_RECTANGLE_ARB ); 
     400                glDisable(GL_TEXTURE_RECTANGLE_ARB); 
    402401 
    403402        } else { 
     
    662661        } 
    663662 
     663        [self setFrame:NSMakeRect(displayProperties.x, displayProperties.y, displayProperties.width, displayProperties.height)]; 
     664        [self display]; // apply the new rect 
    664665    [self update]; 
    665666}