| |
Changeset 112
- 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
| r106 |
r112 |
|
| 11 | 11 | <key>IBOpenObjects</key> |
|---|
| 12 | 12 | <array> |
|---|
| 13 | | <integer>5</integer> |
|---|
| | 13 | <integer>6</integer> |
|---|
| 14 | 14 | </array> |
|---|
| 15 | 15 | <key>IBSystem Version</key> |
|---|
| r110 |
r112 |
|
| 88 | 88 | containerPortal = 2A37F4A9FDCFA73011CA2CEA /* Project object */; |
|---|
| 89 | 89 | proxyType = 1; |
|---|
| 90 | | remoteGlobalIDString = 2796F6680D58E9E8006DA3A0 /* qemu */; |
|---|
| | 90 | remoteGlobalIDString = 2796F6680D58E9E8006DA3A0; |
|---|
| 91 | 91 | remoteInfo = qemu; |
|---|
| 92 | 92 | }; |
|---|
| r107 |
r112 |
|
| 25 | 25 | #import "QApplicationController.h" |
|---|
| 26 | 26 | |
|---|
| 27 | | // #define QAPPLICATIONCONTROLLER_DEBUG 1 |
|---|
| 28 | 27 | |
|---|
| 29 | 28 | |
|---|
| … | … | |
| 37 | 36 | |
|---|
| 38 | 37 | // preferences |
|---|
| 39 | | [[NSUserDefaults standardUserDefaults] registerDefaults:[[NSDictionary alloc] initWithObjects:[NSArray arrayWithObjects: |
|---|
| | 38 | [[NSUserDefaults standardUserDefaults] registerDefaults:[NSDictionary dictionaryWithObjects:[NSArray arrayWithObjects: |
|---|
| 40 | 39 | [NSNumber numberWithBool:FALSE], // disable log to console |
|---|
| 41 | 40 | [NSNumber numberWithBool:TRUE], // yellow |
|---|
| r106 |
r112 |
|
| 136 | 136 | // add knownVMs |
|---|
| 137 | 137 | int i; |
|---|
| 138 | | NSMutableArray *knownVMs = [[[qApplication userDefaults] objectForKey:@"knownVMs"] mutableCopy]; |
|---|
| | 138 | NSMutableArray *knownVMs = [[[[qApplication userDefaults] objectForKey:@"knownVMs"] mutableCopy] autorelease]; |
|---|
| 139 | 139 | for (i = [knownVMs count] - 1; i > -1; i--) { |
|---|
| 140 | 140 | // does it still exist? |
|---|
| r106 |
r112 |
|
| 33 | 33 | IBOutlet QControlTableView *table; |
|---|
| 34 | 34 | IBOutlet QControlController* qControl; |
|---|
| | 35 | NSImage *shutdownImage; |
|---|
| 35 | 36 | NSMutableArray *VMsImages; |
|---|
| 36 | 37 | NSArray *cpuTypes; |
|---|
| … | … | |
| 38 | 39 | } |
|---|
| 39 | 40 | - (void) tableDoubleClick:(id)sender; |
|---|
| | 41 | - (NSImage *) loadThumbnailForVM:(NSMutableDictionary *)VM; |
|---|
| 40 | 42 | - (void) updateThumbnails:(id)sender; |
|---|
| 41 | 43 | @end |
|---|
| r109 |
r112 |
|
| 37 | 37 | if (super) { |
|---|
| 38 | 38 | |
|---|
| | 39 | // cache shutdown image |
|---|
| | 40 | shutdownImage = [NSImage imageNamed: @"q_table_shutdown.png"]; |
|---|
| | 41 | [shutdownImage retain]; |
|---|
| | 42 | |
|---|
| 39 | 43 | // Listen to VM updates |
|---|
| 40 | 44 | [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(updateThumbnails:) name:@"QVMStatusDidChange" object:nil]; |
|---|
| … | … | |
| 49 | 53 | [[NSNotificationCenter defaultCenter] removeObserver:self]; |
|---|
| 50 | 54 | [VMsImages release]; |
|---|
| | 55 | [shutdownImage release]; |
|---|
| 51 | 56 | [super dealloc]; |
|---|
| 52 | 57 | } |
|---|
| … | … | |
| 239 | 244 | |
|---|
| 240 | 245 | #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 | |
|---|
| 241 | 271 | - (void) updateThumbnails:(id)sender |
|---|
| 242 | 272 | { |
|---|
| … | … | |
| 247 | 277 | QDocument *qDocument; |
|---|
| 248 | 278 | NSImage *thumbnail; |
|---|
| 249 | | NSImage *savedImage; |
|---|
| 250 | 279 | |
|---|
| 251 | 280 | updateAll = FALSE; |
|---|
| … | … | |
| 258 | 287 | } |
|---|
| 259 | 288 | for (i = 0; i < [[qControl VMs] count]; i++ ) { |
|---|
| 260 | | |
|---|
| 261 | 289 | qDocument = [[NSDocumentController sharedDocumentController] documentForURL:[[[[qControl VMs] objectAtIndex:i] objectForKey:@"Temporary"] objectForKey:@"URL"]]; |
|---|
| 262 | 290 | if (qDocument) { |
|---|
| … | … | |
| 268 | 296 | [VMsImages replaceObjectAtIndex:i withObject:thumbnail]; |
|---|
| 269 | 297 | break; |
|---|
| | 298 | case QDocumentShutdown: |
|---|
| | 299 | [VMsImages replaceObjectAtIndex:i withObject:shutdownImage]; |
|---|
| | 300 | break; |
|---|
| 270 | 301 | default: |
|---|
| 271 | 302 | 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]]]; |
|---|
| 282 | 304 | } |
|---|
| 283 | 305 | break; |
|---|
| 284 | 306 | } |
|---|
| 285 | 307 | } 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]]]; |
|---|
| 305 | 309 | } |
|---|
| 306 | 310 | } |
|---|
| r110 |
r112 |
|
| 263 | 263 | |
|---|
| 264 | 264 | [[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); |
|---|
| 267 | 266 | } |
|---|
| 268 | 267 | |
|---|
| … | … | |
| 344 | 343 | textures[QDocumentOpenGLTextureScreen] = 1; |
|---|
| 345 | 344 | |
|---|
| 346 | | //calculate the texure rect |
|---|
| | 345 | // calculate the texure rect |
|---|
| 347 | 346 | NSRect clipRect; |
|---|
| 348 | 347 | clipRect = NSMakeRect( |
|---|
| … | … | |
| 354 | 353 | unsigned char *startPointer = screenBuffer; |
|---|
| 355 | 354 | |
|---|
| 356 | | //adapt the drawRect to the textureRect |
|---|
| | 355 | // adapt the drawRect to the textureRect |
|---|
| 357 | 356 | rect = NSMakeRect( |
|---|
| 358 | 357 | 0.0, // we update the whole width, as QEMU in vga is always updating whole memory pages) |
|---|
| … | … | |
| 399 | 398 | } |
|---|
| 400 | 399 | glEnd(); |
|---|
| 401 | | glDisable( GL_TEXTURE_RECTANGLE_ARB ); |
|---|
| | 400 | glDisable(GL_TEXTURE_RECTANGLE_ARB); |
|---|
| 402 | 401 | |
|---|
| 403 | 402 | } else { |
|---|
| … | … | |
| 662 | 661 | } |
|---|
| 663 | 662 | |
|---|
| | 663 | [self setFrame:NSMakeRect(displayProperties.x, displayProperties.y, displayProperties.width, displayProperties.height)]; |
|---|
| | 664 | [self display]; // apply the new rect |
|---|
| 664 | 665 | [self update]; |
|---|
| 665 | 666 | } |
|---|
Download in other formats:
| |