Changeset 4875
- Timestamp:
- 08/22/07 21:41:01 (1 year ago)
- Files:
-
- Footagehead/trunk/FHBrowserController.m (modified) (2 diffs)
- Footagehead/trunk/FHImageLoader.h (modified) (2 diffs)
- Footagehead/trunk/FHImageLoader.m (modified) (12 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Footagehead/trunk/FHBrowserController.m
r4871 r4875 1005 1005 path = [openPanel filename]; 1006 1006 1007 [_imageLoader stopLoadingImagesAndThumbnails];1007 [_imageLoader pauseLoadingImagesAndThumbnails]; 1008 1008 [_imageLoader startLoadingData]; 1009 1009 … … 1030 1030 [_saveProgressPanel close]; 1031 1031 1032 NSLog(@"returnCode = %d", returnCode); 1033 1034 if(returnCode != NSAlertDefaultReturn) { 1035 [_imageLoader stopLoadingData]; 1036 } 1037 1038 [_imageLoader startLoadingImages]; 1032 if(returnCode != NSAlertDefaultReturn) 1033 [_imageLoader pauseLoadingData]; 1034 1035 [_imageLoader startLoadingImageAtIndex:[self selectedIndex]]; 1039 1036 [_imageLoader startLoadingThumbnails]; 1040 1037 } Footagehead/trunk/FHImageLoader.h
r4868 r4875 40 40 NSUInteger _dataCounter; 41 41 42 BOOL _image Stop;43 BOOL _thumbnail Stop;44 BOOL _data Stop;42 BOOL _imagePause, _imageStop; 43 BOOL _thumbnailPause, _thumbnailStop; 44 BOOL _dataPause, _dataStop; 45 45 46 46 NSLock *_asynchronousLock; … … 79 79 - (void)startLoadingImages; 80 80 - (void)startLoadingThumbnails; 81 - (void)pauseLoadingImagesAndThumbnails; 81 82 - (void)stopLoadingImagesAndThumbnails; 82 83 - (void)startLoadingData; 84 - (void)pauseLoadingData; 83 85 - (void)stopLoadingData; 84 86 Footagehead/trunk/FHImageLoader.m
r4871 r4875 238 238 239 239 - (void)imageThread:(id)object { 240 NSAutoreleasePool *pool ;240 NSAutoreleasePool *pool, *loopPool; 241 241 NSArray *files; 242 242 FHFile *file; 243 243 NSUInteger i, count, index; 244 244 NSUInteger counter, lastCounter = 0; 245 BOOL stop;245 BOOL pause, stop; 246 246 247 247 [NSThread setThreadPriority:0.5]; … … 250 250 251 251 while(YES) { 252 if(!pool) 253 pool = [[NSAutoreleasePool alloc] init]; 252 loopPool = [[NSAutoreleasePool alloc] init]; 254 253 255 254 [_imageLock lockWhenCondition:1]; … … 299 298 if(counter != _imageCounter) 300 299 i = count; 300 pause = _imagePause; 301 _imagePause = NO; 301 302 stop = _imageStop; 302 303 [_imageLock unlockWithCondition:counter == _imageCounter ? 0 : 1]; 303 304 304 if( stop)305 if(pause || stop) 305 306 break; 306 307 } … … 309 310 } 310 311 311 [ pool release];312 pool = NULL;312 [loopPool release]; 313 loopPool = NULL; 313 314 314 315 if(stop) … … 328 329 WIURL *url; 329 330 NSUInteger i, count, counter, images; 330 BOOL stop;331 BOOL pause, stop; 331 332 332 333 [NSThread setThreadPriority:0.25]; … … 364 365 if(counter != _thumbnailCounter) 365 366 i = count; 367 pause = _thumbnailPause; 366 368 stop = _thumbnailStop; 367 369 [_thumbnailLock unlockWithCondition:counter == _thumbnailCounter ? 0 : 1]; 368 370 369 if( stop)371 if(pause || stop) 370 372 break; 371 373 } … … 385 387 386 388 - (void)dataThread:(id)sender { 387 NSAutoreleasePool *pool ;389 NSAutoreleasePool *pool, *loopPool; 388 390 NSArray *files; 389 391 FHFile *file; 390 392 NSUInteger i, count; 391 393 NSUInteger counter, lastCounter = 0; 392 BOOL stop;394 BOOL pause, stop; 393 395 394 396 [NSThread setThreadPriority:0.5]; … … 397 399 398 400 while(YES) { 399 if(!pool) 400 pool = [[NSAutoreleasePool alloc] init]; 401 loopPool = [[NSAutoreleasePool alloc] init]; 401 402 402 403 [_dataLock lockWhenCondition:1]; … … 421 422 if(counter != _dataCounter) 422 423 i = count; 424 pause = _dataPause; 425 _dataPause = NO; 423 426 stop = _dataStop; 424 427 [_dataLock unlockWithCondition:counter == _dataCounter ? 0 : 1]; 425 428 426 if( stop)429 if(pause || stop) 427 430 break; 428 431 } … … 430 433 lastCounter = counter; 431 434 432 [_notificationCenter mainThreadPostNotificationName:FHImageLoaderDidLoadAllFiles]; 435 if(!pause && !stop) 436 [_notificationCenter mainThreadPostNotificationName:FHImageLoaderDidLoadAllFiles]; 433 437 } 434 438 435 [ pool release];436 pool = NULL;439 [loopPool release]; 440 loopPool = NULL; 437 441 438 442 if(stop) … … 501 505 502 506 507 - (void)pauseLoadingImagesAndThumbnails { 508 [_imageLock lock]; 509 _imagePause = YES; 510 [_imageLock unlockWithCondition:0]; 511 512 [_thumbnailLock lock]; 513 _thumbnailPause = YES; 514 [_thumbnailLock unlockWithCondition:0]; 515 } 516 517 518 503 519 - (void)stopLoadingImagesAndThumbnails { 504 520 [_imageLock lock]; 505 521 _imageStop = YES; 506 [_imageLock unlockWithCondition: 1];522 [_imageLock unlockWithCondition:0]; 507 523 508 524 [_thumbnailLock lock]; 509 525 _thumbnailStop = YES; 510 [_thumbnailLock unlockWithCondition: 1];526 [_thumbnailLock unlockWithCondition:0]; 511 527 } 512 528 … … 521 537 522 538 539 - (void)pauseLoadingData { 540 [_dataLock lock]; 541 _dataPause = YES; 542 [_dataLock unlockWithCondition:0]; 543 } 544 545 546 523 547 - (void)stopLoadingData { 524 548 [_dataLock lock]; 525 549 _dataStop = YES; 526 [_dataLock unlockWithCondition: 1];550 [_dataLock unlockWithCondition:0]; 527 551 } 528 552
