* bug 8630 fixed - Scopes crashed Scilab on simulation when they had the same 67/3867/2
Clément DAVID [Tue, 19 Apr 2011 14:55:42 +0000 (16:55 +0200)]
                   window id.

Change-Id: Icd4921538c5e15a2ef98ff9d5febf19a0bcef1e1

scilab/CHANGES_5.3.X
scilab/modules/scicos_blocks/src/c/cevscpe.c
scilab/modules/scicos_blocks/src/c/cmscope.c
scilab/modules/scicos_blocks/src/c/cscope.c
scilab/modules/scicos_blocks/src/c/cscopxy.c
scilab/modules/scicos_blocks/src/c/scoWindowScope.c
scilab/modules/xcos/tests/nonreg_tests/bug_8630.dia.ref [new file with mode: 0644]
scilab/modules/xcos/tests/nonreg_tests/bug_8630.tst [new file with mode: 0644]
scilab/modules/xcos/tests/nonreg_tests/bug_8630.xcos [new file with mode: 0644]

index 696bdb6..ecbde54 100644 (file)
@@ -86,6 +86,9 @@ Xcos:
 
 * bug 7479 fixed - The diagram did not update its origin on block moving.
 
+* bug 8630 fixed - Scopes crashed Scilab on simulation when they had the same
+                   window id.
+
 * bug 8692 fixed - Null block parameters was not checked before encoding.
 
 * bug 8735 fixed - Mixed (Implicit-Explicit) superblocks I/O blocks produced
index 288e106..275c30e 100755 (executable)
@@ -111,8 +111,10 @@ SCICOS_BLOCKS_IMPEXP void cevscpe_draw(scicos_block * block, ScopeMemory ** pSco
     }
   scicos_free(colors);
 
-       /* use only single buffering to be sure to draw on the screen */
-       sciSetJavaUseSingleBuffer(scoGetPointerScopeWindow(*pScopeMemory), TRUE);
+    /* use only single buffering to be sure to draw on the screen */
+    if (scoGetPointerScopeWindow(*pScopeMemory) != NULL) {
+        sciSetJavaUseSingleBuffer(scoGetPointerScopeWindow(*pScopeMemory), TRUE);
+    }
 }
 /*--------------------------------------------------------------------------*/ 
 /** \fn void cevscpe(scicos_block * block, int flag)
@@ -207,8 +209,9 @@ SCICOS_BLOCKS_IMPEXP void cevscpe(scicos_block * block, int flag)
                                                /* pFIGURE_FEATURE(pShortDraw)->user_data = NULL; */
                                                /* pFIGURE_FEATURE(pShortDraw)->size_of_user_data = 0; */
                                                /* restore double buffering */
-                                               sciSetJavaUseSingleBuffer(pShortDraw, FALSE);
-                                               scoDelCoupleOfSegments(pScopeMemory);
+                        if (pShortDraw) {
+                            sciSetJavaUseSingleBuffer(pShortDraw, FALSE);
+                        }
                                        }
                                }
                                scoFreeScopeMemory(block->work,&pScopeMemory);
index 29969a3..7504298 100644 (file)
@@ -153,7 +153,9 @@ SCICOS_BLOCKS_IMPEXP void cmscope_draw(scicos_block * block, ScopeMemory ** pSco
   scicos_free(xmax);
 
   /* use only single buffering to be sure to draw on the screen */
-  sciSetJavaUseSingleBuffer(scoGetPointerScopeWindow(*pScopeMemory), TRUE);
+  if (scoGetPointerScopeWindow(*pScopeMemory) != NULL) {
+    sciSetJavaUseSingleBuffer(scoGetPointerScopeWindow(*pScopeMemory), TRUE);
+  }
 }
 /*--------------------------------------------------------------------------*/ 
 /** \fn void cmscope(scicos_block * block, int flag)
@@ -253,8 +255,10 @@ SCICOS_BLOCKS_IMPEXP cmscope(scicos_block * block, int flag)
                                /*pShortDraw = scoGetPointerScopeWindow(pScopeMemory);*/
                                clearUserData(figure);
 
-                               sciSetJavaUseSingleBuffer(figure, FALSE);
-                         scoDelCoupleOfPolylines(pScopeMemory);
+                               /* restore double buffering */
+                               if (figure) {
+                    sciSetJavaUseSingleBuffer(figure, FALSE);
+                }
                        }
 
          }
index e0f2a1b..1604911 100644 (file)
@@ -214,9 +214,11 @@ SCICOS_BLOCKS_IMPEXP void cscope(scicos_block * block,int flag)
                        if (figure != NULL)
                        {
                                clearUserData(figure);
+                               
                                /* restore double buffering */
-                               sciSetJavaUseSingleBuffer(figure, FALSE);
-                               scoDelCoupleOfPolylines(pScopeMemory);
+                               if (figure) {
+                    sciSetJavaUseSingleBuffer(figure, FALSE);
+                }
                        }
 
          }
index fdc6ea3..ae3e326 100755 (executable)
@@ -113,8 +113,10 @@ SCICOS_BLOCKS_IMPEXP void cscopxy_draw(scicos_block * block, ScopeMemory ** pSco
       scoAddTitlesScope(*pScopeMemory,label,"x","y",NULL);
     }
 
-       /* use only single buffering to be sure to draw on the screen */
-       sciSetJavaUseSingleBuffer(scoGetPointerScopeWindow(*pScopeMemory), TRUE);
+    /* use only single buffering to be sure to draw on the screen */
+    if (scoGetPointerScopeWindow(*pScopeMemory) != NULL) {
+        sciSetJavaUseSingleBuffer(scoGetPointerScopeWindow(*pScopeMemory), TRUE);
+    }
 }
 /*--------------------------------------------------------------------------*/ 
 /** \fn void cscopxy(scicos_block * block, int flag)
@@ -192,8 +194,11 @@ SCICOS_BLOCKS_IMPEXP void cscopxy(scicos_block * block, int flag)
                                /*pFIGURE_FEATURE(Pinceau)->user_data = NULL;
                                pFIGURE_FEATURE(Pinceau)->size_of_user_data = 0;*/
                                clearUserData(figure);
+                               
                                /* restore double buffering */
-                               sciSetJavaUseSingleBuffer(figure, FALSE);
+                               if (figure) {
+                    sciSetJavaUseSingleBuffer(figure, FALSE);
+                }
                        }
        }
        scoFreeScopeMemory(block->work, &pScopeMemory);
index 3d57982..455b5e2 100644 (file)
@@ -169,7 +169,7 @@ void scoInitOfWindow(ScopeMemory * pScopeMemory, int dimension, int win_id, int
                                pSUBWIN_FEATURE(pTemp2)->SRect[1] = xmax[i];
                                break;
                        default:
-                               sciprint(_("SCOPE ERROR : scoInitOfWindow incorrect value for dimension argument.\n"));
+                               Coserror(_("Incorrect value for dimension argument."));
                                break;
                        }
                        forceRedraw(pTemp2);
@@ -193,7 +193,7 @@ void scoInitOfWindow(ScopeMemory * pScopeMemory, int dimension, int win_id, int
        }
        else
        {
-               sciprint(_("This Scope (block number : %d) has same number than another. It has been deactivated!\n"),block_number);
+               Coserror(_("This scope has the same window id than another."));
        }
 }
 /*--------------------------------------------------------------------------*/ 
@@ -284,7 +284,7 @@ void scoRefreshDataBoundsX(ScopeMemory * pScopeMemory, double t)
                                        break;
                                }
                        default:
-                               sciprint(_("SCOPE ERROR : Cannot use scoRefreshDataBoundsX() with this type of object\n"));
+                               Coserror(_("Cannot use %s with this type of object."), "scoRefreshDataBoundsX");
                                break;
                        }
                        /* Dont forget to reinit it */
@@ -386,7 +386,7 @@ void scoDrawScopeAmplitudeTimeStyle(ScopeMemory * pScopeMemory, double t)
                        break;
 
                default:
-                       sciprint(_("SCOPE ERROR : Cannot use scoDrawScopeAmplitudeTimeStyle() with this type of object\n"));
+                       Coserror(_("Cannot use %s with this type of object."), "scoDrawScopeAmplitudeTimeStyle");
                        break;
                }
 
@@ -419,7 +419,7 @@ void scoDrawScopeAmplitudeTimeStyle(ScopeMemory * pScopeMemory, double t)
                        break;
 
                default:
-                       sciprint(_("SCOPE ERROR : Cannot use scoDrawScopeAmplitudeTimeStyle() with this type of object\n"));
+                       Coserror(_("Cannot use %s with this type of object."), "scoDrawScopeAmplitudeTimeStyle");
                        break;
                }
 
@@ -438,7 +438,7 @@ void scoDrawScopeAmplitudeTimeStyle(ScopeMemory * pScopeMemory, double t)
                                NbrPtsLong = pSEGS_FEATURE(pLongDraw)->Nbr1;
                                break;
                        default:
-                               sciprint(_("SCOPE ERROR : Cannot use scoDrawScopeAmplitudeTimeStyle() with this type of object\n"));
+                               Coserror(_("Cannot use %s with this type of object."), "scoDrawScopeAmplitudeTimeStyle");
                                break;
                        }
 
@@ -497,7 +497,7 @@ void scoDrawScopeAmplitudeTimeStyle(ScopeMemory * pScopeMemory, double t)
                        NbrPtsShort = pSEGS_FEATURE(pShortDraw)->Nbr1;
                        break;
                default:
-                       sciprint(_("SCOPE ERROR : Cannot use scoDrawScopeAmplitudeTimeStyle() with this type of object\n"));
+                       Coserror(_("Cannot use %s with this type of object."), "scoDrawScopeAmplitudeTimeStyle");
                        break;
                }
                if (force_update[i] == 1) //** scope need a redraw 
@@ -513,7 +513,7 @@ void scoDrawScopeAmplitudeTimeStyle(ScopeMemory * pScopeMemory, double t)
                                NbrPtsLong = pSEGS_FEATURE(pLongDraw)->Nbr1;
                                break;
                        default:
-                               sciprint(_("SCOPE ERROR : Cannot use scoDrawScopeAmplitudeTimeStyle() with this type of object\n"));
+                               Coserror(_("Cannot use %s with this type of object."), "scoDrawScopeAmplitudeTimeStyle");
                                break;
                        }
 
@@ -545,7 +545,7 @@ void scoDrawScopeAmplitudeTimeStyle(ScopeMemory * pScopeMemory, double t)
                                        pSEGS_FEATURE(pLongDraw)->Nbr2 = NbrPtsLong+NbrPtsShort;
                                        break;
                                default:
-                                       sciprint(_("SCOPE ERROR : Cannot use scoDrawScopeAmplitudeTimeStyle() with this type of object\n"));
+                                       Coserror(_("Cannot use %s with this type of object."), "scoDrawScopeAmplitudeTimeStyle");
                                        break;
                                }
                                /*End of Block for Memory*/
@@ -576,7 +576,7 @@ void scoDrawScopeAmplitudeTimeStyle(ScopeMemory * pScopeMemory, double t)
                                                /* Do Nothing */
                                                break;
                                        default:
-                                               sciprint(_("SCOPE ERROR : Cannot use scoDrawScopeAmplitudeTimeStyle() with this type of object\n"));
+                                               Coserror(_("Cannot use %s with this type of object."), "scoDrawScopeAmplitudeTimeStyle");
                                                break;
                                        }
                                }
diff --git a/scilab/modules/xcos/tests/nonreg_tests/bug_8630.dia.ref b/scilab/modules/xcos/tests/nonreg_tests/bug_8630.dia.ref
new file mode 100644 (file)
index 0000000..d9b8bb4
--- /dev/null
@@ -0,0 +1,25 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Clément DAVID
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+// <-- TEST WITH XCOS -->
+//
+// <-- Non-regression test for bug 8630 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=8630
+//
+// <-- Short Description -->
+// Scilab crash when simulating scopes with the same window ids.
+loadXcosLibs();
+status = importXcosDiagram(SCI + "/modules/xcos/tests/nonreg_tests/bug_8630.xcos");
+if ~status then bugmes();quit;end
+prot = funcprot();
+funcprot(0);
+deff("disp(str)", "");
+funcprot(prot);
+// compile and simulate
+xcos_simulate(scs_m, 4);
+clear disp;
diff --git a/scilab/modules/xcos/tests/nonreg_tests/bug_8630.tst b/scilab/modules/xcos/tests/nonreg_tests/bug_8630.tst
new file mode 100644 (file)
index 0000000..6554d5e
--- /dev/null
@@ -0,0 +1,32 @@
+// =============================================================================
+// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
+// Copyright (C) 2011 - DIGITEO - Clément DAVID
+//
+//  This file is distributed under the same license as the Scilab package.
+// =============================================================================
+
+// <-- TEST WITH XCOS -->
+//
+// <-- Non-regression test for bug 8630 -->
+//
+// <-- Bugzilla URL -->
+// http://bugzilla.scilab.org/show_bug.cgi?id=8630
+//
+// <-- Short Description -->
+// Scilab crash when simulating scopes with the same window ids.
+
+loadXcosLibs();
+
+status = importXcosDiagram(SCI + "/modules/xcos/tests/nonreg_tests/bug_8630.xcos");
+if ~status then pause, end
+
+prot = funcprot();
+funcprot(0);
+deff("disp(str)", "");
+funcprot(prot);
+
+// compile and simulate
+xcos_simulate(scs_m, 4);
+
+clear disp;
+
diff --git a/scilab/modules/xcos/tests/nonreg_tests/bug_8630.xcos b/scilab/modules/xcos/tests/nonreg_tests/bug_8630.xcos
new file mode 100644 (file)
index 0000000..b1270d8
Binary files /dev/null and b/scilab/modules/xcos/tests/nonreg_tests/bug_8630.xcos differ