Bug 563796 - NPE in DropTarget.getOperationFromKeyState
Added null check for NSApplication.currentEvent().
Change-Id: Ic1715e6931c7a675a425d6a38f89f6bba4ae68f5
Signed-off-by: Lakshmi Shanmugam <lshanmug@in.ibm.com>
diff --git a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java
index 979e1e4..988f18d 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/cocoa/org/eclipse/swt/dnd/DropTarget.java
@@ -546,12 +546,14 @@
// correct Cocoa behavior. Control + Option or Command is NSDragOperationGeneric,
// or DND.DROP_DEFAULT in the SWT.
NSEvent currEvent = NSApplication.sharedApplication().currentEvent();
- long modifiers = currEvent.modifierFlags();
- boolean option = (modifiers & OS.NSAlternateKeyMask) == OS.NSAlternateKeyMask;
- boolean control = (modifiers & OS.NSControlKeyMask) == OS.NSControlKeyMask;
- if (control && option) return DND.DROP_DEFAULT;
- if (control) return DND.DROP_LINK;
- if (option) return DND.DROP_COPY;
+ if (currEvent != null) {
+ long modifiers = currEvent.modifierFlags();
+ boolean option = (modifiers & OS.NSAlternateKeyMask) == OS.NSAlternateKeyMask;
+ boolean control = (modifiers & OS.NSControlKeyMask) == OS.NSControlKeyMask;
+ if (control && option) return DND.DROP_DEFAULT;
+ if (control) return DND.DROP_LINK;
+ if (option) return DND.DROP_COPY;
+ }
return DND.DROP_DEFAULT;
}