- (void)registerScreenshot:(NSBitmapImageRep *)image fromOnScreen:(NSRect)screenRect
{
- NSData *imageData = [image representationUsingType:NSJPEGFileType properties:nil];
-
- NSBundle *mainBundle = [NSBundle mainBundle];
- NSDictionary *infoList = [mainBundle localizedInfoDictionary];
- NSString *filename = [infoList objectForKey:@"CFBundleName"];
- if([filename length] == 0) {
- filename = @"KCD";
- }
- filename = [filename stringByAppendingPathExtension:@"jpg"];
- NSString *path = [[self screenshotSaveDirectoryPath] stringByAppendingPathComponent:filename];
- path = [[NSFileManager defaultManager] _web_pathWithUniqueFilenameForPath:path];
-
- [imageData writeToFile:path atomically:YES];
- HMScreenshotInformation *info = [HMScreenshotInformation new];
- info.path = path;
- info.version = [self cacheVersionForPath:path];
-
- [self.screenshotsController insertObject:info atArrangedObjectIndex:0];
- self.screenshotsController.selectedObjects = @[info];
-
- if(HMStandardDefaults.showsListWindowAtScreenshot) {
- [self.window makeKeyAndOrderFront:nil];
- }
+ dispatch_queue_t queue = dispatch_queue_create("Screenshot queue", DISPATCH_QUEUE_SERIAL);
+ dispatch_async(queue, ^{
+ NSDate *date00 = [NSDate dateWithTimeIntervalSinceNow:0.0];
+
+ NSData *imageData = [image representationUsingType:NSJPEGFileType properties:@{}];
+
+ NSBundle *mainBundle = [NSBundle mainBundle];
+ NSDictionary *infoList = [mainBundle localizedInfoDictionary];
+ NSString *filename = [infoList objectForKey:@"CFBundleName"];
+ if([filename length] == 0) {
+ filename = @"KCD";
+ }
+ filename = [filename stringByAppendingPathExtension:@"jpg"];
+ NSString *path = [[self screenshotSaveDirectoryPath] stringByAppendingPathComponent:filename];
+
+ NSDate *date01 = [NSDate dateWithTimeIntervalSinceNow:0.0];
+
+ path = [[NSFileManager defaultManager] _web_pathWithUniqueFilenameForPath:path];
+
+ NSDate *date02 = [NSDate dateWithTimeIntervalSinceNow:0.0];
+
+ [imageData writeToFile:path atomically:YES];
+
+ NSDate *date03 = [NSDate dateWithTimeIntervalSinceNow:0.0];
+
+ HMScreenshotInformation *info = [HMScreenshotInformation new];
+ info.path = path;
+ info.version = [self cacheVersionForPath:path];
+
+ [self.screenshotsController insertObject:info atArrangedObjectIndex:0];
+ self.screenshotsController.selectedObjects = @[info];
+
+ if(HMStandardDefaults.showsListWindowAtScreenshot) {
+ [self.window makeKeyAndOrderFront:nil];
+ }
+
+ NSDate *date04 = [NSDate dateWithTimeIntervalSinceNow:0.0];
+
+ NSLog(@"01 -> %lf\n02 -> %lf\n03 -> %lf\n04 -> %lf",
+ [date01 timeIntervalSinceDate:date00],
+ [date02 timeIntervalSinceDate:date01],
+ [date03 timeIntervalSinceDate:date02],
+ [date04 timeIntervalSinceDate:date03]
+ );
+
+ });
}
- (void)incrementCacheVersionForPath:(NSString *)fullpath