From d873f21b6a3a5187105cfac4bbc06eda95708957 Mon Sep 17 00:00:00 2001 From: leo Date: Sat, 6 Apr 2024 15:01:07 +0800 Subject: [PATCH] fix: crash when open external tool drop down menu --- src/Models/ExternalEditor.cs | 5 ++--- src/Native/Linux.cs | 6 +++--- src/Native/MacOS.cs | 6 +++--- src/Native/Windows.cs | 6 +++--- src/ViewModels/Repository.cs | 2 +- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/Models/ExternalEditor.cs b/src/Models/ExternalEditor.cs index 8ae16132..1fab67d8 100644 --- a/src/Models/ExternalEditor.cs +++ b/src/Models/ExternalEditor.cs @@ -1,12 +1,11 @@ -using System; -using System.Diagnostics; +using System.Diagnostics; namespace SourceGit.Models { public class ExternalEditor { public string Name { get; set; } = string.Empty; - public Uri Icon { get; set; } = null; + public string Icon { get; set; } = string.Empty; public string Executable { get; set; } = string.Empty; public string OpenCmdArgs { get; set; } = string.Empty; diff --git a/src/Native/Linux.cs b/src/Native/Linux.cs index 5b7c02e8..dd31e0c8 100644 --- a/src/Native/Linux.cs +++ b/src/Native/Linux.cs @@ -41,7 +41,7 @@ namespace SourceGit.Native editors.Add(new Models.ExternalEditor { Name = "Visual Studio Code", - Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/vscode.png", UriKind.Absolute), + Icon = "vscode.png", Executable = vscode, OpenCmdArgs = "\"{0}\"", }); @@ -53,7 +53,7 @@ namespace SourceGit.Native editors.Add(new Models.ExternalEditor { Name = "Visual Studio Code - Insiders", - Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/vscode_insiders.png", UriKind.Absolute), + Icon = "vscode_insiders.png", Executable = vscodeInsiders, OpenCmdArgs = "\"{0}\"", }); @@ -65,7 +65,7 @@ namespace SourceGit.Native editors.Add(new Models.ExternalEditor { Name = "JetBrains Fleet", - Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/fleet.png", UriKind.Absolute), + Icon = "fleet.png", Executable = fleet, OpenCmdArgs = "\"{0}\"", }); diff --git a/src/Native/MacOS.cs b/src/Native/MacOS.cs index bc632ca1..ab9bc992 100644 --- a/src/Native/MacOS.cs +++ b/src/Native/MacOS.cs @@ -38,7 +38,7 @@ namespace SourceGit.Native editors.Add(new Models.ExternalEditor { Name = "Visual Studio Code", - Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/vscode.png", UriKind.Absolute), + Icon = "vscode.png", Executable = vscode, OpenCmdArgs = "\"{0}\"", }); @@ -50,7 +50,7 @@ namespace SourceGit.Native editors.Add(new Models.ExternalEditor { Name = "Visual Studio Code - Insiders", - Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/vscode_insiders.png", UriKind.Absolute), + Icon = "vscode_insiders.png", Executable = vscodeInsiders, OpenCmdArgs = "\"{0}\"", }); @@ -62,7 +62,7 @@ namespace SourceGit.Native editors.Add(new Models.ExternalEditor { Name = "JetBrains Fleet", - Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/fleet.png", UriKind.Absolute), + Icon = "fleet.png", Executable = fleet, OpenCmdArgs = "\"{0}\"", }); diff --git a/src/Native/Windows.cs b/src/Native/Windows.cs index 829f85c7..f91a6da5 100644 --- a/src/Native/Windows.cs +++ b/src/Native/Windows.cs @@ -124,7 +124,7 @@ namespace SourceGit.Native editors.Add(new Models.ExternalEditor { Name = "Visual Studio Code", - Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/vscode.png", UriKind.Absolute), + Icon = "vscode.png", Executable = vscode, OpenCmdArgs = "\"{0}\"", }); @@ -136,7 +136,7 @@ namespace SourceGit.Native editors.Add(new Models.ExternalEditor { Name = "Visual Studio Code - Insiders", - Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/vscode_insiders.png", UriKind.Absolute), + Icon = "vscode_insiders.png", Executable = vscodeInsiders, OpenCmdArgs = "\"{0}\"", }); @@ -148,7 +148,7 @@ namespace SourceGit.Native editors.Add(new Models.ExternalEditor { Name = "JetBrains Fleet", - Icon = new Uri("avares://SourceGit/Resources/ExternalToolIcons/fleet.png", UriKind.Absolute), + Icon = "fleet.png", Executable = fleet, OpenCmdArgs = "\"{0}\"", }); diff --git a/src/ViewModels/Repository.cs b/src/ViewModels/Repository.cs index 64b211b0..61f034ff 100644 --- a/src/ViewModels/Repository.cs +++ b/src/ViewModels/Repository.cs @@ -303,7 +303,7 @@ namespace SourceGit.ViewModels foreach (var editor in editors) { var dupEditor = editor; - var icon = AssetLoader.Open(dupEditor.Icon); + var icon = AssetLoader.Open(new Uri($"avares://SourceGit/Resources/ExternalToolIcons/{dupEditor.Icon}", UriKind.RelativeOrAbsolute)); var item = new MenuItem(); item.Header = App.Text("Repository.OpenIn", dupEditor.Name); item.Icon = new Image { Width = 16, Height = 16, Source = new Bitmap(icon) };