Skip to content

Commit

Permalink
Fixes Exception that might cause client freeze (FAForever#1576)
Browse files Browse the repository at this point in the history
  • Loading branch information
1-alex98 authored and Chris Haggan committed Apr 15, 2022
1 parent d035111 commit 417ba4a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/main/java/com/faforever/client/fx/JavaFxUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -396,4 +396,12 @@ public static void fixJDK8089296() {
int newStyle = user32.GetWindowLong(hwnd, GWL_STYLE) | 0x00020000; //WS_MINIMIZEBOX
user32.SetWindowLong(hwnd, GWL_STYLE, newStyle);
}

public static void assureRunOnMainThread(Runnable runnable) {
if (Platform.isFxApplicationThread()) {
runnable.run();
} else {
runLater(runnable);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ public void onChatUserCreated(ChatUserCreatedEvent event) {
}

private void onPlayersInfo(PlayersMessage playersMessage) {
playersMessage.getPlayers().forEach(this::onPlayerInfo);
playersMessage.getPlayers().forEach(dto -> JavaFxUtil.assureRunOnMainThread(() -> onPlayerInfo(dto)));
}

private void onFoeList(SocialMessage socialMessage) {
Expand Down

0 comments on commit 417ba4a

Please sign in to comment.