mirror of
https://fastgit.cc/github.com/sourcegit-scm/sourcegit
synced 2026-04-25 11:24:02 +08:00
fix: crash when create image from a empty stream
This commit is contained in:
@@ -475,7 +475,7 @@ namespace SourceGit.ViewModels
|
||||
if (IMG_EXTS.Contains(ext))
|
||||
{
|
||||
var stream = Commands.QueryFileContent.Run(_repo, _commit.SHA, file.Path);
|
||||
var bitmap = stream != null ? new Bitmap(stream) : null as Bitmap;
|
||||
var bitmap = stream.Length > 0 ? new Bitmap(stream) : null;
|
||||
Dispatcher.UIThread.Invoke(() =>
|
||||
{
|
||||
ViewRevisionFileContent = new Models.RevisionImageFile() { Image = bitmap };
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace SourceGit.ViewModels
|
||||
private Bitmap BitmapFromRevisionFile(string repo, string revision, string file)
|
||||
{
|
||||
var stream = Commands.QueryFileContent.Run(repo, revision, file);
|
||||
return stream != null ? new Bitmap(stream) : null;
|
||||
return stream.Length > 0 ? new Bitmap(stream) : null;
|
||||
}
|
||||
|
||||
private static readonly HashSet<string> IMG_EXTS = new HashSet<string>()
|
||||
|
||||
Reference in New Issue
Block a user