Graphics: fix handle.tag / gca() / clf() crash
[scilab.git] / scilab / modules / graphic_objects / src / cpp / createGraphicObject.cpp
index 98fd49d..3ace6b4 100644 (file)
@@ -158,6 +158,15 @@ int createFigure(int iDockable, int iMenubarType, int iToolbarType, int iDefault
     {
         int* pUserData = NULL;
         getGraphicObjectProperty(getFigureModel(), __GO_USER_DATA__, jni_int_vector, (void**)&pUserData);
+        if (sizeof(void*) == 4) //32 bits
+        {
+            increaseValRef(NULL, (int*)* (int*)pUserData);
+        }
+        else //64 bits
+        {
+            increaseValRef(NULL, (int*)* (long long*)pUserData);
+        }
+
         setGraphicObjectProperty(id, __GO_USER_DATA__, pUserData, jni_int_vector, iUserDataSize);
     }
 
@@ -167,6 +176,15 @@ int createFigure(int iDockable, int iMenubarType, int iToolbarType, int iDefault
     {
         int* pUserData = NULL;
         getGraphicObjectProperty(getAxesModel(), __GO_USER_DATA__, jni_int_vector, (void**)&pUserData);
+        if (sizeof(void*) == 4) //32 bits
+        {
+            increaseValRef(NULL, (int*)* (int*)pUserData);
+        }
+        else //64 bits
+        {
+            increaseValRef(NULL, (int*)* (long long*)pUserData);
+        }
+
         setGraphicObjectProperty(getCurrentSubWin(), __GO_USER_DATA__, pUserData, jni_int_vector, iUserDataSize);
     }