Duplicate method error after moving from v3 to v4

Running Processing 4 beta 7 on Windows 11. I am attempting to run a sketch that runs fine in Processing 3 on the same machine. Loading it now in P4 with no changes results in a “duplicate method settings()” error even though “settings()” only appears once in the main class for the sketch (and nowhere else). I use the settings() method to set the size of the window for the sketch based on a config file that gets loaded from the data folder for the sketch. This requires a call to loadJSONObject() from within settings(). Is it possible that the “duplicate method” error stems from that call in P4?

Hi @deisengard, I’m sorry no-one has replied. It would be easier if you posted the code. I suggest you save to a new name, and remove everything that isn’t part of the problem. see Minimum reproducible example.

1 Like

Hello @deisengard ,

This works on W10 with Processing 4 beta 8:

// data.json file contents:
/*
  {
  "width":  100,
  "height": 200,
  }
*/

JSONObject json;

void settings()
  {
  json = loadJSONObject("data.json");
  int w = json.getInt("width");
  int h = json.getInt("height");
  println(w, h);
  size(w, h);
  }

void setup() 
	{
  println(width, height);
	}

void draw() 
	{
  background(0);
	}

:)

I found that Processing automatically spawns a settings() method and moves something into it, EG if you use settings() to set size(), and you put smooth() into setup(), Processing gives that “duplicate method” error.
That means if you declare and use settings(), you may use size() and smooth() in it.

This is not mentioned in the official documentation

1 Like