Ghidra is a software reverse engineering (SRE) framework
Fix for creating a new folder with no node selected
dragonmacher889d2ace20af
diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatree/FrontEndProjectTreeContext.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatree/FrontEndProjectTreeContext.javaindex e9dd44660b..609a79464f 100644--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatree/FrontEndProjectTreeContext.java+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/datatree/FrontEndProjectTreeContext.java@@ -4,9 +4,9 @@* Licensed under the Apache License, Version 2.0 (the "License");* you may not use this file except in compliance with the License.* You may obtain a copy of the License at- *+ ** http://www.apache.org/licenses/LICENSE-2.0- *+ ** Unless required by applicable law or agreed to in writing, software* distributed under the License is distributed on an "AS IS" BASIS,* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.@@ -60,6 +60,10 @@ public class FrontEndProjectTreeContext extends ProjectDataContext@Overridepublic GTreeNode getContextNode() {- return (GTreeNode) super.getContextObject();+ Object contextObject = super.getContextObject();+ if (contextObject instanceof GTreeNode node) {+ return node;+ }+ return null;}}diff --git a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/projectdata/actions/ProjectDataNewFolderAction.java b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/projectdata/actions/ProjectDataNewFolderAction.javaindex a56873c35f..17e3b4bf7a 100644--- a/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/projectdata/actions/ProjectDataNewFolderAction.java+++ b/Ghidra/Framework/Project/src/main/java/ghidra/framework/main/projectdata/actions/ProjectDataNewFolderAction.java@@ -99,8 +99,13 @@ public class ProjectDataNewFolderAction<T extends ProjectTreeContext>private GTreeNode getParentNode(T context) {GTreeNode node = context.getContextNode();+ if (node == null) {+ // no node selected in the tree+ return context.getTree().getModelRoot();+ }+if (node instanceof DomainFileNode) {- return ((DomainFileNode) node).getParent();+ return node.getParent();}return node;}