8189204: Possible NPE in Component::getLocationOnScreen()

Reviewed-by: serb, prr
This commit is contained in:
Semyon Sadetsky 2017-11-22 13:52:48 -08:00
parent e27e8b9e39
commit 48508135fe
2 changed files with 62 additions and 2 deletions

View file

@ -2039,14 +2039,14 @@ public abstract class Component implements ImageObserver, MenuContainer,
* used by GlobalCursormanager to update cursor
*/
final Point getLocationOnScreen_NoTreeLock() {
ComponentPeer peer = this.peer;
if (peer != null && isShowing()) {
if (peer instanceof LightweightPeer) {
// lightweight component location needs to be translated
// relative to a native component.
Container host = getNativeContainer();
Point pt = host.peer.getLocationOnScreen();
for(Component c = this; c != host; c = c.getParent()) {
for(Component c = this; c != host; c = c.getContainer()) {
pt.x += c.x;
pt.y += c.y;
}