8198000: java/awt/List/EmptyListEventTest/EmptyListEventTest.java debug assert on Windows
authorarapte
Fri, 09 Nov 2018 12:08:05 +0530
changeset 52544 c1389b2371c9
parent 52543 3853631e6a07
child 52545 e944ea36af05
8198000: java/awt/List/EmptyListEventTest/EmptyListEventTest.java debug assert on Windows Reviewed-by: prr, serb
src/java.desktop/windows/native/libawt/windows/awt_List.cpp
test/jdk/java/awt/List/EmptyListEventTest/EmptyListEventTest.java
--- a/src/java.desktop/windows/native/libawt/windows/awt_List.cpp	Fri Nov 09 09:29:43 2018 +0530
+++ b/src/java.desktop/windows/native/libawt/windows/awt_List.cpp	Fri Nov 09 12:08:05 2018 +0530
@@ -478,16 +478,22 @@
 MsgRouting AwtList::HandleEvent(MSG *msg, BOOL synthetic)
 {
     if (IsFocusingMouseMessage(msg)) {
-        LONG item = static_cast<LONG>(SendListMessage(LB_ITEMFROMPOINT, 0, msg->lParam));
-        if (item != LB_ERR) {
-            if (isMultiSelect) {
-                if (IsItemSelected(item)) {
-                    Deselect(item);
-                } else {
-                    Select(item);
+        LONG count = GetCount();
+        if (count > 0) {
+            LONG item = static_cast<LONG>(SendListMessage(LB_ITEMFROMPOINT, 0, msg->lParam));
+            if (HIWORD(item) == 0) {
+                item = LOWORD(item);
+                if (item >= 0 && item < count) {
+                    if (isMultiSelect) {
+                        if (IsItemSelected(item)) {
+                            Deselect(item);
+                        } else {
+                            Select(item);
+                        }
+                    } else {
+                        Select(item);
+                    }
                 }
-            } else {
-                Select(item);
             }
         }
         delete msg;
--- a/test/jdk/java/awt/List/EmptyListEventTest/EmptyListEventTest.java	Fri Nov 09 09:29:43 2018 +0530
+++ b/test/jdk/java/awt/List/EmptyListEventTest/EmptyListEventTest.java	Fri Nov 09 12:08:05 2018 +0530
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008, 2012, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2008, 2018, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -24,7 +24,7 @@
 /*
  * @test
  * @key headful
- * @bug 6366126
+ * @bug 6366126 8198000
  * @summary List throws ArrayIndexOutOfBoundsException when pressing ENTER after removing all the items, Win32
  * @author Dmitry Cherepanov area=awt.list
  * @run main EmptyListEventTest