Skip to content

Commit

Permalink
Merge pull request #1322 from VladiStep/saferDisassemblyEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
Grossley authored Apr 15, 2023
2 parents e76dfbf + 9a33896 commit 2089908
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions UndertaleModTool/Editors/UndertaleCodeEditor.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -480,16 +480,28 @@ private void DisassembleCode(UndertaleCode code, bool first)
{
DisassemblyEditor.IsReadOnly = false;

var data = mainWindow.Data;
text = code.Disassemble(data.Variables, data.CodeLocals.For(code));
try
{
var data = mainWindow.Data;
text = code.Disassemble(data.Variables, data.CodeLocals.For(code));

CurrentLocals = new List<string>();
}
catch (Exception ex)
{
DisassemblyEditor.IsReadOnly = true;

CurrentLocals = new List<string>();
string exStr = ex.ToString();
exStr = String.Join("\n;", exStr.Split('\n'));
text = $"; EXCEPTION!\n; {exStr}\n";
}
}

DisassemblyEditor.Document.BeginUpdate();
DisassemblyEditor.Document.Text = text;

RestoreCaretPosition(DisassemblyEditor, currLine, currColumn, scrollPos);
if (!DisassemblyEditor.IsReadOnly)
RestoreCaretPosition(DisassemblyEditor, currLine, currColumn, scrollPos);

DisassemblyEditor.Document.EndUpdate();

Expand Down

0 comments on commit 2089908

Please sign in to comment.