Skip to content

Commit 8078279

Browse files
committed
fixed NPE during renaming lights.
1 parent d0b17f8 commit 8078279

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/main/java/com/ss/editor/ui/control/model/node/light/LightTreeNode.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,8 @@ public LightTreeNode(@NotNull final T element, final long objectId) {
4343
public void changeName(@NotNull final NodeTree<?> nodeTree, @NotNull final String newName) {
4444
final T element = getElement();
4545
final ChangeConsumer consumer = notNull(nodeTree.getChangeConsumer());
46-
consumer.execute(new RenameLightOperation(element.getName(), newName, element));
46+
final String currentName = element.getName();
47+
consumer.execute(new RenameLightOperation(currentName == null ? "" : currentName, newName, element));
4748
}
4849

4950
@Override

src/main/java/com/ss/editor/ui/control/model/tree/action/light/AbstractCreateLightAction.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@
66
import com.ss.editor.annotation.FXThread;
77
import com.ss.editor.model.undo.editor.ChangeConsumer;
88
import com.ss.editor.model.undo.editor.ModelChangeConsumer;
9-
import com.ss.editor.ui.control.tree.action.AbstractNodeAction;
109
import com.ss.editor.ui.control.model.tree.action.operation.AddLightOperation;
1110
import com.ss.editor.ui.control.tree.NodeTree;
11+
import com.ss.editor.ui.control.tree.action.AbstractNodeAction;
1212
import com.ss.editor.ui.control.tree.node.TreeNode;
13-
1413
import org.jetbrains.annotations.NotNull;
1514

1615
/**
@@ -32,6 +31,10 @@ protected void process() {
3231
final NodeTree<?> nodeTree = getNodeTree();
3332

3433
final Light light = createLight();
34+
if (light.getName() == null) {
35+
light.setName("");
36+
}
37+
3538
final TreeNode<?> treeNode = getNode();
3639
final Node element = (Node) treeNode.getElement();
3740

0 commit comments

Comments
 (0)