Fix crash on Scicos exiting when simulation was stoped and some scope closed
[scilab.git] / scilab / modules / scicos_blocks / src / c / cfscope.c
index 373b42f..1a130b6 100755 (executable)
@@ -189,12 +189,22 @@ void cfscope(scicos_block * block,int flag)
        scoRetrieveScopeMemory(block->work, &pScopeMemory);
        if(scoGetScopeActivation(pScopeMemory) == 1)
          {
-           sciSetUsedWindow(scoGetWindowID(pScopeMemory));
+           /*sciSetUsedWindow(scoGetWindowID(pScopeMemory));
            pShortDraw = sciGetCurrentFigure();
            pFIGURE_FEATURE(pShortDraw)->user_data = NULL;
            pFIGURE_FEATURE(pShortDraw)->size_of_user_data = 0;
            
-           scoDelCoupleOfPolylines(pScopeMemory);
+           scoDelCoupleOfPolylines(pScopeMemory);*/
+
+                       /* Check if figure is still opened, otherwise, don't try to destroy it again. */
+                       scoGraphicalObject figure = scoGetPointerScopeWindow(pScopeMemory);
+                       if (figure != NULL)
+                       {
+                               /*pShortDraw = scoGetPointerScopeWindow(pScopeMemory);*/
+                               clearUserData(figure);
+
+                               scoDelCoupleOfPolylines(pScopeMemory);
+                       }
          }
        scoFreeScopeMemory(block->work, &pScopeMemory);
        break;