Changeset 4868
- Timestamp:
- 08/21/07 17:38:21 (1 year ago)
- Files:
-
- Footagehead/trunk/English.lproj/Browser.nib/classes.nib (modified) (2 diffs)
- Footagehead/trunk/English.lproj/Browser.nib/info.nib (modified) (1 diff)
- Footagehead/trunk/English.lproj/Browser.nib/keyedobjects.nib (modified) (previous)
- Footagehead/trunk/English.lproj/MainMenu.nib/info.nib (modified) (2 diffs)
- Footagehead/trunk/English.lproj/MainMenu.nib/keyedobjects.nib (modified) (previous)
- Footagehead/trunk/English.lproj/MainMenu.nib/objects.nib (modified) (previous)
- Footagehead/trunk/FHBrowserController.h (modified) (3 diffs)
- Footagehead/trunk/FHBrowserController.m (modified) (7 diffs)
- Footagehead/trunk/FHFile.h (modified) (2 diffs)
- Footagehead/trunk/FHFile.m (modified) (1 diff)
- Footagehead/trunk/FHImageLoader.h (modified) (3 diffs)
- Footagehead/trunk/FHImageLoader.m (modified) (13 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
Footagehead/trunk/English.lproj/Browser.nib/classes.nib
r4725 r4868 2 2 IBClasses = ( 3 3 { 4 ACTIONS = { 5 autoSwitch = id; 6 firstFile = id; 7 lastFile = id; 8 nextImage = id; 9 nextPage = id; 10 openDirectory = id; 11 openFile = id; 12 openParent = id; 13 previousImage = id; 14 previousPage = id; 15 }; 4 ACTIONS = {autoSwitch = id; }; 16 5 CLASS = FHBrowserController; 17 6 LANGUAGE = ObjC; … … 28 17 "_rightStatusTextField" = NSTextField; 29 18 "_rightView" = NSView; 19 "_saveProgressIndicator" = NSProgressIndicator; 20 "_saveProgressPanel" = NSPanel; 21 "_saveProgressTextField" = NSTextField; 30 22 "_screenAutoSwitchButton" = NSButton; 31 23 "_screenAutoSwitchTextField" = NSTextField; Footagehead/trunk/English.lproj/Browser.nib/info.nib
r4727 r4868 4 4 <dict> 5 5 <key>IBDocumentLocation</key> 6 <string> 1075 123403 407 0 0 1920 1178 </string>6 <string>816 72 403 407 0 0 1920 1178 </string> 7 7 <key>IBFramework Version</key> 8 8 <string>446.1</string> 9 9 <key>IBOpenObjects</key> 10 10 <array> 11 <integer>7</integer> 11 12 <integer>65</integer> 12 13 <integer>52</integer> 13 <integer> 7</integer>14 <integer>160</integer> 14 15 <integer>82</integer> 15 16 </array> 16 17 <key>IBSystem Version</key> 17 <string>8 P135</string>18 <string>8R218</string> 18 19 </dict> 19 20 </plist> Footagehead/trunk/English.lproj/MainMenu.nib/info.nib
r4733 r4868 8 8 <dict> 9 9 <key>29</key> 10 <string> 433 614 400 44 0 0 1280 778 </string>10 <string>748 949 400 44 0 0 1920 1178 </string> 11 11 </dict> 12 12 <key>IBFramework Version</key> … … 19 19 </array> 20 20 <key>IBSystem Version</key> 21 <string>8 P2137</string>21 <string>8R218</string> 22 22 </dict> 23 23 </plist> Footagehead/trunk/FHBrowserController.h
r4726 r4868 51 51 IBOutlet NSPanel *_openSpotlightPanel; 52 52 IBOutlet NSTextView *_openSpotlightTextView; 53 54 IBOutlet NSPanel *_saveProgressPanel; 55 IBOutlet NSProgressIndicator *_saveProgressIndicator; 56 IBOutlet NSTextField *_saveProgressTextField; 53 57 54 58 IBOutlet NSPanel *_screenPanel; … … 69 73 BOOL _switchingURL; 70 74 NSInteger _previousRow; 75 NSUInteger _savedFiles; 71 76 } 72 77 … … 74 79 #define FHBrowserControllerDidLoadHandler @"FHBrowserControllerDidLoadHandler" 75 80 76 77 - (IBAction)openParent:(id)sender;78 - (IBAction)openFile:(id)sender;79 - (IBAction)openDirectory:(id)sender;80 81 81 82 - (IBAction)autoSwitch:(id)sender; Footagehead/trunk/FHBrowserController.m
r4858 r4868 429 429 imageLoader = [[FHImageLoader alloc] init]; 430 430 [self setImageLoader:imageLoader]; 431 431 432 [[_imageLoader notificationCenter] 433 addObserver:self 434 selector:@selector(imageLoaderWillLoadFile:) 435 name:FHImageLoaderWillLoadFile]; 436 437 [[_imageLoader notificationCenter] 438 addObserver:self 439 selector:@selector(imageLoaderReceivedFileData:) 440 name:FHImageLoaderReceivedFileData]; 441 432 442 [[_imageLoader notificationCenter] 433 443 addObserver:self 434 444 selector:@selector(imageLoaderDidLoadThumbnail:) 435 445 name:FHImageLoaderDidLoadThumbnail]; 446 447 [[_imageLoader notificationCenter] 448 addObserver:self 449 selector:@selector(imageLoaderDidLoadAllFiles:) 450 name:FHImageLoaderDidLoadAllFiles]; 436 451 437 452 [imageLoader release]; … … 447 462 [_handler release]; 448 463 449 [_imageLoader stopLoading ];464 [_imageLoader stopLoadingImagesAndThumbnails]; 450 465 451 466 [_toolbarItems release]; … … 604 619 605 620 621 - (void)imageLoaderWillLoadFile:(NSNotification *)notification { 622 FHFile *file; 623 624 file = [notification object]; 625 626 _savedFiles++; 627 628 [_saveProgressIndicator setIndeterminate:YES]; 629 [_saveProgressTextField setStringValue:[NSSWF:NSLS(@"%@, %u/%u%C", @"Save status (name, this file, remaining files, '...'"), 630 [file name], _savedFiles, [_handler numberOfFiles], 0x2026]]; 631 } 632 633 634 635 - (void)imageLoaderReceivedFileData:(NSNotification *)notification { 636 FHFile *file; 637 638 file = [notification object]; 639 640 [_saveProgressIndicator setIndeterminate:NO]; 641 [_saveProgressIndicator setDoubleValue:[file percentReceived]]; 642 [_saveProgressIndicator animate:self]; 643 } 644 645 646 606 647 - (void)imageLoaderDidLoadThumbnail:(NSNotification *)notification { 607 648 [_tableView reloadData]; 649 } 650 651 652 653 - (void)imageLoaderDidLoadAllFiles:(NSNotification *)notification { 654 [NSApp endSheet:_saveProgressPanel returnCode:NSAlertDefaultReturn]; 608 655 } 609 656 … … 852 899 853 900 854 - ( IBAction)openURL:(id)sender {901 - (void)openURL:(id)sender { 855 902 [_openURLTextView setSelectedRange:NSMakeRange(0, [[_openURLTextView string] length])]; 856 903 … … 903 950 904 951 905 #pragma mark - 906 907 - (IBAction)openParent:(id)sender { 908 NSString *name; 909 WIURL *url; 910 911 if([_handler hasParent]) { 912 url = [_handler parentURL]; 913 914 if(![url isEqual:[_handler URL]]) { 915 name = [[[_handler URL] path] lastPathComponent]; 952 - (void)saveDocument:(id)sender { 953 NSOpenPanel *openPanel; 954 NSString *path; 955 956 openPanel = [NSOpenPanel openPanel]; 957 [openPanel setTitle:NSLS(@"Select Directory", @"Save panel title")]; 958 [openPanel setPrompt:NSLS(@"Select", @"Save panel button")]; 959 [openPanel setCanChooseFiles:NO]; 960 [openPanel setCanChooseDirectories:YES]; 961 [openPanel setCanCreateDirectories:YES]; 962 963 if([openPanel runModalForTypes:nil] == NSFileHandlingPanelOKButton) { 964 path = [openPanel filename]; 965 966 [_imageLoader stopLoadingImagesAndThumbnails]; 967 [_imageLoader startLoadingData]; 968 969 [_saveProgressIndicator setDoubleValue:0.0]; 970 [_saveProgressTextField setStringValue:@""]; 971 972 _savedFiles = 0; 973 974 [NSApp beginSheet:_saveProgressPanel 975 modalForWindow:[self window] 976 modalDelegate:self 977 didEndSelector:@selector(saveProgressPanelDidEnd:returnCode:contextInfo:) 978 contextInfo:[path retain]]; 979 } 980 } 981 982 983 984 - (void)saveProgressPanelDidEnd:(NSOpenPanel *)sheet returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo { 985 NSArray *files; 986 NSString *path = contextInfo; 987 FHFile *file; 988 NSUInteger i, count; 989 990 [_saveProgressPanel close]; 991 992 if(returnCode == NSAlertDefaultReturn) { 993 files = [[self imageLoader] files]; 994 count = [files count]; 995 996 for(i = 0; i < count; i++) { 997 file = [files objectAtIndex:i]; 916 998 917 [self _loadURL:url selectName:name]; 999 if([file data]) { 1000 [[file data] writeToFile:[path stringByAppendingPathComponent:[[file path] lastPathComponent]] 1001 atomically:YES]; 1002 1003 [file setData:NULL]; 1004 } 918 1005 } 919 } 920 } 921 922 923 924 - (IBAction)openFile:(id)sender { 925 FHFile *file; 926 927 file = [self selectedFile]; 928 929 if([file isDirectory]) 930 [self _loadURL:[file URL]]; 931 else 932 [[NSWorkspace sharedWorkspace] openURL:[[file URL] URL]]; 933 } 934 935 936 937 - (IBAction)openDirectory:(id)sender { 938 FHFile *file; 939 940 file = [self selectedFile]; 941 942 if([file isDirectory]) 943 [self _loadURL:[file URL]]; 1006 } else { 1007 [_imageLoader stopLoadingData]; 1008 } 1009 1010 [_imageLoader startLoadingImages]; 1011 [_imageLoader startLoadingThumbnails]; 1012 1013 [path release]; 944 1014 } 945 1015 … … 1002 1072 1003 1073 [self showFile:[self selectedFile]]; 1074 1075 [self _updateLeftStatus]; 1004 1076 } 1005 1077 } … … 1096 1168 #pragma mark - 1097 1169 1170 - (void)openParent:(id)sender { 1171 NSString *name; 1172 WIURL *url; 1173 1174 if([_handler hasParent]) { 1175 url = [_handler parentURL]; 1176 1177 if(![url isEqual:[_handler URL]]) { 1178 name = [[[_handler URL] path] lastPathComponent]; 1179 1180 [self _loadURL:url selectName:name]; 1181 } 1182 } 1183 } 1184 1185 1186 1187 - (void)openFile:(id)sender { 1188 FHFile *file; 1189 1190 file = [self selectedFile]; 1191 1192 if([file isDirectory]) 1193 [self _loadURL:[file URL]]; 1194 else 1195 [[NSWorkspace sharedWorkspace] openURL:[[file URL] URL]]; 1196 } 1197 1198 1199 1200 - (void)openDirectory:(id)sender { 1201 FHFile *file; 1202 1203 file = [self selectedFile]; 1204 1205 if([file isDirectory]) 1206 [self _loadURL:[file URL]]; 1207 } 1208 1209 1210 1211 #pragma mark - 1212 1098 1213 - (void)loadURL:(WIURL *)url { 1099 1214 NSString *name; Footagehead/trunk/FHFile.h
r4726 r4868 37 37 FHImage *_icon; 38 38 FHImage *_thumbnail; 39 NSData *_data; 39 40 BOOL _loaded; 40 41 double _percentReceived; … … 53 54 - (void)setThumbnail:(FHImage *)thumbnail; 54 55 - (FHImage *)thumbnail; 56 - (void)setData:(NSData *)data; 57 - (NSData *)data; 55 58 - (void)setLoaded:(BOOL)loaded; 56 59 - (BOOL)isLoaded; Footagehead/trunk/FHFile.m
r4726 r4868 125 125 126 126 127 - (void)setData:(NSData *)data { 128 [data retain]; 129 [_data release]; 130 131 _data = data; 132 } 133 134 135 136 - (NSData *)data { 137 return _data; 138 } 139 140 141 127 142 - (void)setLoaded:(BOOL)loaded { 128 143 _loaded = loaded; Footagehead/trunk/FHImageLoader.h
r4726 r4868 34 34 NSConditionLock *_imageLock; 35 35 NSConditionLock *_thumbnailLock; 36 NSConditionLock *_dataLock; 36 37 37 38 NSUInteger _imageCounter; 38 39 NSUInteger _thumbnailCounter; 39 40 NSMutableData *_asynchronousData; 41 FHFile *_asynchronousFile; 42 long long _asynchronousLength; 43 BOOL _asynchronousDone; 40 NSUInteger _dataCounter; 44 41 45 42 BOOL _imageStop; 46 43 BOOL _thumbnailStop; 44 BOOL _dataStop; 45 46 NSLock *_asynchronousLock; 47 NSMutableData *_asynchronousData; 48 FHFile *_asynchronousFile; 49 NSMutableURLRequest *_asynchronousRequest; 50 long long _asynchronousLength; 51 BOOL _asynchronousImages; 52 BOOL _asynchronousDone; 47 53 48 54 NSArray *_files; … … 53 59 54 60 61 #define FHImageLoaderWillLoadImage @"FHImageLoaderWillLoadImage" 62 #define FHImageLoaderWillLoadFile @"FHImageLoaderWillLoadFile" 63 55 64 #define FHImageLoaderReceivedImageData @"FHImageLoaderReceivedImageData" 65 #define FHImageLoaderReceivedFileData @"FHImageLoaderReceivedFileData" 56 66 57 67 #define FHImageLoaderDidLoadImage @"FHImageLoaderDidLoadImage" 58 68 #define FHImageLoaderDidLoadThumbnail @"FHImageLoaderDidLoadThumbnail" 69 #define FHImageLoaderDidLoadFile @"FHImageLoaderDidLoadFile" 70 #define FHImageLoaderDidLoadAllFiles @"FHImageLoaderDidLoadAllFiles" 59 71 60 72 … … 67 79 - (void)startLoadingImages; 68 80 - (void)startLoadingThumbnails; 69 - (void)stopLoading; 81 - (void)stopLoadingImagesAndThumbnails; 82 - (void)startLoadingData; 83 - (void)stopLoadingData; 70 84 71 85 @end Footagehead/trunk/FHImageLoader.m
r4732 r4868 34 34 #define FHImagesToKeepBehind 2 35 35 36 @interface FHImageLoader(Private) 37 38 - (void)_asynchronouslyLoadDataForFile:(FHFile *)file; 39 - (void)_loadDataForFile:(FHFile *)file; 40 - (void)_loadImageForFile:(FHFile *)file; 41 42 @end 43 44 45 @implementation FHImageLoader(Private) 46 47 - (void)_asynchronouslyLoadDataForFile:(FHFile *)file { 48 NSURLConnection *connection; 49 WIURL *url; 50 51 url = [file URL]; 52 53 [_asynchronousRequest setURL:[url URL]]; 54 [_asynchronousRequest setValue:[[url URLByDeletingLastPathComponent] string] forHTTPHeaderField:@"Referer"]; 55 56 connection = [NSURLConnection connectionWithRequest:_asynchronousRequest delegate:self]; 57 58 _asynchronousDone = NO; 59 _asynchronousFile = file; 60 [_asynchronousData setLength:0]; 61 62 do { 63 [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode 64 beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.2]]; 65 } while(!_asynchronousDone); 66 } 67 68 69 70 - (void)_loadDataForFile:(FHFile *)file { 71 NSData *data; 72 WIURL *url; 73 74 [_notificationCenter mainThreadPostNotificationName:FHImageLoaderWillLoadFile object:file]; 75 76 url = [file URL]; 77 78 if([url isFileURL]) { 79 data = [[NSData alloc] initWithContentsOfFile:[url path]]; 80 [file setData:data]; 81 [data release]; 82 } else { 83 [_asynchronousLock lock]; 84 85 _asynchronousImages = NO; 86 87 [self _asynchronouslyLoadDataForFile:file]; 88 89 [file setData:_asynchronousData]; 90 91 [_asynchronousData release]; 92 _asynchronousData = [[NSMutableData alloc] init]; 93 94 [_asynchronousLock unlock]; 95 } 96 97 [_notificationCenter mainThreadPostNotificationName:FHImageLoaderDidLoadFile object:file]; 98 } 99 100 101 102 - (void)_loadImageForFile:(FHFile *)file { 103 NSData *data; 104 WIURL *url; 105 FHImage *image, *thumbnail; 106 107 [_notificationCenter mainThreadPostNotificationName:FHImageLoaderWillLoadImage object:file]; 108 109 url = [file URL]; 110 111 if([url isFileURL]) { 112 data = [[NSData alloc] initWithContentsOfFile:[url path]]; 113 image = [[FHImage alloc] initImageWithData:data]; 114 thumbnail = NULL; 115 [data release]; 116 } else { 117 [_asynchronousLock lock]; 118 119 _asynchronousImages = YES; 120 121 [self _asynchronouslyLoadDataForFile:file]; 122 123 image = [[FHImage alloc] initImageWithData:_asynchronousData]; 124 thumbnail = [[FHCache cache] thumbnailForURL:url withData:_asynchronousData]; 125 126 [_asynchronousData setLength:0]; 127 [_asynchronousLock unlock]; 128 } 129 130 [file setImage:image]; 131 [file setLoaded:YES]; 132 _pixels += [image pixels]; 133 [image release]; 134 135 [_notificationCenter mainThreadPostNotificationName:FHImageLoaderDidLoadImage object:file]; 136 137 if(thumbnail) { 138 [file setThumbnail:thumbnail]; 139 140 [_notificationCenter mainThreadPostNotificationName:FHImageLoaderDidLoadThumbnail object:file]; 141 } 142 } 143 144 @end 145 146 147 36 148 @implementation FHImageLoader 37 149 … … 39 151 self = [super init]; 40 152 41 _notificationCenter = [[NSNotificationCenter alloc] init]; 42 43 _imageLock = [[NSConditionLock alloc] initWithCondition:0]; 44 _thumbnailLock = [[NSConditionLock alloc] initWithCondition:0]; 45 46 _asynchronousData = [[NSMutableData alloc] init]; 47 48 _maxPixels = ((double) [[NSProcessInfo processInfo] amountOfMemory] / 10) / 5; 153 _notificationCenter = [[NSNotificationCenter alloc] init]; 154 155 _imageLock = [[NSConditionLock alloc] initWithCondition:0]; 156 _thumbnailLock = [[NSConditionLock alloc] initWithCondition:0]; 157 _dataLock = [[NSConditionLock alloc] initWithCondition:0]; 158 159 _asynchronousLock = [[NSLock alloc] init]; 160 _asynchronousData = [[NSMutableData alloc] init]; 161 162 _asynchronousRequest = [[NSMutableURLRequest alloc] init]; 163 164 #ifdef DEBUG 165 [_asynchronousRequest setCachePolicy:NSURLRequestReloadIgnoringCacheData]; 166 #endif 167 168 _maxPixels = ((double) [[NSProcessInfo processInfo] amountOfMemory] / 10) / 5; 49 169 50 170 [NSThread detachNewThreadSelector:@selector(imageThread:) toTarget:self withObject:NULL]; 51 171 [NSThread detachNewThreadSelector:@selector(thumbnailsThread:) toTarget:self withObject:NULL]; 172 [NSThread detachNewThreadSelector:@selector(dataThread:) toTarget:self withObject:NULL]; 52 173 53 174 [NSThread setThreadPriority:0.75]; … … 63 184 [_imageLock release]; 64 185 [_thumbnailLock release]; 186 [_dataLock release]; 65 187 66 188 [_asynchronousData release]; 189 [_asynchronousLock release]; 67 190 68 191 [super dealloc]; … … 80 203 81 204 - (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data { 205 NSString *notification; 82 206 double percent; 83 207 … … 90 214 [_asynchronousFile setPercentReceived:percent]; 91 215 92 [_notificationCenter mainThreadPostNotificationName:FHImageLoaderReceivedImageData 93 object:_asynchronousFile]; 216 notification = _asynchronousImages ? FHImageLoaderReceivedImageData : FHImageLoaderReceivedFileData; 217 218 [_notificationCenter mainThreadPostNotificationName:notification object:_asynchronousFile]; 94 219 } 95 220 } … … 115 240 NSAutoreleasePool *pool; 116 241 NSArray *files; 117 NSData *data;118 NSURLConnection *connection;119 NSMutableURLRequest *request;120 WIURL *url;121 FHImage *image;122 242 FHFile *file; 123 243 NSUInteger i, count, index; … … 128 248 129 249 pool = [[NSAutoreleasePool alloc] init]; 130 request = [[NSMutableURLRequest alloc] init];131 250 132 251 while(YES) { … … 170 289 file = [files objectAtIndex:i]; 171 290 172 if([file isDirectory]) 173 goto next; 174 175 if([file image]) 176 goto next; 177 178 if(i > index + 1 && _pixels >= _maxPixels) 179 break; 180 181 url = [file URL]; 182 183 if([url isFileURL]) { 184 data = [NSData dataWithContentsOfFile:[url path]]; 185 } else { 186 [request setURL:[url URL]]; 187 [request setValue:[[url URLByDeletingLastPathComponent] string] forHTTPHeaderField:@"Referer"]; 188 189 connection = [NSURLConnection connectionWithRequest:request delegate:self]; 190 191 _asynchronousDone = NO; 192 _asynchronousFile = file; 193 [_asynchronousData setLength:0]; 194 195 do { 196 [[NSRunLoop currentRunLoop] runMode:NSDefaultRunLoopMode 197 beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.2]]; 198 } while(!_asynchronousDone); 199 200 data = _asynchronousData; 291 if(![file isDirectory] && ![file image]) { 292 if(i > index + 1 && _pixels >= _maxPixels) 293 break; 294 295 [self _loadImageForFile:file]; 201 296 } 202 203 image = [[FHImage alloc] initImageWithData:data]; 204 [file setImage:image]; 205 [file setLoaded:YES]; 206 _pixels += [image pixels]; 207 [image release]; 208 209 [_notificationCenter mainThreadPostNotificationName:FHImageLoaderDidLoadImage object:file]; 210 211 if([_asynchronousData length] > 0) { 212 image = [[FHCache cache] thumbnailForURL:url withData:data]; 213 214 if(image) { 215 [file setThumbnail:image]; 216 217 [_notificationCenter mainThreadPostNotificationName:FHImageLoaderDidLoadThumbnail object:file]; 218 } 219 220 [_asynchronousData setLength:0]; 221 } 222 223 next: 297 224 298 [_imageLock lock]; 225 299 if(counter != _imageCounter) … … 242 316 } 243 317 244 [request release];245 318 [pool release]; 246 319 } … … 275 348 for(i = images = 0; i < count; i++) { 276 349 file = [files objectAtIndex:i]; 277 278 if([file isDirectory] || [file thumbnail])279 goto next;280 281 350 url = [file URL]; 282 351 283 if(![url isFileURL]) 284 goto next; 285 286 image = [[FHCache cache] thumbnailForURL:url]; 287 288 if(image) { 289 [file setThumbnail:image]; 290 291 [_notificationCenter mainThreadPostNotificationName:FHImageLoaderDidLoadThumbnail object:file]; 352 if(![file isDirectory] && ![file thumbnail] && [url isFileURL]) { 353 image = [[FHCache cache] thumbnailForURL:url]; 354 355 if(image) { 356 [file setThumbnail:image]; 357 358 [_notificationCenter mainThreadPostNotificationName:FHImageLoaderDidLoadThumbnail object:file]; 359 } 292 360 } 293 294 next: 361 295 362 if(++images % 5 == 0) { 296 363 [_thumbnailLock lock]; … … 317 384 318 385 386 - (void)dataThread:(id)sender { 387 NSAutoreleasePool *pool; 388 NSArray *files; 389 FHFile *file; 390 NSUInteger i, count; 391 NSUInteger counter, lastCounter = 0; 392 BOOL stop; 393 394 [NSThread setThreadPriority:0.5]; 395 396 pool = [[NSAutoreleasePool alloc] init]; 397 398 while(YES) { 399 if(!pool) 400 pool = [[NSAutoreleasePool alloc] init]; 401 402 [_dataLock lockWhenCondition:1]; 403 files = [[_files retain] autorelease]; 404 counter = _dataCounter; 405 stop = _dataStop; 406 [_dataLock unlockWithCondition:0]; 407 408 if(stop) 409 break; 410 411 if(counter != lastCounter) { 412 count = [files count]; 413 414 for(i = 0; i < count; i++) { 415 file = [files objectAtIndex:i]; 416 417 if(![file isDirectory] && ![file data]) 418 [self _loadDataForFile:file]; 419 420 [_dataLock lock]; 421 if(counter != _dataCounter) 422 i = count; 423 stop = _dataStop; 424 [_dataLock unlockWithCondition:counter == _dataCounter ? 0 : 1]; 425 426 if(stop) 427 break; 428 } 429 430 lastCounter = counter; 431 432 [_notificationCenter mainThreadPostNotificationName:FHImageLoaderDidLoadAllFiles]; 433 } 434 435 [pool release]; 436 pool = NULL; 437 438 if(stop) 439 break; 440 } 441 442 [pool release]; 443 } 444 445 446 319 447 #pragma mark - 320 448 … … 373 501 374 502 375 - (void)stopLoading {503 - (void)stopLoadingImagesAndThumbnails { 376 504 [_imageLock lock]; 377 505 _imageStop = YES; … … 383 511 } 384 512 513 514 515 - (void)startLoadingData { 516 [_dataLock lock]; 517 _dataCounter++; 518 [_dataLock unlockWithCondition:1]; 519 } 520 521 522 523 - (void)stopLoadingData { 524 [_dataLock lock]; 525 _dataStop = YES; 526 [_dataLock unlockWithCondition:1]; 527 } 528 385 529 @end
