Skip to content

Commit

Permalink
Try to fix progress reporting
Browse files Browse the repository at this point in the history
  • Loading branch information
kleisauke committed May 9, 2024
1 parent 4fba0cf commit 32de520
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
8 changes: 4 additions & 4 deletions src/NetVips/Image.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public partial class Image : VipsObject
/// Internal marshaller delegate for <see cref="EvalDelegate"/>.
/// </summary>
[SuppressUnmanagedCodeSecurity, UnmanagedFunctionPointer(CallingConvention.Cdecl)]
internal delegate void EvalMarshalDelegate(IntPtr imagePtr, VipsProgress progress, IntPtr userDataPtr);
internal delegate void EvalMarshalDelegate(IntPtr imagePtr, IntPtr progress, IntPtr userDataPtr);

/// <inheritdoc cref="VipsObject"/>
internal Image(IntPtr pointer)
Expand Down Expand Up @@ -2103,17 +2103,17 @@ public void SetKill(bool kill)
/// <exception cref="T:System.ArgumentException">If it failed to connect the signal.</exception>
public ulong SignalConnect(Enums.Signals signal, EvalDelegate callback, IntPtr data = default)
{
void EvalMarshal(IntPtr imagePtr, VipsProgress progress, IntPtr userDataPtr)
void EvalMarshal(IntPtr imagePtr, IntPtr progress, IntPtr userDataPtr)
{
if (imagePtr == IntPtr.Zero)
if (imagePtr == IntPtr.Zero || progress == IntPtr.Zero)
{
return;
}

using var image = new Image(imagePtr);
image.ObjectRef();

callback.Invoke(image, progress);
callback.Invoke(image, Marshal.PtrToStructure<VipsProgress>(progress));
}

switch (signal)
Expand Down
10 changes: 8 additions & 2 deletions src/NetVips/VipsProgress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public struct GTimer
/// <summary>
/// Is the timer currently active?
/// </summary>
public int Active;
[MarshalAs(UnmanagedType.I1)]
public bool Active;
}

/// <summary>
Expand Down Expand Up @@ -65,6 +66,11 @@ public struct VipsProgress
/// <summary>
/// Start time.
/// </summary>
public GTimer Start;
private IntPtr StartPtr;

/// <summary>
/// Start time.
/// </summary>
public GTimer Start => Marshal.PtrToStructure<GTimer>(StartPtr);
}
}

0 comments on commit 32de520

Please sign in to comment.