Added null check and removal from open queue to closing windows on the client side#92
Merged
RecursivePineapple merged 3 commits intoGTNewHorizons:masterfrom Oct 9, 2025
Merged
Conversation
RecursivePineapple
approved these changes
Oct 9, 2025
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.
Issue
Prior to this fix when a request to open and close (in this order) the same window arrived on the same tick from the server, the client had no time to actually open the window and so a null exception occured here (window would be null):
ModularUI/src/main/java/com/gtnewhorizons/modularui/api/screen/ModularUIContext.java
Lines 411 to 413 in e1481e3
Example
This could be seen in the case of the gt5 Drone Centre, where on the machine list window, losing focus of the textbox and clicking the sort and localise buttons had this effect:
This means the client recieved the request close-open, which is not problematic.
However, when one of the affore mentioned buttons get clicked whilst the textbox is still active the following request is sent to the client: close-open-close-open. We can see that the problematic request has appeared.
On the client side during the execution of the second close request, the window that is requested to be closed has not been opened yet, it is still in the queuedOpenWindow list. This list gets emptied (ie the window gets opened) on a new client tick, which in most cases happens later than the atttempt to close it.
Solution
First, check to see if the window to be closed is open or not (
window == null). Second, if it's not, meaning it is probably in the list of queued windows to be opened, just remove it from that list.Fixes GTNewHorizons/GT-New-Horizons-Modpack/issues/16580
Probably also fixes GTNewHorizons/GT-New-Horizons-Modpack/issues/19771, the error message and the circumstances are similar