Dispose Image only when not needed for preview

This commit is contained in:
Charles Milette 2018-10-01 18:37:13 -04:00
parent 12d5010769
commit 7e7aeb44c2
No known key found for this signature in database
GPG key ID: 1A5AE81377AD973A

View file

@ -304,14 +304,9 @@ private void ThreadDoWork()
}
finally
{
bool hasFile = !string.IsNullOrEmpty(Info.FilePath) && File.Exists(Info.FilePath);
Dispose(!(Info.DataType == EDataType.Image && Info.TaskSettings.GeneralSettings.PopUpNotification == PopUpNotificationType.ToastNotification));
if (hasFile || Info.DataType != EDataType.Image)
{
Dispose();
}
if (Info.Job == TaskJob.Job && Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.DeleteFile) && hasFile)
if (Info.Job == TaskJob.Job && Info.TaskSettings.AfterCaptureJob.HasFlag(AfterCaptureTasks.DeleteFile) && !string.IsNullOrEmpty(Info.FilePath) && File.Exists(Info.FilePath))
{
File.Delete(Info.FilePath);
}
@ -1117,7 +1112,7 @@ private void OnUploadersConfigWindowRequested(IUploaderService uploaderService)
}
}
public void Dispose()
private void Dispose(bool shouldDisposeImage)
{
if (Data != null)
{
@ -1125,11 +1120,16 @@ public void Dispose()
Data = null;
}
if (Image != null)
if (Image != null && shouldDisposeImage)
{
Image.Dispose();
Image = null;
}
}
public void Dispose()
{
Dispose(true);
}
}
}