GUI: Don't lose status handler on multi-image binaries / improve status output

This commit is contained in:
Katy Coe
2020-08-07 19:08:07 +02:00
parent 58cd9abe02
commit 7086a8f7ba
5 changed files with 20 additions and 15 deletions

View File

@@ -52,7 +52,7 @@ namespace Il2CppInspector
U ReadObject<U>() where U : new();
string ReadMappedNullTerminatedString(ulong uiAddr);
List<U> ReadMappedObjectPointerArray<U>(ulong uiAddr, int count) where U : new();
event EventHandler<string> OnStatusUpdate;
EventHandler<string> OnStatusUpdate { get; set; }
}
public class FileFormatReader
@@ -99,7 +99,7 @@ namespace Il2CppInspector
public virtual int Bits => throw new NotImplementedException();
public event EventHandler<string> OnStatusUpdate;
public EventHandler<string> OnStatusUpdate { get; set; }
protected void StatusUpdate(string status) => OnStatusUpdate?.Invoke(this, status);
@@ -118,7 +118,9 @@ namespace Il2CppInspector
public static T Load(Stream stream, EventHandler<string> statusCallback = null) {
// Copy the original stream in case we modify it
var ms = new MemoryStream();
stream.Position = 0;
if (stream.CanSeek)
stream.Position = 0;
stream.CopyTo(ms);
ms.Position = 0;
@@ -127,7 +129,7 @@ namespace Il2CppInspector
}
private bool InitImpl(EventHandler<string> statusCallback = null) {
OnStatusUpdate += statusCallback;
OnStatusUpdate = statusCallback;
return Init();
}