Skip to content

Commit af4a5ad

Browse files
committed
Fix: skip _PSketch injection for classes that already inherit PApplet
1 parent f84d95c commit af4a5ad

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

mode/CppMode.jar

38 Bytes
Binary file not shown.

src/java/CppBuild.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2100,7 +2100,11 @@ private String removePSketchFromDataStructs(String code) {
21002100
result.append(code, i, lineStart);
21012101
// Also remove _PSketch from template classes -- they can't use Processing API
21022102
boolean isTemplate = lineStart > 0 && code.substring(Math.max(0, lineStart - 200), lineStart).contains("template<");
2103-
if (hasMethod && !isTemplate) {
2103+
// If the class already inherits PApplet directly, skip _PSketch injection
2104+
// -- it already has width/height/key etc. as members, and injecting
2105+
// _PSketch proxies would cause ambiguity errors.
2106+
boolean alreadyInheritsApplet = code.substring(lineStart, braceOpen).contains("PApplet");
2107+
if (hasMethod && !isTemplate && !alreadyInheritsApplet) {
21042108
// Keep _PSketch injection
21052109
result.append(code, lineStart, j);
21062110
} else {

0 commit comments

Comments
 (0)