Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix for NullPointerException thrown in PApplet.dequeueWindowEvents() #930

Merged
merged 1 commit into from
Jan 21, 2025

Conversation

hx2A
Copy link
Collaborator

@hx2A hx2A commented Jan 19, 2025

Here is a fix for #918.

When the window is moved or resized, the new location or size values will be stored as a pair in the windowEventQueue map. This ensures that there are no race conditions if one value has been added but the other has not.

The exception I saw when I opened #918 is probably very rare and would be hard to reproduce. Nevertheless, we can review the code change and verify that the necessary functionality still works. You can test window move and resize events with the following code:

void setup() {
  size(200, 200, JAVA2D);
  windowResizable(true);
  windowMove(100, 100);
}

void draw() {
}

void windowResized() {
  println("new size", width, height);
}

void windowMoved() {
  println("new location", windowX, windowY);
}

void keyPressed() {
  windowResize(200, 200);
  windowMove(100, 100);
}

It also works with the P2D renderer.

@Stefterv
Copy link
Collaborator

Stefterv commented Jan 20, 2025

Hi @hx2A Thank you for the fix, I tested it on macOS arm64 and works just fine here too.

@hx2A
Copy link
Collaborator Author

hx2A commented Jan 20, 2025

Hi @hx2A Thank you for the fix, I tested it on macOS arm64 and works just fine here too.

You are welcome! Happy to help out here.

@SableRaf SableRaf changed the title fix for #918 Fix for NullPointerException thrown in PApplet.dequeueWindowEvents() Jan 21, 2025
@SableRaf SableRaf self-requested a review January 21, 2025 16:53
@Stefterv Stefterv merged commit 78ef9f5 into processing:main Jan 21, 2025
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants