Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions Regift/Regift.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,14 +293,11 @@ public struct Regift {

// Create a dispatch group to force synchronous behavior on an asynchronous method.
let gifGroup = Group()
var dispatchError: Bool = false
gifGroup.enter()

generator.generateCGImagesAsynchronously(forTimes: times, completionHandler: { (requestedTime, image, actualTime, result, error) in
guard let imageRef = image , error == nil else {
print("An error occurred: \(error), image is \(image)")
dispatchError = true
gifGroup.leave()

@nakajijapan nakajijapan Oct 29, 2017

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that gifGroup.leave()'s position isn't good. In this case, leave is called only if an error doesn't occur. We should call leave every cases.

return
}

Expand All @@ -313,11 +310,6 @@ public struct Regift {

// Wait for the asynchronous generator to finish.
gifGroup.wait()

// If there was an error in the generator, throw the error.
if dispatchError {
throw RegiftError.AddFrameToDestination
}

CGImageDestinationSetProperties(destination, fileProperties as CFDictionary)

Expand Down