Skip to content
Open
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
44 changes: 27 additions & 17 deletions TuneLab/UI/MainWindow/Editor/Editor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -387,14 +387,18 @@ async void SwitchProjectSafely(Action SwitchProject)

void LoadProject(string path)
{
if (!FormatsManager.Deserialize(path, out var info, out var error))
Task.Run(() =>
{
Log.Error("Deserialize file error: " + error);
return;
}

mDocument.SetProject(CreateProject(info), path);
RecentFilesManager.AddFile(path);
if (!FormatsManager.Deserialize(path, out var info, out var error))
{
Log.Error("Deserialize file error: " + error);
return;
}
Dispatcher.UIThread.Post(() => {
mDocument.SetProject(CreateProject(info), path);
RecentFilesManager.AddFile(path);
});
});
}

Project CreateProject(ProjectInfo info)
Expand Down Expand Up @@ -509,18 +513,24 @@ public async void ExportAs(string extension)
var path = file?.TryGetLocalPath();
if (path == null)
return;

if (!FormatsManager.Serialize(mDocument.Project.GetInfo(), extension, out var stream, out var error))
_ = Task.Run(() =>
{
Log.Error("Save file error: " + error);
return;
}
if (!FormatsManager.Serialize(mDocument.Project.GetInfo(), extension, out var stream, out var error))
{
Log.Error("Save file error: " + error);
return;
}

using (FileStream fileStream = new FileStream(path, FileMode.Create))
{
stream.CopyTo(fileStream);
}
RecentFilesManager.AddFile(path);
using (FileStream fileStream = new FileStream(path, FileMode.Create))
{
stream.CopyTo(fileStream);
}

Dispatcher.UIThread.Post(() =>
{
RecentFilesManager.AddFile(path);
});
});
}

void SaveToFile(string path)
Expand Down