Skip to content

Commit

Permalink
Only remove the callback value from our shared array when the last ex…
Browse files Browse the repository at this point in the history
…ntesionLevel has been processed
  • Loading branch information
migueldeicaza committed Jun 16, 2024
1 parent 9ef16a2 commit 522cd18
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion Sources/SwiftGodot/EntryPoint.swift
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,13 @@ func extension_deinitialize (userData: UnsafeMutableRawPointer?, l: GDExtensionI
//print ("SWIFT: extension_deinitialize")
guard let userData else { return }
let key = OpaquePointer(userData)
guard let callback = extensionDeInitCallbacks.removeValue(forKey: key) else { return }
guard let callback = extensionDeInitCallbacks [key] else { return }
guard let level = GDExtension.InitializationLevel(rawValue: Int64 (exactly: l.rawValue)!) else { return }
callback (level)
if level == .core {
// Last one, remove
extensionDeInitCallbacks.removeValue(forKey: key)
}
}

/// Error types returned by Godot when invoking a method
Expand Down

0 comments on commit 522cd18

Please sign in to comment.