Skip to content

Commit ed9e83b

Browse files
committed
Fix ErrorFormatter brace mismatch, add debug dialogs for Windows crash diagnosis
1 parent 0ef2e09 commit ed9e83b

4 files changed

Lines changed: 21 additions & 4 deletions

File tree

mode/CppMode.jar

38 Bytes
Binary file not shown.

src/Processing.cpp

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3405,8 +3405,14 @@ void PApplet::run(){
34053405
glfwSwapBuffers(w);
34063406
});
34073407
glfwMakeContextCurrent(gWindow);
3408-
glewExperimental = GL_TRUE; // required for core/compat profiles to load all function pointers
3408+
glewExperimental = GL_TRUE;
3409+
#ifdef _WIN32
3410+
MessageBoxA(NULL, "Before glewInit", "Debug1", MB_OK);
3411+
#endif
34093412
GLenum glewErr = glewInit();
3413+
#ifdef _WIN32
3414+
MessageBoxA(NULL, "After glewInit", "Debug2", MB_OK);
3415+
#endif
34103416
if(glewErr != GLEW_OK){
34113417
#ifdef _WIN32
34123418
char msg[256]; snprintf(msg,sizeof(msg),"glewInit() failed: %s", glewGetErrorString(glewErr));
@@ -3421,7 +3427,13 @@ void PApplet::run(){
34213427
if(phongProg){glDeleteProgram(phongProg);phongProg=0;}
34223428
glEnable(GL_BLEND);glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
34233429
glEnable(GL_DEPTH_TEST);
3430+
#ifdef _WIN32
3431+
MessageBoxA(NULL, "After GL enable calls", "Debug3", MB_OK);
3432+
#endif
34243433
smooth();
3434+
#ifdef _WIN32
3435+
MessageBoxA(NULL, "After smooth()", "Debug4", MB_OK);
3436+
#endif
34253437
// Don't call setProjection here -- let size() in this->setup() do it
34263438
// with the correct dimensions. Calling it now with winWidth=640,winHeight=480
34273439
// (defaults) would set the wrong ortho before this->setup() changes the size.
@@ -3499,6 +3511,9 @@ void PApplet::run(){
34993511
}
35003512
}
35013513

3514+
#ifdef _WIN32
3515+
MessageBoxA(NULL, "Before glfwFocusWindow", "Debug5", MB_OK);
3516+
#endif
35023517
glfwFocusWindow(gWindow); // ensure input focus on Windows
35033518

35043519
// Settle loop: poll+swap several times BEFORE this->setup() runs so i3/tiling WMs

src/java/CppBuild.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -602,7 +602,7 @@ public File compile(RunnerListener listener) throws Exception {
602602
// Copy bundled macOS dylibs to sketch folder so the binary finds them at runtime.
603603
if (isMac) {
604604
String macArch2 = System.getProperty("os.arch","").contains("aarch64") ? "arm64" : "x64";
605-
File macLibsDir2 = new File(runtimeDir.getParentFile(), "libs/macos"2);
605+
File macLibsDir2 = new File(runtimeDir.getParentFile(), "libs/macos");
606606
if (macLibsDir2.exists()) {
607607
for (File dylib : macLibsDir2.listFiles((d,n) -> n.endsWith(".dylib"))) {
608608
File destDylib = new File(sketch.getFolder(), dylib.getName());

src/java/ErrorFormatter.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -150,15 +150,17 @@ private static String fixNote(ParseException ex) {
150150
if (msg.contains("expected identifier") || msg.contains("expected a type name")) {
151151
String _d = msg.replaceAll(".*(?:but found|before) '(.+?)'.*", "$1");
152152
if (_d.length() > 0 && Character.isDigit(_d.charAt(0))) return "names cannot start with a digit";
153-
}
154153
java.util.Set<String> KW = new java.util.HashSet<>(java.util.Arrays.asList(
155154
"for","while","if","else","switch","case","return","break","continue",
156155
"class","struct","namespace","template","typename","auto","void",
157156
"int","float","double","bool","char","long","short","unsigned","signed",
158157
"const","constexpr","static","inline","virtual","override","new","delete","this"));
159158
if (KW.contains(_d)) return "'"+_d+"' is a reserved keyword";
160159
}
161-
if (msg.contains("expected ';' but found '") && msg.replaceAll(".*but found '(.+?)'.*", "$1").matches("[^a-zA-Z0-9_]+")) { String tok = msg.replaceAll(".*but found '(.+?)'.*", "$1"); return "invalid token '" + tok + "'"; }
160+
if (msg.contains("expected ';' but found '")) {
161+
String tok = msg.replaceAll(".*but found '(.+?)'.*", "$1");
162+
if (tok.matches("[^a-zA-Z0-9_]+")) return "invalid token '" + tok + "'";
163+
}
162164
if (msg.contains("expected ';'")) return "missing ';' here";
163165
if (msg.contains("expected '(' before") || msg.contains("expected '(' but found")) return "'(' is required after 'if'/'while'/'for'/'switch'";
164166
if (msg.contains("expected ')'")) return "missing ')' to close this";

0 commit comments

Comments
 (0)