Fixed null pointer errors when switching and deleting maps and images

This commit is contained in:
Brendan Robert 2016-04-23 13:11:35 -05:00
parent 11a9640e26
commit cfb26b86b0
2 changed files with 12 additions and 6 deletions

View File

@ -216,8 +216,6 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
imageNameField.setDisable(true);
imageWidthField.setDisable(true);
currentImageEditor = null;
cursorInfo.textProperty().unbind();
cursorInfo.setText("");
} else {
if (i.getName() == null) {
i.setName("Untitled");
@ -248,7 +246,12 @@ public class ImageEditorTabControllerImpl extends ImageEditorTabController {
currentImageEditor.setState(oldEditorState);
}
}
cursorInfo.textProperty().bind(currentImageEditor.cursorInfoProperty());
if (currentImageEditor != null) {
cursorInfo.textProperty().bind(currentImageEditor.cursorInfoProperty());
} else {
cursorInfo.textProperty().unbind();
cursorInfo.setText("");
}
}
private Image getCurrentImage() {

View File

@ -286,8 +286,6 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
mapWidthField.setDisable(true);
mapWrapAround.setDisable(true);
setCurrentEditor(null);
cursorInfo.textProperty().unbind();
cursorInfo.setText("");
} else {
if (m.getScripts() != null) {
DataUtilities.sortNamedEntities(m.getScripts().getScript());
@ -323,7 +321,12 @@ public class MapEditorTabControllerImpl extends MapEditorTabController {
if (currentTile != null) {
e.setCurrentTile(currentTile);
}
cursorInfo.textProperty().bind(e.cursorInfoProperty());
}
if (getCurrentEditor() != null) {
cursorInfo.textProperty().bind(getCurrentEditor().cursorInfoProperty());
} else {
cursorInfo.textProperty().unbind();
cursorInfo.setText("");
}
redrawMapScripts();
}