mirror of
https://github.com/DarthAffe/StableDiffusion.NET.git
synced 2025-12-13 05:48:40 +00:00
Prevented possible collection of the callback delegates and the resulting crash
This commit is contained in:
parent
631c8ca180
commit
e2015e7724
@ -7,6 +7,11 @@ public sealed unsafe class StableDiffusionModel : IDisposable
|
|||||||
{
|
{
|
||||||
#region Properties & Fields
|
#region Properties & Fields
|
||||||
|
|
||||||
|
// ReSharper disable NotAccessedField.Local - They are important, the delegate can be collected if it's not stored!
|
||||||
|
private static readonly Native.sd_log_cb_t LOG_CALLBACK;
|
||||||
|
private static readonly Native.sd_progress_cb_t PROGRESS_CALLBACK;
|
||||||
|
// ReSharper restore NotAccessedField.Local
|
||||||
|
|
||||||
private bool _disposed;
|
private bool _disposed;
|
||||||
|
|
||||||
private readonly string _modelPath;
|
private readonly string _modelPath;
|
||||||
@ -29,8 +34,8 @@ public sealed unsafe class StableDiffusionModel : IDisposable
|
|||||||
|
|
||||||
static StableDiffusionModel()
|
static StableDiffusionModel()
|
||||||
{
|
{
|
||||||
Native.sd_set_log_callback(OnNativeLog, null);
|
Native.sd_set_log_callback(LOG_CALLBACK = OnNativeLog, null);
|
||||||
Native.sd_set_progress_callback(OnNativeProgress, null);
|
Native.sd_set_progress_callback(PROGRESS_CALLBACK = OnNativeProgress, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public StableDiffusionModel(string modelPath, ModelParameter parameter, UpscalerModelParameter? upscalerParameter = null)
|
public StableDiffusionModel(string modelPath, ModelParameter parameter, UpscalerModelParameter? upscalerParameter = null)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user