Commit 61447e77 authored by Stephanie Gawroriski's avatar Stephanie Gawroriski
Browse files

Correct NullPointerException being thrown when display events happen when a...

Correct NullPointerException being thrown when display events happen when a display has not been bound.
parent 84f5bd45
......@@ -520,7 +520,9 @@ public final class NativeDisplayAccess
}
// Indicate that the size changed
NativeDisplayAccess._CALLBACK.sizeChanged(0, xw, xh);
NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
if (cbx != null)
cbx.sizeChanged(0, xw, xh);
}
/**
......@@ -530,7 +532,9 @@ public final class NativeDisplayAccess
@Override
public void componentHidden(ComponentEvent __e)
{
NativeDisplayAccess._CALLBACK.shown(0, 0);
NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
if (cbx != null)
cbx.shown(0, 0);
}
/**
......@@ -566,7 +570,9 @@ public final class NativeDisplayAccess
@Override
public void componentShown(ComponentEvent __e)
{
NativeDisplayAccess._CALLBACK.shown(0, 1);
NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
if (cbx != null)
cbx.shown(0, 1);
}
/**
......@@ -576,10 +582,11 @@ public final class NativeDisplayAccess
@Override
public void keyPressed(KeyEvent __e)
{
NativeDisplayAccess._CALLBACK.keyEvent(0,
NativeDisplayEventCallback.KEY_PRESSED,
__KeyMap__.__map(__e), __KeyMap__.__char(__e),
(int)__e.getWhen());
NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
if (cbx != null)
cbx.keyEvent(0, NativeDisplayEventCallback.KEY_PRESSED,
__KeyMap__.__map(__e), __KeyMap__.__char(__e),
(int)__e.getWhen());
}
/**
......@@ -589,10 +596,11 @@ public final class NativeDisplayAccess
@Override
public void keyReleased(KeyEvent __e)
{
NativeDisplayAccess._CALLBACK.keyEvent(0,
NativeDisplayEventCallback.KEY_RELEASED,
__KeyMap__.__map(__e), __KeyMap__.__char(__e),
(int)__e.getWhen());
NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
if (cbx != null)
cbx.keyEvent(0, NativeDisplayEventCallback.KEY_RELEASED,
__KeyMap__.__map(__e), __KeyMap__.__char(__e),
(int)__e.getWhen());
}
/**
......@@ -602,10 +610,11 @@ public final class NativeDisplayAccess
@Override
public void keyTyped(KeyEvent __e)
{
NativeDisplayAccess._CALLBACK.keyEvent(0,
NativeDisplayEventCallback.KEY_PRESSED,
__KeyMap__.__map(__e), __KeyMap__.__char(__e),
(int)__e.getWhen());
NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
if (cbx != null)
cbx.keyEvent(0, NativeDisplayEventCallback.KEY_PRESSED,
__KeyMap__.__map(__e), __KeyMap__.__char(__e),
(int)__e.getWhen());
}
/**
......@@ -704,9 +713,9 @@ public final class NativeDisplayAccess
// Have the display client draw whatever is on this display, but
// only in the region we are drawing!
Rectangle rect = __g.getClipBounds();
NativeDisplayAccess._CALLBACK.paintDisplay(0,
rect.x, rect.y,
rect.width, rect.height);
NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
if (cbx != null)
cbx.paintDisplay(0, rect.x, rect.y, rect.width, rect.height);
// Draw the backed buffered image
__g.drawImage(image, 0, 0, xw, xh,
......@@ -741,7 +750,9 @@ public final class NativeDisplayAccess
todo.DEBUG.note("Window is closing!");
// Post close event
NativeDisplayAccess._CALLBACK.exitRequest(0);
NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
if (cbx != null)
cbx.exitRequest(0);
}
/**
......@@ -817,8 +828,10 @@ public final class NativeDisplayAccess
}
// Post event
NativeDisplayAccess._CALLBACK.pointerEvent(0,
__t, __e.getX(), __e.getY(), (int)__e.getWhen());
NativeDisplayEventCallback cbx = NativeDisplayAccess._CALLBACK;
if (cbx != null)
cbx.pointerEvent(0, __t, __e.getX(), __e.getY(),
(int)__e.getWhen());
}
}
}
......
......@@ -30,6 +30,8 @@ More detailed changes:
may still be implicit within ZIPs.
* Launching
* An alternative VM may be specified.
* Correct cases where `NullPointerException` is thrown when a `Display`
was initialized but was not yet claimed by any program.
* The profiler snapshot can be written to a specific file.
* System properties may be defined and passed to the launched program.
* Started work on JavaDoc generation.
......@@ -116,6 +118,8 @@ More detailed changes:
* Added string representation for the stack map table.
* Add ability to start tasks with command line arguments, system
properties, and alternative console redirection (to capture output).
* Correct cases where `NullPointerException` is thrown when a `Display`
was initialized but was not yet claimed by any program.
* SpringCoat
* Add support for system properties being based to virtual machine
instances.
......
......@@ -421,14 +421,18 @@ public class VMNativeDisplayAccess
@Override
public void commandAction(Command __c, Displayable __d)
{
NativeDisplayEventCallback cb =
VMNativeDisplayAccess.this._callback;
if (cb == null)
return;
// Exiting the VM?
if (__c.getCommandType() == Command.EXIT)
VMNativeDisplayAccess.this._callback.exitRequest(0);
cb.exitRequest(0);
// Function menu key
else if (__c.getLabel().startsWith("F"))
VMNativeDisplayAccess.this._callback.command(0,
__c.getPriority());
cb.command(0, __c.getPriority());
}
}
......@@ -450,7 +454,12 @@ public class VMNativeDisplayAccess
@Override
public void hideNotify()
{
VMNativeDisplayAccess.this._callback.shown(0, 0);
NativeDisplayEventCallback cb =
VMNativeDisplayAccess.this._callback;
if (cb == null)
return;
cb.shown(0, 0);
}
/**
......@@ -490,14 +499,18 @@ public class VMNativeDisplayAccess
@Override
public void paint(Graphics __g)
{
NativeDisplayEventCallback cb =
VMNativeDisplayAccess.this._callback;
if (cb == null)
return;
int x = __g.getClipX(),
y = __g.getClipY(),
w = __g.getClipWidth(),
h = __g.getClipHeight();
// Call paint code
VMNativeDisplayAccess.this._callback.paintDisplay(0,
x, y, w, h);
cb.paintDisplay(0, x, y, w, h);
// Just draw the raw RGB data
int fbw = VMNativeDisplayAccess.this._fbw;
......@@ -518,7 +531,12 @@ public class VMNativeDisplayAccess
@Override
public void pointerDragged(int __x, int __y)
{
VMNativeDisplayAccess.this._callback.pointerEvent(0,
NativeDisplayEventCallback cb =
VMNativeDisplayAccess.this._callback;
if (cb == null)
return;
cb.pointerEvent(0,
NativeDisplayEventCallback.POINTER_DRAGGED, __x, __y,
++this._keyindex);
}
......@@ -530,7 +548,12 @@ public class VMNativeDisplayAccess
@Override
public void pointerPressed(int __x, int __y)
{
VMNativeDisplayAccess.this._callback.pointerEvent(0,
NativeDisplayEventCallback cb =
VMNativeDisplayAccess.this._callback;
if (cb == null)
return;
cb.pointerEvent(0,
NativeDisplayEventCallback.POINTER_PRESSED, __x, __y,
++this._keyindex);
}
......@@ -542,7 +565,12 @@ public class VMNativeDisplayAccess
@Override
public void pointerReleased(int __x, int __y)
{
VMNativeDisplayAccess.this._callback.pointerEvent(0,
NativeDisplayEventCallback cb =
VMNativeDisplayAccess.this._callback;
if (cb == null)
return;
cb.pointerEvent(0,
NativeDisplayEventCallback.POINTER_RELEASED, __x, __y,
++this._keyindex);
}
......@@ -554,7 +582,12 @@ public class VMNativeDisplayAccess
@Override
public void showNotify()
{
VMNativeDisplayAccess.this._callback.shown(0, 1);
NativeDisplayEventCallback cb =
VMNativeDisplayAccess.this._callback;
if (cb == null)
return;
cb.shown(0, 1);
}
/**
......@@ -567,9 +600,13 @@ public class VMNativeDisplayAccess
// The framebuffer will need to be redone
VMNativeDisplayAccess.this.__checkFramebuffer();
NativeDisplayEventCallback cb =
VMNativeDisplayAccess.this._callback;
if (cb == null)
return;
// Post
VMNativeDisplayAccess.this._callback.sizeChanged(0,
__w, __h);
cb.sizeChanged(0, __w, __h);
}
/**
......@@ -583,6 +620,11 @@ public class VMNativeDisplayAccess
final void __postKey(int __et, int __kc)
throws NullPointerException
{
NativeDisplayEventCallback cb =
VMNativeDisplayAccess.this._callback;
if (cb == null)
return;
// Try to map to a game key if possible
try
{
......@@ -636,8 +678,7 @@ public class VMNativeDisplayAccess
}
// Post event
VMNativeDisplayAccess.this._callback.keyEvent(0,
__et, __kc, 0, ++this._keyindex);
cb.keyEvent(0, __et, __kc, 0, ++this._keyindex);
}
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment