Preserve selected algorithm when the grid is rebuilt on resize#25
Merged
Conversation
Resizing the window (e.g. maximising) fires the gridPane layout-bounds listener, which rebuilds the grid and creates a fresh GridService. Speed was re-applied to the new service but the selected pathfinding algorithm was not, so the new service's algorithm was null: Visualize then reported "Pick an Algorithm!" even though the play button still showed the selection. Re-picking the same algorithm did nothing (the menu selection didn't change, so no listener fired); only switching away and back worked. Re-apply the button's already-selected algorithm to the new service, mirroring how speed is re-applied. Fixes both the false "Pick an Algorithm!" and the dead re-selection. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
actions/cache@v2 is now auto-failed by GitHub; bump it (and the equally deprecated checkout/setup-java/codeql-action) to current majors: - maven.yml: checkout@v2->v4, setup-java@v2->v4, cache@v2->v4 - codeql.yml: codeql-action init/analyze @v2->v3, checkout@v3->v4 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
The project targets Java 21 (java.version=21), but the Maven workflow set up JDK 17 -> "release version 21 not supported". Bump setup-java to 21. This only surfaced now that the deprecated actions/cache no longer aborts the run early. CodeQL still used the unedited template placeholder (autobuild commented out, a non-existent buildscript.sh run step). Set up JDK 21 and use autobuild so the Java analysis actually compiles the project. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Bug
After visualizing a run, maximizing / resizing the window loses the configuration and Visualize stops working:
Cause
Resizing fires the
gridPanelayout-bounds listener, which rebuilds the grid and creates a newGridService. Speed is re-applied to the new service, but the selected pathfinding algorithm is not — so the new service'spathAlgorithmisnull→MissingAlgorithmException("Pick an Algorithm!").Bug 2 follows: re-selecting the already-selected menu item doesn't change
selectedItemProperty, so no listener fires and the new service never learns the algorithm — hence the "switch away and back" workaround.Fix
In the resize listener, re-apply the play button's already-selected algorithm to the fresh service (mirroring how
updateSpeedis re-applied). This fixes both symptoms — the algorithm survives the rebuild, so Visualize works immediately and no re-selection is needed.Testing
mvn testgreen (5 tests);mvn compilegreen.🤖 Generated with Claude Code