Fix concurrent problems in TexturesLoader.Selector
This commit is contained in:
@@ -20,6 +20,7 @@ package org.jackhuang.hmcl.ui.account;
|
|||||||
import com.jfoenix.concurrency.JFXUtilities;
|
import com.jfoenix.concurrency.JFXUtilities;
|
||||||
import com.jfoenix.controls.*;
|
import com.jfoenix.controls.*;
|
||||||
|
|
||||||
|
import javafx.application.Platform;
|
||||||
import javafx.beans.binding.Bindings;
|
import javafx.beans.binding.Bindings;
|
||||||
import javafx.beans.property.ListProperty;
|
import javafx.beans.property.ListProperty;
|
||||||
import javafx.beans.property.ReadOnlyObjectProperty;
|
import javafx.beans.property.ReadOnlyObjectProperty;
|
||||||
@@ -246,7 +247,7 @@ public class AddAccountPane extends StackPane {
|
|||||||
private final CountDownLatch latch = new CountDownLatch(1);
|
private final CountDownLatch latch = new CountDownLatch(1);
|
||||||
private GameProfile selectedProfile = null;
|
private GameProfile selectedProfile = null;
|
||||||
|
|
||||||
{
|
public Selector() {
|
||||||
setStyle("-fx-padding: 8px;");
|
setStyle("-fx-padding: 8px;");
|
||||||
|
|
||||||
cancel.setText(i18n("button.cancel"));
|
cancel.setText(i18n("button.cancel"));
|
||||||
@@ -265,21 +266,22 @@ public class AddAccountPane extends StackPane {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public GameProfile select(YggdrasilService service, List<GameProfile> profiles) throws NoSelectedCharacterException {
|
public GameProfile select(YggdrasilService service, List<GameProfile> profiles) throws NoSelectedCharacterException {
|
||||||
for (GameProfile profile : profiles) {
|
Platform.runLater(() -> {
|
||||||
ImageView portraitView = new ImageView();
|
for (GameProfile profile : profiles) {
|
||||||
portraitView.setSmooth(false);
|
ImageView portraitView = new ImageView();
|
||||||
portraitView.imageProperty().bind(TexturesLoader.fxAvatarBinding(service, profile.getId(), 32));
|
portraitView.setSmooth(false);
|
||||||
FXUtils.limitSize(portraitView, 32, 32);
|
portraitView.imageProperty().bind(TexturesLoader.fxAvatarBinding(service, profile.getId(), 32));
|
||||||
|
FXUtils.limitSize(portraitView, 32, 32);
|
||||||
|
|
||||||
IconedItem accountItem = new IconedItem(portraitView, profile.getName());
|
IconedItem accountItem = new IconedItem(portraitView, profile.getName());
|
||||||
accountItem.setOnMouseClicked(e -> {
|
accountItem.setOnMouseClicked(e -> {
|
||||||
selectedProfile = profile;
|
selectedProfile = profile;
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
});
|
});
|
||||||
listBox.add(accountItem);
|
listBox.add(accountItem);
|
||||||
}
|
}
|
||||||
|
Controllers.dialog(this);
|
||||||
JFXUtilities.runInFX(() -> Controllers.dialog(this));
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
latch.await();
|
latch.await();
|
||||||
|
|||||||
Reference in New Issue
Block a user