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: fix game screen goes black bug #4980

Merged
merged 9 commits into from
Jan 21, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -728,6 +728,9 @@ public int height() {
* @param height An integer representing the new height.
*/
public void setDimensions(int width, int height) {
Copy link
Member

@pollend pollend Jan 15, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's just obscuring the problem by having the method silently fail.

Preconditions.checkArgument(width > 0);
Preconditions.checkArgument(height > 0);

reproduce the issue and look at the backtrace to see where the problem is occurring.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pollend That's true. I am looking for a way to solve this bug more accurately. Do you have any suggestions on where I should start on? That would be so helpful.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the precondition should hit and give you a backtrace and give you information where this is coming from. I don't know off the top of my head why its getting set to 0,0

if(width == 0 && height ==0){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Minor code quality fixes here, explained by the robot :-)

Should this just check for an or rather than and ? In the case we're dealing with both dimensions are zero. But it seems like either being zero would be a case where you'd disregard the instruction and return early.

Additionally, maybe it would be good if we did a logger.warn(....) to highlight that the set was called with invalid dimensions?

return;
}
this.width = width;
this.height = height;
}
Expand All @@ -737,6 +740,9 @@ public void setDimensions(int width, int height) {
* @param other A Dimension to use the width and height from.
*/
public void setDimensions(Dimensions other) {
if(width == 0 && height ==0){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In addition to my other review content in this case shouldn't we be checking other.width and same for height?

return;
}
this.width = other.width;
this.height = other.height;
}
Expand Down