Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions OpenUtau.Core/Classic/PluginRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using System.IO;
using System.Linq;
using System.Security.Cryptography;
using System.Threading.Tasks;
using OpenUtau.Core;
using OpenUtau.Core.Ustx;
using Serilog;
Expand Down Expand Up @@ -44,7 +45,7 @@ public PluginRunner(PathManager pathManager, Action<ReplaceNoteEventArgs> onRepl
OnError = onError;
}

public void Execute(UProject project, UVoicePart part, UNote? first, UNote? last, IPlugin plugin) {
public async Task Execute(UProject project, UVoicePart part, UNote? first, UNote? last, IPlugin plugin) {
if (first == null || last == null) {
return;
}
Expand All @@ -59,7 +60,11 @@ public void Execute(UProject project, UVoicePart part, UNote? first, UNote? last
return;
}
Log.Information("Legacy plugin temp file has changed.");
var (toRemove, toAdd) = Ust.ParsePlugin(project, part, first, last, sequence, tempFile, encoding: plugin.Encoding);

var (toRemove, toAdd) = await Task.Run(() =>
Ust.ParsePlugin(project, part, first, last, sequence, tempFile, encoding: plugin.Encoding)
);

OnReplaceNote(new ReplaceNoteEventArgs(part, toRemove, toAdd));
} catch (Exception e) {
OnError(new PluginErrorEventArgs("Failed to execute plugin", e));
Expand Down
29 changes: 14 additions & 15 deletions OpenUtau/ViewModels/PianoRollViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -147,27 +147,26 @@ public PianoRollViewModel() {
DocManager.Inst.EndUndoGroup();
});

legacyPluginCommand = ReactiveCommand.CreateFromTask<Classic.Plugin>(async plugin => {
legacyPluginCommand = ReactiveCommand.Create<Classic.Plugin>(async plugin => {
if (NotesViewModel.Part == null || NotesViewModel.Part.notes.Count == 0) {
return;
}
DocManager.Inst.ExecuteCmd(new LoadingNotification(typeof(PianoRollWindow), true, "legacy plugin"));

try {
await Task.Run(() => {
var part = NotesViewModel.Part;
UNote? first;
UNote? last;
if (NotesViewModel.Selection.IsEmpty) {
first = part.notes.First();
last = part.notes.Last();
} else {
first = NotesViewModel.Selection.FirstOrDefault();
last = NotesViewModel.Selection.LastOrDefault();
}
var runner = PluginRunner.from(PathManager.Inst, DocManager.Inst);
runner.Execute(NotesViewModel.Project, part, first, last, plugin);
});
var part = NotesViewModel.Part;
UNote? first;
UNote? last;
if (NotesViewModel.Selection.IsEmpty) {
first = part.notes.First();
last = part.notes.Last();
} else {
first = NotesViewModel.Selection.FirstOrDefault();
last = NotesViewModel.Selection.LastOrDefault();
}
var runner = PluginRunner.from(PathManager.Inst, DocManager.Inst);
await runner.Execute(NotesViewModel.Project, part, first, last, plugin);

} catch (Exception e) {
DocManager.Inst.ExecuteCmd(new ErrorMessageNotification(e));
} finally {
Expand Down
11 changes: 4 additions & 7 deletions OpenUtau/Views/MainWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ public MainWindow() {
AskIfSaveAndContinue = AskIfSaveAndContinue
};

viewModel.NewProject();
viewModel.AddTempoChangeCmd = ReactiveCommand.Create<int>(tick => AddTempoChange(tick));
viewModel.DelTempoChangeCmd = ReactiveCommand.Create<int>(tick => DelTempoChange(tick));
viewModel.AddTimeSigChangeCmd = ReactiveCommand.Create<int>(bar => AddTimeSigChange(bar));
Expand Down Expand Up @@ -509,8 +510,8 @@ void OnMenuExpressionss(object sender, RoutedEventArgs args) {
}
}

void OnMenuSingers(object sender, RoutedEventArgs args) {
OpenSingersWindow();
async void OnMenuSingers(object sender, RoutedEventArgs args) {
await OpenSingersWindowAsync();
}

/// <summary>
Expand All @@ -525,11 +526,7 @@ void OnMenuSingers(object sender, RoutedEventArgs args) {
return null;
}

public void OpenSingersWindow() {
LoadingWindow.RunAsyncOnUIThread(OpenSingersWindowAsync);
}

public async void OpenSingersWindowAsync() {
public async Task OpenSingersWindowAsync() {
var lifetime = Application.Current?.ApplicationLifetime as IClassicDesktopStyleApplicationLifetime;
if (lifetime == null) {
return;
Expand Down
14 changes: 9 additions & 5 deletions OpenUtau/Views/PianoRollWindow.axaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,10 @@ void OnMenuPlaybackAutoScroll(object sender, RoutedEventArgs args) {
}
}

void OnMenuSingers(object sender, RoutedEventArgs args) {
MainWindow?.OpenSingersWindow();
async void OnMenuSingers(object sender, RoutedEventArgs args) {
if (MainWindow != null) {
await MainWindow.OpenSingersWindowAsync();
}
this.Activate();
try {
USinger? singer = null;
Expand Down Expand Up @@ -979,7 +981,7 @@ public void PhonemeCanvasDoubleTapped(object sender, TappedEventArgs args) {
LyricBox?.Show(ViewModel.NotesViewModel.Part, new LyricBoxPhoneme(phoneme!), phoneme!.phoneme);
}

public void PhonemeCanvasPointerPressed(object sender, PointerPressedEventArgs args) {
public async void PhonemeCanvasPointerPressed(object sender, PointerPressedEventArgs args) {
LyricBox?.EndEdit();
if (ViewModel?.NotesViewModel?.Part == null) {
return;
Expand All @@ -997,7 +999,9 @@ public void PhonemeCanvasPointerPressed(object sender, PointerPressedEventArgs a
if (Preferences.Default.OtoEditor == 1 && !string.IsNullOrEmpty(Preferences.Default.VLabelerPath)) {
Integrations.VLabelerClient.Inst.GotoOto(singer, hitAliasInfo.phoneme.oto);
} else {
MainWindow?.OpenSingersWindow();
if (MainWindow != null) {
await MainWindow.OpenSingersWindowAsync();
}
this.Activate();
DocManager.Inst.ExecuteCmd(new GotoOtoNotification(singer, hitAliasInfo.phoneme.oto));
}
Expand Down Expand Up @@ -1795,7 +1799,7 @@ public void AttachExpressions() {
public void OnNext(UCommand cmd, bool isUndo) {
if (cmd is LoadingNotification loadingNotif && loadingNotif.window == typeof(PianoRollWindow)) {
if (loadingNotif.startLoading) {
LoadingWindow.BeginLoading(this);
LoadingWindow.BeginLoadingImmediate(this);
} else {
LoadingWindow.EndLoading();
}
Expand Down
Loading