Fixed NullPointerException when switched profile

This commit is contained in:
huangyuhui
2018-02-26 20:16:14 +08:00
parent 1404a080ad
commit 3067d323de
2 changed files with 2 additions and 12 deletions

View File

@@ -530,8 +530,8 @@ public class Settings {
} }
private void onProfileChanged() { private void onProfileChanged() {
getSelectedProfile().getRepository().refreshVersionsAsync().start(); getSelectedProfile().getRepository().refreshVersionsAsync().subscribe(() ->
EventBus.EVENT_BUS.fireEvent(new ProfileChangedEvent(SETTINGS, getSelectedProfile())); EventBus.EVENT_BUS.fireEvent(new ProfileChangedEvent(SETTINGS, getSelectedProfile())));
} }
private void profileNameChanged(ObservableValue<? extends String> observableValue, String oldValue, String newValue) { private void profileNameChanged(ObservableValue<? extends String> observableValue, String oldValue, String newValue) {

View File

@@ -80,8 +80,6 @@ public final class MainPage extends StackPane implements DecoratorPage {
FXUtils.loadFXML(this, "/assets/fxml/main.fxml"); FXUtils.loadFXML(this, "/assets/fxml/main.fxml");
EventBus.EVENT_BUS.channel(RefreshedVersionsEvent.class).register(() -> Platform.runLater(this::loadVersions)); EventBus.EVENT_BUS.channel(RefreshedVersionsEvent.class).register(() -> Platform.runLater(this::loadVersions));
EventBus.EVENT_BUS.channel(ProfileLoadingEvent.class).register(this::onProfilesLoading);
EventBus.EVENT_BUS.channel(ProfileChangedEvent.class).register(this::onProfileChanged);
versionPopup = new JFXPopup(versionList); versionPopup = new JFXPopup(versionList);
getChildren().remove(versionList); getChildren().remove(versionList);
@@ -178,14 +176,6 @@ public final class MainPage extends StackPane implements DecoratorPage {
return item; return item;
} }
public void onProfilesLoading() {
// TODO: Profiles
}
public void onProfileChanged(ProfileChangedEvent event) {
Platform.runLater(() -> loadVersions(event.getProfile()));
}
private void loadVersions() { private void loadVersions() {
loadVersions(Settings.INSTANCE.getSelectedProfile()); loadVersions(Settings.INSTANCE.getSelectedProfile());
} }