optimize<*>: App.RaiseException should be called in UIThread; add default progress description for popups;

This commit is contained in:
leo 2024-02-26 11:29:57 +08:00
parent dc0b33ba21
commit 9c3294c285
35 changed files with 100 additions and 34 deletions

View file

@ -1,4 +1,5 @@
using System.Collections.Generic;
using Avalonia.Threading;
using System.Collections.Generic;
namespace SourceGit.Commands {
public class GitFlow : Command {
@ -42,7 +43,9 @@ namespace SourceGit.Commands {
Args = $"flow hotfix start {name}";
break;
default:
App.RaiseException(Context, "Bad branch type!!!");
Dispatcher.UIThread.Invoke(() => {
App.RaiseException(Context, "Bad branch type!!!");
});
return false;
}
@ -62,7 +65,9 @@ namespace SourceGit.Commands {
Args = $"flow hotfix finish {option} {name} -m \"HOTFIX_DONE\"";
break;
default:
App.RaiseException(Context, "Bad branch type!!!");
Dispatcher.UIThread.Invoke(() => {
App.RaiseException(Context, "Bad branch type!!!");
});
return false;
}

View file

@ -1,15 +1,20 @@
using System.IO;
using Avalonia.Threading;
using System.IO;
namespace SourceGit.Commands {
public static class MergeTool {
public static bool OpenForMerge(string repo, string tool, string mergeCmd, string file) {
if (string.IsNullOrWhiteSpace(tool) || string.IsNullOrWhiteSpace(mergeCmd)) {
App.RaiseException(repo, "Invalid external merge tool settings!");
Dispatcher.UIThread.Invoke(() => {
App.RaiseException(repo, "Invalid external merge tool settings!");
});
return false;
}
if (!File.Exists(tool)) {
App.RaiseException(repo, $"Can NOT found external merge tool in '{tool}'!");
Dispatcher.UIThread.Invoke(() => {
App.RaiseException(repo, $"Can NOT found external merge tool in '{tool}'!");
});
return false;
}
@ -22,12 +27,16 @@ namespace SourceGit.Commands {
public static bool OpenForDiff(string repo, string tool, string diffCmd, Models.DiffOption option) {
if (string.IsNullOrWhiteSpace(tool) || string.IsNullOrWhiteSpace(diffCmd)) {
App.RaiseException(repo, "Invalid external merge tool settings!");
Dispatcher.UIThread.Invoke(() => {
App.RaiseException(repo, "Invalid external merge tool settings!");
});
return false;
}
if (!File.Exists(tool)) {
App.RaiseException(repo, $"Can NOT found external merge tool in '{tool}'!");
Dispatcher.UIThread.Invoke(() => {
App.RaiseException(repo, $"Can NOT found external merge tool in '{tool}'!");
});
return false;
}

View file

@ -1,4 +1,5 @@
using System;
using Avalonia.Threading;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
@ -35,7 +36,9 @@ namespace SourceGit.Commands {
return rs;
} catch (Exception e) {
App.RaiseException(repo, "Save change to patch failed: " + e.Message);
Dispatcher.UIThread.Invoke(() => {
App.RaiseException(repo, "Save change to patch failed: " + e.Message);
});
return false;
}
}

View file

@ -1,4 +1,5 @@
using System;
using Avalonia.Threading;
using System;
using System.Diagnostics;
using System.IO;
@ -51,7 +52,9 @@ namespace SourceGit.Commands {
return rs;
} catch (Exception e) {
App.RaiseException(repo, "Save file failed: " + e.Message);
Dispatcher.UIThread.Invoke(() => {
App.RaiseException(repo, "Save file failed: " + e.Message);
});
return false;
}
}