changeset 6448:d550116b8d71

RT-35619 : IMX6-SDP / Yocto hard float : crash while running hello.HelloComboBox Reviewed-by : kselle, dblaukopf
author Rafi Tayar <rafi.tayar@oracle.com>
date Tue, 11 Mar 2014 17:54:41 +0200
parents 685651bc38c2
children c508ecd2723b
files modules/graphics/src/main/native-glass/lens/LensCommon.h modules/graphics/src/main/native-glass/lens/LensWindow.c modules/graphics/src/main/native-glass/lens/wm/LensWindowManager.c
diffstat 3 files changed, 23 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/modules/graphics/src/main/native-glass/lens/LensCommon.h	Tue Mar 11 16:15:55 2014 +0100
+++ b/modules/graphics/src/main/native-glass/lens/LensCommon.h	Tue Mar 11 17:54:41 2014 +0200
@@ -995,6 +995,15 @@
 void glass_window_list_lock();
 
 /**
+ * Check that *window* exists in the windows list. Not 
+ * using locks. Use glass_window_list_lock() 
+ * and glass_window_list_unlock() before and after the 
+ * function call.
+ * @return true - if window exists, false otherwise.
+ */
+jboolean glass_window_isExist(NativeWindow window);
+
+/**
  * Unlock the windows list.
  */
 void glass_window_list_unlock();
--- a/modules/graphics/src/main/native-glass/lens/LensWindow.c	Tue Mar 11 16:15:55 2014 +0100
+++ b/modules/graphics/src/main/native-glass/lens/LensWindow.c	Tue Mar 11 17:54:41 2014 +0200
@@ -796,7 +796,7 @@
     return windowList_size;
 }
 
-static jboolean glass_window_isExist(NativeWindow window){
+jboolean glass_window_isExist(NativeWindow window){
 
     NativeWindow w = glass_window_list_getHead();
     while (w) {
--- a/modules/graphics/src/main/native-glass/lens/wm/LensWindowManager.c	Tue Mar 11 16:15:55 2014 +0100
+++ b/modules/graphics/src/main/native-glass/lens/wm/LensWindowManager.c	Tue Mar 11 17:54:41 2014 +0200
@@ -1198,15 +1198,20 @@
     }
     
     if (touchWindow != NULL) {
-        dx = -touchWindow->currentBounds.x;
-        dy = -touchWindow->currentBounds.y;
-        glass_application_notifyMultiTouchEvent(env, touchWindow, count,
-                                                states, ids, xabs, yabs,
-                                                dx, dy);
-        if (primaryPointIndex == -1) {
-            //all released
-            touchWindow = NULL;
+        //Check that touchWindow is still valid before using it. 
+        glass_window_list_lock();
+        if (glass_window_isExist(touchWindow)) {
+            dx = -touchWindow->currentBounds.x;
+            dy = -touchWindow->currentBounds.y;
+            glass_application_notifyMultiTouchEvent(env, touchWindow, count,
+                                                    states, ids, xabs, yabs,
+                                                    dx, dy);
+            if (primaryPointIndex == -1) {
+                //all released
+                touchWindow = NULL;
+            }
         }
+        glass_window_list_unlock();
     }
    
 }