Skip to content
This repository was archived by the owner on Sep 11, 2023. It is now read-only.

Commit cc110b3

Browse files
committed
fixed program crashing when compiling with no editors opened
1 parent 0966da2 commit cc110b3

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

UI/MainWindow/MainWindowSPCompiler.cs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@ public partial class MainWindow
3636
private async void Compile_SPScripts(bool compileAll = true)
3737
{
3838
// Checks if the program is compiling to avoid doing it again, and checks if the editor is from the templates window
39-
if (InCompiling || GetCurrentEditorElement().IsTemplateEditor)
39+
var ee = GetCurrentEditorElement();
40+
if (InCompiling || (ee != null && ee.IsTemplateEditor))
4041
{
4142
return;
4243
}
@@ -105,7 +106,6 @@ await this.ShowMessageAsync(Program.Translations.GetLanguage("Error"),
105106
}
106107
else
107108
{
108-
var ee = GetCurrentEditorElement();
109109
if (ee == null)
110110
{
111111
InCompiling = false;
@@ -128,8 +128,7 @@ await this.ShowMessageAsync(Program.Translations.GetLanguage("Error"),
128128
progressTask.SetProgress(0.0);
129129
var stringOutput = new StringBuilder();
130130
var errorFilterRegex =
131-
new Regex(
132-
@"^(?<File>.+?)\((?<Line>[0-9]+(\s*--\s*[0-9]+)?)\)\s*:\s*(?<Type>[a-zA-Z]+\s+([a-zA-Z]+\s+)?[0-9]+)\s*:(?<Details>.+)",
131+
new Regex(Constants.ErrorFilterRegex,
133132
RegexOptions.Compiled | RegexOptions.ExplicitCapture | RegexOptions.Multiline);
134133

135134
var compiledSuccess = 0;

Utils/Constants.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ public static class Constants
1010
public const string DiscordRPCAppID = "692110664948514836";
1111
public const string JavaDownloadSite64 = "https://api.adoptopenjdk.net/v3/installer/latest/15/ga/windows/x64/jdk/hotspot/normal/adoptopenjdk?project=jdk";
1212
public const string JavaDownloadSite32 = "https://api.adoptopenjdk.net/v3/installer/latest/15/ga/windows/x32/jdk/hotspot/normal/adoptopenjdk?project=jdk";
13+
public const string ErrorFilterRegex = @"^(?<File>.+?)\((?<Line>[0-9]+(\s*--\s*[0-9]+)?)\)\s*:\s*(?<Type>[a-zA-Z]+\s+([a-zA-Z]+\s+)?[0-9]+)\s*:(?<Details>.+)";
1314
public const string JavaDownloadFile = @"%userprofile%\Downloads\adoptopenjdk-java-15-spcode.msi";
1415
public const string HotkeysFile = "Hotkeys.xml";
1516
public const string LicenseFile = "License.txt";

0 commit comments

Comments
 (0)