Skip to content

Commit

Permalink
Try to ensure longevity
Browse files Browse the repository at this point in the history
  • Loading branch information
IsaacMarovitz committed Jul 22, 2024
1 parent ae13f68 commit 0418c13
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
5 changes: 3 additions & 2 deletions src/SharpMetal/Metal/MTLDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ public partial struct MTLDevice: IDisposable
{
[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
private delegate void NewLibraryCompletionHandler(IntPtr block, IntPtr library, IntPtr error);
private NewLibraryCompletionHandler _handler;

public IntPtr NativePtr;
public static implicit operator IntPtr(MTLDevice obj) => obj.NativePtr;
Expand Down Expand Up @@ -468,8 +469,8 @@ public MTLLibrary NewLibrary(NSString source, MTLCompileOptions options, ref NSE

public void NewLibrary(NSString source, MTLCompileOptions options, Action<MTLLibrary, NSError> callback)
{
NewLibraryCompletionHandler handler = (_, library, error) => callback(new MTLLibrary(library), new NSError(error));
var block = Block.GetBlockForDelegate(handler);
_handler = (_, library, error) => callback(new MTLLibrary(library), new NSError(error));
var block = Block.GetBlockForDelegate(_handler);

ObjectiveCRuntime.objc_msgSend(NativePtr, sel_newLibraryWithSourceoptionscompletionHandler, source, options, block);
}
Expand Down
2 changes: 1 addition & 1 deletion src/SharpMetal/SharpMetal.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<AssemblyName>SharpMetal</AssemblyName>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<Version>1.0.0-preview16</Version>
<Version>1.0.0-preview17</Version>
<Description>Handcrafted Metal bindings for C#</Description>
<RepositoryUrl>https://github.com/IsaacMarovitz/SharpMetal</RepositoryUrl>
<RepositoryType>git</RepositoryType>
Expand Down

0 comments on commit 0418c13

Please sign in to comment.