Previewer Preview n links Fix
@@ -43,7 +43,7 @@ | ||
43 | 43 | { |
44 | 44 | NSString *urlString = [anURL absoluteString]; |
45 | 45 | if (!urlString) { |
46 | - ; | |
46 | + return; | |
47 | 47 | } |
48 | 48 | [[self boardWarriorSettingsDictionary] setObject:urlString forKey:kBWBBSMenuURLKey]; |
49 | 49 | } |
@@ -257,6 +257,6 @@ | ||
257 | 257 | [attachment_ observeIconToFinishDownload:self]; |
258 | 258 | } |
259 | 259 | } |
260 | - return attachment_; | |
260 | + return [attachment_ autorelease]; | |
261 | 261 | } |
262 | 262 | @end |
@@ -40,6 +40,10 @@ | ||
40 | 40 | NSMutableDictionary *m_toolbarItems; |
41 | 41 | NSTimer *m_fadeOutTimer; |
42 | 42 | id m_recoveringURLs; // NSURL or NSArray (of NSURLs) |
43 | + | |
44 | + // 遅延複数プレビュー用 | |
45 | + BOOL m_mp_isFirstFoundCache; | |
46 | + NSUInteger m_mp_newSelectedIndex; | |
43 | 47 | } |
44 | 48 | |
45 | 49 | // Content object for BSIPIArrayController. |
@@ -59,6 +59,9 @@ | ||
59 | 59 | [defaults addObserver:self forKeyPath:@"alphaValue" options:NSKeyValueObservingOptionNew context:kBSIPIDefaultsContext]; |
60 | 60 | [defaults addObserver:self forKeyPath:@"imageViewBgColorData" options:NSKeyValueObservingOptionNew context:kBSIPIDefaultsContext]; |
61 | 61 | [defaults addObserver:self forKeyPath:@"autoCollectImages" options:NSKeyValueObservingOptionNew context:kBSIPIDefaultsContext]; |
62 | + | |
63 | + m_mp_isFirstFoundCache = YES; | |
64 | + m_mp_newSelectedIndex = NSNotFound; | |
62 | 65 | } |
63 | 66 | return self; |
64 | 67 | } |
@@ -319,17 +322,26 @@ | ||
319 | 322 | return YES; |
320 | 323 | } |
321 | 324 | |
322 | -- (BOOL)previewLinksImpl:(NSArray *)urls | |
325 | +- (BOOL)previewLinksImpl:(NSDictionary *)contextInfo | |
323 | 326 | { |
324 | - [self showWindow:self]; | |
327 | + NSArray *urls = [contextInfo objectForKey:@"URLs"]; | |
328 | + NSUInteger contextNum = [[contextInfo objectForKey:@"ContextNumber"] unsignedIntegerValue]; | |
325 | 329 | |
330 | + if (contextNum == 0) { | |
331 | + [self showWindow:self]; | |
332 | + } | |
333 | + | |
326 | 334 | BSIPIArrayController *controller = [self tripleGreenCubes]; |
327 | 335 | |
328 | 336 | NSUInteger index = NSNotFound; |
329 | - NSUInteger tmpIndex = [controller countOfArrangedObjects]; | |
330 | - BOOL isFirst = YES; | |
331 | - | |
332 | - [controller setSelectsInsertedObjects:NO]; | |
337 | +// NSUInteger tmpIndex = [controller countOfArrangedObjects]; | |
338 | +// BOOL isFirst = YES; | |
339 | + | |
340 | + if (contextNum == 0) { | |
341 | + m_mp_isFirstFoundCache = YES; | |
342 | + m_mp_newSelectedIndex = [controller countOfArrangedObjects]; | |
343 | + [controller setSelectsInsertedObjects:NO]; | |
344 | + } | |
333 | 345 | for (NSURL *url in urls) { |
334 | 346 | index = [[self historyManager] cachedTokenIndexForURL:url]; |
335 | 347 | if (index == NSNotFound) { |
@@ -336,8 +348,10 @@ | ||
336 | 348 | NSError *error; |
337 | 349 | NSString *destinationPath = [[BSIPIDefaults sharedIPIDefaults] autoCollectImages] ? [[self historyManager] dlDateFolderPath:&error] : [[self historyManager] dlFolderPath:&error]; |
338 | 350 | if (!destinationPath && error) { |
339 | - [self setRecoveringURLs:urls]; | |
340 | - [self presentError:error modalForWindow:[self window] delegate:self didPresentSelector:@selector(didPresentPreviewErrorWithRecovery:contextInfo:) contextInfo:nil]; | |
351 | +// [self setRecoveringURLs:urls]; | |
352 | +// [self presentError:error modalForWindow:[self window] delegate:self didPresentSelector:@selector(didPresentPreviewErrorWithRecovery:contextInfo:) contextInfo:nil]; | |
353 | + // 後続の遅延プレビューもすべてキャンセル | |
354 | + [NSObject cancelPreviousPerformRequestsWithTarget:self]; | |
341 | 355 | return YES; |
342 | 356 | } |
343 | 357 | BSIPIToken *token = [[BSIPIToken alloc] initWithURL:url destination:destinationPath]; |
@@ -344,19 +358,48 @@ | ||
344 | 358 | [controller addObject:token]; |
345 | 359 | [token release]; |
346 | 360 | } else { |
347 | - if (isFirst) { | |
361 | +/* if (isFirst) { | |
348 | 362 | tmpIndex = index; |
349 | 363 | isFirst = NO; |
364 | + }*/ | |
365 | + if (m_mp_isFirstFoundCache) { | |
366 | + m_mp_newSelectedIndex = index; | |
367 | + m_mp_isFirstFoundCache = NO; | |
350 | 368 | } |
351 | 369 | } |
352 | 370 | } |
353 | - [controller setSelectionIndex:tmpIndex]; | |
354 | - [controller setSelectsInsertedObjects:YES]; | |
371 | + if (contextNum == 2) { | |
372 | +// [controller setSelectionIndex:tmpIndex]; | |
373 | + [controller setSelectionIndex:m_mp_newSelectedIndex]; | |
374 | + [controller setSelectsInsertedObjects:YES]; | |
375 | + } | |
355 | 376 | return YES; |
356 | 377 | } |
357 | 378 | |
379 | +- (BOOL)previewLinksBeforeCheck:(NSArray *)allURLs error:(NSError **)errorPtr | |
380 | +{ | |
381 | + NSUInteger index = NSNotFound; | |
382 | + for (NSURL *url in allURLs) { | |
383 | + index = [[self historyManager] cachedTokenIndexForURL:url]; | |
384 | + if (index == NSNotFound) { | |
385 | + NSString *destinationPath = [[BSIPIDefaults sharedIPIDefaults] autoCollectImages] ? [[self historyManager] dlDateFolderPath:errorPtr] : [[self historyManager] dlFolderPath:errorPtr]; | |
386 | + if (!destinationPath) { | |
387 | + return NO; | |
388 | + } | |
389 | + } | |
390 | + } | |
391 | + return YES; | |
392 | +} | |
393 | + | |
358 | 394 | - (BOOL)previewLinks:(NSArray *)urls |
359 | 395 | { |
396 | + NSError *error; | |
397 | + if (![self previewLinksBeforeCheck:urls error:&error] && error) { | |
398 | + [self setRecoveringURLs:urls]; | |
399 | + [self presentError:error modalForWindow:[self window] delegate:self didPresentSelector:@selector(didPresentPreviewErrorWithRecovery:contextInfo:) contextInfo:nil]; | |
400 | + return YES; | |
401 | + } | |
402 | + | |
360 | 403 | int division; |
361 | 404 | NSTimeInterval interval; |
362 | 405 |
@@ -377,11 +420,24 @@ | ||
377 | 420 | } |
378 | 421 | |
379 | 422 | int times = [urls count] / division; |
423 | + int moduro = [urls count] % division; | |
424 | + NSUInteger tmp = 0; | |
380 | 425 | for (int i = 0; i < times; i++) { |
381 | - [self performSelector:@selector(previewLinksImpl:) withObject:[urls subarrayWithRange:NSMakeRange(i * division, division)] afterDelay:(i * interval)]; | |
426 | + if (i == 0) { | |
427 | + tmp = 0; | |
428 | + } else if (i == (times - 1)) { | |
429 | + if (moduro == 0) { | |
430 | + tmp = 2; | |
431 | + } else { | |
432 | + tmp = 1; | |
433 | + } | |
434 | + } else { | |
435 | + tmp = 1; | |
436 | + } | |
437 | + [self performSelector:@selector(previewLinksImpl:) withObject:@{@"URLs": [urls subarrayWithRange:NSMakeRange(i * division, division)], @"ContextNumber": [NSNumber numberWithUnsignedInteger:tmp]} afterDelay:(i * interval)]; | |
382 | 438 | } |
383 | - if ([urls count] % division != 0) { | |
384 | - [self performSelector:@selector(previewLinksImpl:) withObject:[urls subarrayWithRange:NSMakeRange(times * division, ([urls count] % division))] afterDelay:(times * interval)]; | |
439 | + if (moduro != 0) { | |
440 | + [self performSelector:@selector(previewLinksImpl:) withObject:@{@"URLs": [urls subarrayWithRange:NSMakeRange(times * division, ([urls count] % division))], @"ContextNumber" : @2} afterDelay:(times * interval)]; | |
385 | 441 | } |
386 | 442 | return YES; |
387 | 443 | } |
@@ -23,7 +23,7 @@ | ||
23 | 23 | <key>CFBundleSignature</key> |
24 | 24 | <string>????</string> |
25 | 25 | <key>CFBundleVersion</key> |
26 | - <string>160</string> | |
26 | + <string>162</string> | |
27 | 27 | <key>NSHumanReadableCopyright</key> |
28 | 28 | <string>© 2005-2015 tsawada2 & BathyScaphe Project</string> |
29 | 29 | <key>NSMainNibFile</key> |
@@ -87,7 +87,7 @@ | ||
87 | 87 | </dict> |
88 | 88 | </array> |
89 | 89 | <key>CFBundleVersion</key> |
90 | - <string>771</string> | |
90 | + <string>772</string> | |
91 | 91 | <key>LSMinimumSystemVersion</key> |
92 | 92 | <string>10.7.5</string> |
93 | 93 | <key>NSAppleScriptEnabled</key> |
@@ -1,3 +1,12 @@ | ||
1 | +2015-02-26 tsawada2 <tsawada2@users.sourceforge.jp> | |
2 | + * application/source/manager/BSSSSPIconManager.m | |
3 | + * application/source/preferences/AppDefaults-BoardWarrior.m | |
4 | + * frameworks/SGAppKit/framework/src/extensions/image/NSImage-SGExtensions.m | |
5 | + メモリリークが発生する恐れがあった記述を修正。 | |
6 | + * application/subproj/BSLinkPreviewSelector/ja.lproj/BSPSPlugInPaneViewController.xib | |
7 | + nib の Deployment Target が 10.6 に指定されていたせいで不要なワーニングが出ていたのを修正。 | |
8 | + * application/subproj/previewer/BSImagePreviewInspector.m | |
9 | + 「n 個のリンクをプレビュー」の挙動を改善。 | |
1 | 10 | 2015-02-22 tsawada2 <tsawada2@users.sourceforge.jp> |
2 | 11 | * application/source/composer/CMXTextParser.m |
3 | 12 | open2ch のように、レスの投稿日時が半角スペースなしで表記されている場合のパースがうまくいかない問題を修正。 |
@@ -84,13 +84,12 @@ | ||
84 | 84 | }*/ |
85 | 85 | image_ = [[NSBundle applicationSpecificBundle] imageForResource:aName]; |
86 | 86 | if (search && !image_) { |
87 | - image_ = [[self imageNamed:aName] retain]; | |
87 | + image_ = [self imageNamed:aName]; | |
88 | 88 | } |
89 | 89 | if (!image_) { |
90 | 90 | return nil; |
91 | 91 | } |
92 | 92 | [userImageCache setObject:image_ forKey:aName]; |
93 | - [image_ release]; | |
94 | 93 | |
95 | 94 | return image_; |
96 | 95 | } |
@@ -21,7 +21,7 @@ | ||
21 | 21 | <key>CFBundleSignature</key> |
22 | 22 | <string>????</string> |
23 | 23 | <key>CFBundleVersion</key> |
24 | - <string>101</string> | |
24 | + <string>102</string> | |
25 | 25 | <key>NSHumanReadableCopyright</key> |
26 | 26 | <string>© 2005-2015 tsawada2 & BathyScaphe Project</string> |
27 | 27 | </dict> |