summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRaphael <raphael@google.com>2009-10-20 12:44:18 -0700
committerRaphael <raphael@google.com>2009-10-20 12:59:15 -0700
commit4ed80aea3458e793682b916b86a688369915c8fc (patch)
tree9dfe0f12e93bebfba8f2d440b0ef653015a61220 /tools
parentfc5b5aecdeca8bb32eba9d38961b6649395f8913 (diff)
downloadandroid_development-4ed80aea3458e793682b916b86a688369915c8fc.tar.gz
android_development-4ed80aea3458e793682b916b86a688369915c8fc.tar.bz2
android_development-4ed80aea3458e793682b916b86a688369915c8fc.zip
Fix potential NPE in manifest editor when switching SDKs
The UiElementNode depends on the target to compute the description and it's entirely possible for the target to be null while the SDK is being unloaded/reloaded. SDK BUG 2196260 Change-Id: I4151529ea3b6a65eade47d03e55fc93cad8596d9
Diffstat (limited to 'tools')
-rw-r--r--tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/model/UiManifestElementNode.java20
1 files changed, 13 insertions, 7 deletions
diff --git a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/model/UiManifestElementNode.java b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/model/UiManifestElementNode.java
index 62b6d9d1d..5dc85447b 100644
--- a/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/model/UiManifestElementNode.java
+++ b/tools/eclipse/plugins/com.android.ide.eclipse.adt/src/com/android/ide/eclipse/adt/internal/editors/manifest/model/UiManifestElementNode.java
@@ -21,6 +21,7 @@ import com.android.ide.eclipse.adt.internal.editors.manifest.descriptors.Android
import com.android.ide.eclipse.adt.internal.editors.manifest.descriptors.ManifestElementDescriptor;
import com.android.ide.eclipse.adt.internal.editors.uimodel.UiAttributeNode;
import com.android.ide.eclipse.adt.internal.editors.uimodel.UiElementNode;
+import com.android.ide.eclipse.adt.internal.sdk.AndroidTargetData;
import com.android.sdklib.SdkConstants;
import org.w3c.dom.Element;
@@ -41,10 +42,10 @@ import org.w3c.dom.Element;
* {@link ElementDescriptor}.
*/
public final class UiManifestElementNode extends UiElementNode {
-
+
/**
* Creates a new {@link UiElementNode} described by a given {@link ElementDescriptor}.
- *
+ *
* @param elementDescriptor The {@link ElementDescriptor} for the XML node. Cannot be null.
*/
public UiManifestElementNode(ManifestElementDescriptor elementDescriptor) {
@@ -55,18 +56,23 @@ public final class UiManifestElementNode extends UiElementNode {
* Computes a short string describing the UI node suitable for tree views.
* Uses the element's attribute "android:name" if present, or the "android:label" one
* followed by the element's name.
- *
+ *
* @return A short string describing the UI node suitable for tree views.
*/
@Override
public String getShortDescription() {
- if (getXmlNode() != null &&
+ AndroidTargetData target = getAndroidTarget();
+ AndroidManifestDescriptors manifestDescriptors = null;
+ if (target != null) {
+ manifestDescriptors = target.getManifestDescriptors();
+ }
+
+ if (manifestDescriptors != null &&
+ getXmlNode() != null &&
getXmlNode() instanceof Element &&
getXmlNode().hasAttributes()) {
- AndroidManifestDescriptors manifestDescriptors =
- getAndroidTarget().getManifestDescriptors();
-
+
// Application and Manifest nodes have a special treatment: they are unique nodes
// so we don't bother trying to differentiate their strings and we fall back to
// just using the UI name below.