summaryrefslogtreecommitdiffstats
path: root/scilab/modules
diff options
context:
space:
mode:
authorSylvestre Ledru <sylvestre.ledru@scilab.org>2008-10-27 11:31:47 +0100
committerSylvestre Ledru <sylvestre.ledru@scilab.org>2008-10-27 11:31:47 +0100
commit7646ebc4b6d021f63eb837d074e4899322a16f3c (patch)
tree8202eb6605c57c966b735f590d2b438312c5281d /scilab/modules
parent7d99f2607ed7ab870cafc955a2ccc2c957a9f9a4 (diff)
parent08807d3e3ec818419ecf4598c39d531f6d567a75 (diff)
downloadscilab-7646ebc4b6d021f63eb837d074e4899322a16f3c.zip
scilab-7646ebc4b6d021f63eb837d074e4899322a16f3c.tar.gz
Merge branch '5.0' of git@git.scilab.org:scilab into 5.0
Diffstat (limited to 'scilab/modules')
-rw-r--r--scilab/modules/dynamic_link/sci_gateway/c/sci_link.c11
-rw-r--r--scilab/modules/dynamic_link/src/c/dynamic_link.c28
-rw-r--r--scilab/modules/dynamic_link/tests/nonreg_tests/bug_3639.c93
-rw-r--r--scilab/modules/dynamic_link/tests/nonreg_tests/bug_3639.tst70
-rw-r--r--scilab/modules/dynamic_link/tests/nonreg_tests/bug_3639.win.dia.ref114
-rw-r--r--scilab/modules/graphics/includes/GetProperty.h1
-rw-r--r--scilab/modules/graphics/includes/ObjectStructure.h5
-rw-r--r--scilab/modules/graphics/includes/SetProperty.h3
-rw-r--r--scilab/modules/graphics/locales/fr_FR/graphics.po2
-rw-r--r--scilab/modules/graphics/sci_gateway/c/sci_xname.c2
-rw-r--r--scilab/modules/graphics/src/c/BuildObjects.c3
-rw-r--r--scilab/modules/graphics/src/c/GetProperty.c27
-rw-r--r--scilab/modules/graphics/src/c/InitObjects.c6
-rw-r--r--scilab/modules/graphics/src/c/SetProperty.c124
-rw-r--r--scilab/modules/graphics/src/c/getHandleProperty/set_figure_name_property.c2
-rw-r--r--scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJavaMapper.cpp8
-rw-r--r--scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJavaMapper.hxx4
-rw-r--r--scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJoGL.cpp12
18 files changed, 388 insertions, 127 deletions
diff --git a/scilab/modules/dynamic_link/sci_gateway/c/sci_link.c b/scilab/modules/dynamic_link/sci_gateway/c/sci_link.c
index 9219c76..a3f6e03 100644
--- a/scilab/modules/dynamic_link/sci_gateway/c/sci_link.c
+++ b/scilab/modules/dynamic_link/sci_gateway/c/sci_link.c
@@ -182,16 +182,7 @@ static int linkNoRhs(void)
182 LhsVar(1)=Rhs+1; 182 LhsVar(1)=Rhs+1;
183 C2F(putlhsvar)(); 183 C2F(putlhsvar)();
184 184
185 for (i=0;i < sizeFunctionsList;i++) 185 freeArrayOfString(FunctionsList,sizeFunctionsList);
186 {
187 if (FunctionsList[i])
188 {
189 FREE(FunctionsList[i]);
190 FunctionsList[i]=NULL;
191 }
192 }
193 FREE(FunctionsList);
194 FunctionsList = NULL;
195 } 186 }
196 else 187 else
197 { 188 {
diff --git a/scilab/modules/dynamic_link/src/c/dynamic_link.c b/scilab/modules/dynamic_link/src/c/dynamic_link.c
index fb5f6f0..aad7d87 100644
--- a/scilab/modules/dynamic_link/src/c/dynamic_link.c
+++ b/scilab/modules/dynamic_link/src/c/dynamic_link.c
@@ -169,21 +169,25 @@ char **getNamesOfFunctionsInSharedLibraries(int *sizearray)
169 char **NamesOfFunctions = NULL; 169 char **NamesOfFunctions = NULL;
170 *sizearray = 0; 170 *sizearray = 0;
171 171
172 if (NEpoints) 172 if ( (NEpoints) && (NEpoints > 0) )
173 { 173 {
174 int i=0; 174 int i = 0;
175 for ( i = NEpoints-1 ; i >=0 ; i--) 175 NamesOfFunctions = (char **) MALLOC((NEpoints)*sizeof(char *));
176 if (NamesOfFunctions)
176 { 177 {
177 if (EP[i].name) 178 for ( i = NEpoints-1 ; i >= 0 ; i--)
178 { 179 {
179 char *EntryName=(char *)MALLOC(strlen(EP[i].name)*sizeof(char)); 180 if (EP[i].name)
180 181 {
181 (*sizearray)++; 182 char *EntryName = (char *)MALLOC(((int)strlen(EP[i].name)+1)*sizeof(char));
182 if (NamesOfFunctions) NamesOfFunctions = (char **) REALLOC(NamesOfFunctions,(*sizearray)*sizeof(char *)); 183
183 else NamesOfFunctions = (char **) MALLOC((*sizearray)*sizeof(char *)); 184 if (EntryName)
184 185 {
185 strcpy(EntryName,EP[i].name); 186 (*sizearray)++;
186 NamesOfFunctions[(*sizearray)-1]=EntryName; 187 strcpy(EntryName , EP[i].name);
188 NamesOfFunctions[(*sizearray)-1] = EntryName;
189 }
190 }
187 } 191 }
188 } 192 }
189 } 193 }
diff --git a/scilab/modules/dynamic_link/tests/nonreg_tests/bug_3639.c b/scilab/modules/dynamic_link/tests/nonreg_tests/bug_3639.c
new file mode 100644
index 0000000..c0a4d49
--- /dev/null
+++ b/scilab/modules/dynamic_link/tests/nonreg_tests/bug_3639.c
@@ -0,0 +1,93 @@
1/* ============================================== */
2#include "stack-c.h"
3#include "sciprint.h"
4/* ============================================== */
5/* Interfaces for c fonctions */
6/* ============================================== */
7void c_sum(double *b, double *c, double *a);
8void c_sub(double *b, double *c, double *a);
9/* ============================================== */
10int c_intsum(char *fname)
11{
12 int l1=0, m1=0, n1=0, l2=0, m2=0, n2=0, l3=0, m3=1, n3=1;
13 int minlhs=1, maxlhs=1, minrhs=2, maxrhs=2;
14
15 /* Check number of inputs (rhs=2) and outputs (lhs=1) */
16 CheckRhs(minrhs,maxrhs) ;
17 CheckLhs(minlhs,maxlhs) ;
18
19 /* Get Qdata (#1) and Param (#2) and create C (#3) as double ("d") matrices */
20 GetRhsVar(1, MATRIX_OF_DOUBLE_DATATYPE, &m1, &n1, &l1); /* b */
21 GetRhsVar(2, MATRIX_OF_DOUBLE_DATATYPE, &m2, &n2, &l2); /* c */
22
23 CreateVar(Rhs+1, MATRIX_OF_DOUBLE_DATATYPE, &m3, &n3, &l3); /* Result : a = b+c */
24
25 /* Check dimensions */
26 if (!(m1==1)|!(n1==1))
27 {
28 sciprint("%s: Wrong inputs \r\n", "c_fun");
29 Error(999);
30 return 0;
31 }
32 if (!(m2==1)|!(n2==1))
33 {
34 sciprint("%s: Wrong inputs \r\n", "c_fun");
35 Error(999);
36 return 0;
37 }
38
39 /* Call c_fun */
40 c_sum(stk(l1),stk(l2),stk(l3));
41
42 /* Return result */
43 LhsVar(1) = Rhs+1;
44 return 0;
45}
46/* ============================================== */
47int c_intsub(char *fname)
48{
49 int l1=0, m1=0, n1=0, l2=0, m2=0, n2=0, l3=0, m3=1, n3=1;
50 int minlhs=1, maxlhs=1, minrhs=2, maxrhs=2;
51
52 /* Check number of inputs (rhs=2) and outputs (lhs=1) */
53 CheckRhs(minrhs,maxrhs) ;
54 CheckLhs(minlhs,maxlhs) ;
55
56 /* Get Qdata (#1) and Param (#2) and create C (#3) as double ("d") matrices */
57 GetRhsVar(1, MATRIX_OF_DOUBLE_DATATYPE, &m1, &n1, &l1); /* b */
58 GetRhsVar(2, MATRIX_OF_DOUBLE_DATATYPE, &m2, &n2, &l2); /* c */
59
60 CreateVar(Rhs+1, MATRIX_OF_DOUBLE_DATATYPE, &m3, &n3, &l3); /* Result : a = b-c */
61
62 /* Check dimensions */
63 if (!(m1==1)|!(n1==1))
64 {
65 sciprint("%s: Wrong inputs \r\n", "c_fun");
66 Error(999);
67 return 0;
68 }
69 if (!(m2==1)|!(n2==1))
70 {
71 sciprint("%s: Wrong inputs \r\n", "c_fun");
72 Error(999);
73 return 0;
74 }
75
76 /* Call c_fun */
77 c_sub(stk(l1),stk(l2),stk(l3));
78
79 /* Return result */
80 LhsVar(1) = Rhs+1;
81 return 0;
82}
83/* ============================================== */
84void c_sum(double *b, double *c, double *a)
85{
86 *a = *b + *c;
87}
88/* ============================================== */
89void c_sub(double *b, double *c, double *a)
90{
91 *a = *b -*c;
92}
93/* ============================================== */ \ No newline at end of file
diff --git a/scilab/modules/dynamic_link/tests/nonreg_tests/bug_3639.tst b/scilab/modules/dynamic_link/tests/nonreg_tests/bug_3639.tst
new file mode 100644
index 0000000..7cfa743
--- /dev/null
+++ b/scilab/modules/dynamic_link/tests/nonreg_tests/bug_3639.tst
@@ -0,0 +1,70 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2008 - DIGITEO - Allan CORNET
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7
8// <-- Non-regression test for bug 3639 -->
9//
10// <-- Bugzilla URL -->
11// http://bugzilla.scilab.org/show_bug.cgi?id=3639
12//
13// <-- Short Description -->
14// link without parameters can crash
15
16
17test_path = get_absolute_file_path('bug_3639.tst');
18
19currentpath = pwd();
20
21cd TMPDIR;
22cd ../;
23OS_TMP_DIR = pwd();
24
25
26mkdir(OS_TMP_DIR,'bug_3639');
27TEST_DIR = OS_TMP_DIR + filesep() + 'bug_3639';
28
29copyfile(SCI+'/modules/dynamic_link/tests/nonreg_tests/bug_3639.c' , TEST_DIR + filesep() + 'bug_3639.c');
30
31chdir(TEST_DIR);
32
33files=['bug_3639.o'];
34ilib_build('libc_fun1',['c_sum1','c_intsum';'c_sub1','c_intsub'],files,[]);
35copyfile('loader.sce','loader1.sce');
36
37ilib_build('libc_fun2',['c_sum2','c_intsum';'c_sub2','c_intsub'],files,[]);
38
39
40// disable message
41warning_mode = warning('query');
42warning('off');
43
44// load the shared library
45info_link = link();
46if info_link <> [] then pause,end
47
48exec loader1.sce
49info_link = link();
50if info_link <> 'libc_fun1' then pause,end
51
52exec loader.sce
53info_link = link();
54if or(info_link <> ['libc_fun2','libc_fun1']) then pause,end
55
56// enable message
57warning(warning_mode);
58
59chdir(currentpath);
60
61// ulink() all libraries
62ulink();
63clearfun('c_sum1');
64clearfun('c_sub1');
65clearfun('c_sum2');
66clearfun('c_sub2');
67
68//remove TMP_DIR
69rmdir(TEST_DIR,'s');
70// =============================================================================
diff --git a/scilab/modules/dynamic_link/tests/nonreg_tests/bug_3639.win.dia.ref b/scilab/modules/dynamic_link/tests/nonreg_tests/bug_3639.win.dia.ref
new file mode 100644
index 0000000..a9ff543
--- /dev/null
+++ b/scilab/modules/dynamic_link/tests/nonreg_tests/bug_3639.win.dia.ref
@@ -0,0 +1,114 @@
1// =============================================================================
2// Scilab ( http://www.scilab.org/ ) - This file is part of Scilab
3// Copyright (C) 2008 - DIGITEO - Allan CORNET
4//
5// This file is distributed under the same license as the Scilab package.
6// =============================================================================
7// <-- Non-regression test for bug 3639 -->
8//
9// <-- Bugzilla URL -->
10// http://bugzilla.scilab.org/show_bug.cgi?id=3639
11//
12// <-- Short Description -->
13// link without parameters can crash
14test_path = get_absolute_file_path('bug_3639.tst');
15currentpath = pwd();
16cd TMPDIR;
17cd ../;
18OS_TMP_DIR = pwd();
19mkdir(OS_TMP_DIR,'bug_3639');
20TEST_DIR = OS_TMP_DIR + filesep() + 'bug_3639';
21copyfile(SCI+'/modules/dynamic_link/tests/nonreg_tests/bug_3639.c' , TEST_DIR + filesep() + 'bug_3639.c');
22chdir(TEST_DIR);
23files=['bug_3639.o'];
24ilib_build('libc_fun1',['c_sum1','c_intsum';'c_sub1','c_intsub'],files,[]);
25 Generate a gateway file
26 Generate a loader file
27 Generate a Makefile: Makelib
28 Running the makefile
29 Compilation of bug_3639
30 Building shared library (be patient)
31copyfile('loader.sce','loader1.sce');
32ilib_build('libc_fun2',['c_sum2','c_intsum';'c_sub2','c_intsub'],files,[]);
33 Generate a gateway file
34 Generate a loader file
35 Generate a Makefile: Makelib
36 Running the makefile
37 Compilation of bug_3639
38 Building shared library (be patient)
39// disable message
40warning_mode = warning('query');
41warning('off');
42// load the shared library
43info_link = link();
44if info_link <> [] then bugmes();quit;end
45exec loader1.sce
46
47// ------------------------------------------------------
48
49// generated by builder.sce: Please do not edit this file
50
51// ------------------------------------------------------
52
53
54libc_fun1_path = get_file_path('loader.sce');
55
56list_functions = [ 'c_sum1';
57 'c_sub1';
58];
59
60addinter(libc_fun1_path+'/libc_fun1.dll','libc_fun1',list_functions);
61
62// remove temp. variables on stack
63
64clear libc_fun1_path;
65
66clear list_functions;
67
68clear get_file_path;
69
70// ------------------------------------------------------
71
72info_link = link();
73if info_link <> 'libc_fun1' then bugmes();quit;end
74exec loader.sce
75
76// ------------------------------------------------------
77
78// generated by builder.sce: Please do not edit this file
79
80// ------------------------------------------------------
81
82
83libc_fun2_path = get_file_path('loader.sce');
84
85list_functions = [ 'c_sum2';
86 'c_sub2';
87];
88
89addinter(libc_fun2_path+'/libc_fun2.dll','libc_fun2',list_functions);
90
91// remove temp. variables on stack
92
93clear libc_fun2_path;
94
95clear list_functions;
96
97clear get_file_path;
98
99// ------------------------------------------------------
100
101info_link = link();
102if or(info_link <> ['libc_fun2','libc_fun1']) then bugmes();quit;end
103// enable message
104warning(warning_mode);
105chdir(currentpath);
106// ulink() all libraries
107ulink();
108clearfun('c_sum1');
109clearfun('c_sub1');
110clearfun('c_sum2');
111clearfun('c_sub2');
112//remove TMP_DIR
113rmdir(TEST_DIR,'s');
114// =============================================================================
diff --git a/scilab/modules/graphics/includes/GetProperty.h b/scilab/modules/graphics/includes/GetProperty.h
index afcb165a..3dd21e4 100644
--- a/scilab/modules/graphics/includes/GetProperty.h
+++ b/scilab/modules/graphics/includes/GetProperty.h
@@ -114,7 +114,6 @@ BOOL sciGetResize (sciPointObj * pobj); /* GET */
114 114
115/* Window Functions */ 115/* Window Functions */
116char *sciGetName (sciPointObj * pobj); /* GET */ 116char *sciGetName (sciPointObj * pobj); /* GET */
117int sciGetNameLength (sciPointObj * pobj); /* GET */
118int sciGetNum (sciPointObj * pobj); /* GET */ 117int sciGetNum (sciPointObj * pobj); /* GET */
119int sciGetWidth (sciPointObj * pobj); /* GET */ 118int sciGetWidth (sciPointObj * pobj); /* GET */
120int sciGetHeight (sciPointObj * pobj); /* GET */ 119int sciGetHeight (sciPointObj * pobj); /* GET */
diff --git a/scilab/modules/graphics/includes/ObjectStructure.h b/scilab/modules/graphics/includes/ObjectStructure.h
index e2706ba..dfac872 100644
--- a/scilab/modules/graphics/includes/ObjectStructure.h
+++ b/scilab/modules/graphics/includes/ObjectStructure.h
@@ -454,9 +454,8 @@ typedef struct
454 sciGraphicContext graphiccontext; /* the only property used here is background */ 454 sciGraphicContext graphiccontext; /* the only property used here is background */
455 sciPointObj * originalsubwin0011; 455 sciPointObj * originalsubwin0011;
456 /** specifies the title for this window */ 456 /** specifies the title for this window */
457 char name[SCI_FIGURE_NAME_LENGTH]; 457 char * name;
458 /** specifies le length of the string name */ 458
459 int namelen;
460 /** specifies the number of this window */ 459 /** specifies the number of this window */
461 int number; 460 int number;
462 461
diff --git a/scilab/modules/graphics/includes/SetProperty.h b/scilab/modules/graphics/includes/SetProperty.h
index ac9fe62..77ba172 100644
--- a/scilab/modules/graphics/includes/SetProperty.h
+++ b/scilab/modules/graphics/includes/SetProperty.h
@@ -155,7 +155,8 @@ int sciSetDefaultValues (void); /* SET */
155 155
156 156
157/* Window Functions */ 157/* Window Functions */
158int sciSetName (sciPointObj * pobj, char *pvalue, int length); /* SET */ 158int sciInitName(sciPointObj * pobj, char * newName); /* SET */
159int sciSetName (sciPointObj * pobj, char * newName); /* SET */
159int sciInitNum( sciPointObj * pobj, int value ) ; 160int sciInitNum( sciPointObj * pobj, int value ) ;
160int sciSetNum ( sciPointObj * pobj, int value ) ; /* SET */ 161int sciSetNum ( sciPointObj * pobj, int value ) ; /* SET */
161 162
diff --git a/scilab/modules/graphics/locales/fr_FR/graphics.po b/scilab/modules/graphics/locales/fr_FR/graphics.po
index 38a64ef..11c4f56 100644
--- a/scilab/modules/graphics/locales/fr_FR/graphics.po
+++ b/scilab/modules/graphics/locales/fr_FR/graphics.po
@@ -623,7 +623,7 @@ msgstr ""
623 623
624#, c-format 624#, c-format
625msgid "Graphic window number %d" 625msgid "Graphic window number %d"
626msgstr "Figure n°%d" 626msgstr "Figure n %d"
627 627
628msgid "This object has not any graphic mode\n" 628msgid "This object has not any graphic mode\n"
629msgstr "" 629msgstr ""
diff --git a/scilab/modules/graphics/sci_gateway/c/sci_xname.c b/scilab/modules/graphics/sci_gateway/c/sci_xname.c
index 3afa15b..5635634 100644
--- a/scilab/modules/graphics/sci_gateway/c/sci_xname.c
+++ b/scilab/modules/graphics/sci_gateway/c/sci_xname.c
@@ -32,7 +32,7 @@ int sci_xname(char *fname,unsigned long fname_len)
32 CheckLhs(1,1); 32 CheckLhs(1,1);
33 GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1); 33 GetRhsVar(1,STRING_DATATYPE,&m1,&n1,&l1);
34 34
35 sciSetName( sciGetCurrentFigure(), cstk(l1), m1 ) ; 35 sciSetName( sciGetCurrentFigure(), cstk(l1) ) ;
36 36
37 LhsVar(1)=0; 37 LhsVar(1)=0;
38 return 0; 38 return 0;
diff --git a/scilab/modules/graphics/src/c/BuildObjects.c b/scilab/modules/graphics/src/c/BuildObjects.c
index 237d0a1..6da6418 100644
--- a/scilab/modules/graphics/src/c/BuildObjects.c
+++ b/scilab/modules/graphics/src/c/BuildObjects.c
@@ -203,7 +203,8 @@ sciPointObj * ConstructFigure(sciPointObj * pparent, int * figureIndex)
203 /* Set default figure index */ 203 /* Set default figure index */
204 sciInitNum(pobj, getUnusedFigureIndex()); 204 sciInitNum(pobj, getUnusedFigureIndex());
205 } 205 }
206 sciSetName(pobj, sciGetName(pfiguremdl), sciGetNameLength(pfiguremdl)); 206
207 sciInitName(pobj, sciGetName(pfiguremdl));
207 sciInitResize(pobj,sciGetResize(pfiguremdl)); 208 sciInitResize(pobj,sciGetResize(pfiguremdl));
208 209
209 ppFigure->isiconified = ppModel->isiconified; 210 ppFigure->isiconified = ppModel->isiconified;
diff --git a/scilab/modules/graphics/src/c/GetProperty.c b/scilab/modules/graphics/src/c/GetProperty.c
index 3381693..d0557e5 100644
--- a/scilab/modules/graphics/src/c/GetProperty.c
+++ b/scilab/modules/graphics/src/c/GetProperty.c
@@ -2029,38 +2029,13 @@ sciGetName (sciPointObj * pobj)
2029 case SCI_SUBWIN: 2029 case SCI_SUBWIN:
2030 case SCI_AGREG: 2030 case SCI_AGREG:
2031 default: 2031 default:
2032 printSetGetErrorMessage("name"); 2032 printSetGetErrorMessage("figure_name");
2033 return NULL; 2033 return NULL;
2034 break; 2034 break;
2035 } 2035 }
2036} 2036}
2037 2037
2038 2038
2039/**sciGetNameLength
2040 * Returns the length of the name of the Figure or SubWindow
2041 * @param sciPointObj * pobj: the pointer to the entity
2042 * @return the length of the Name
2043 */
2044int
2045sciGetNameLength (sciPointObj * pobj)
2046{
2047 switch (sciGetEntityType (pobj))
2048 {
2049 case SCI_FIGURE:
2050 return pFIGURE_FEATURE (pobj)->namelen;
2051 break;
2052 case SCI_SUBWIN:
2053 return pSUBWIN_FEATURE (pobj)->namelen;
2054 break;
2055 case SCI_AGREG:
2056 default:
2057 printSetGetErrorMessage("name");
2058 return 0;
2059 break;
2060 }
2061}
2062
2063
2064/**sciGetNum 2039/**sciGetNum
2065 * Returns the number of the Figure. 2040 * Returns the number of the Figure.
2066 * @param sciPointObj * pobj: the pointer to the entity 2041 * @param sciPointObj * pobj: the pointer to the entity
diff --git a/scilab/modules/graphics/src/c/InitObjects.c b/scilab/modules/graphics/src/c/InitObjects.c
index b45dceb..2966e4f 100644
--- a/scilab/modules/graphics/src/c/InitObjects.c
+++ b/scilab/modules/graphics/src/c/InitObjects.c
@@ -508,8 +508,8 @@ int InitFigureModel( void )
508 /* F.Leray 10.06.04 */ 508 /* F.Leray 10.06.04 */
509 return -1 ; 509 return -1 ;
510 } 510 }
511 strncpy (pFIGURE_FEATURE (pfiguremdl)->name, _("Graphic window number %d"), strlen(_("Graphic window number %d"))*sizeof(char) + 4); 511
512 pFIGURE_FEATURE (pfiguremdl)->namelen = Min ((int)strlen(_("Graphic window number %d"))*sizeof(char) + 4, 24); 512 sciInitName(pfiguremdl, _("Graphic window number %d"));
513 pFIGURE_FEATURE (pfiguremdl)->number = 0 ; 513 pFIGURE_FEATURE (pfiguremdl)->number = 0 ;
514 514
515 /* Set figure model attributes */ 515 /* Set figure model attributes */
@@ -804,7 +804,7 @@ int ResetFigureToDefaultValues(sciPointObj * pobj)
804 return -1; 804 return -1;
805 } 805 }
806 /* sciSetNum(pobj, getUnusedFigureIndex()); Number can not be modified */ 806 /* sciSetNum(pobj, getUnusedFigureIndex()); Number can not be modified */
807 sciSetName(pobj, sciGetName(pfiguremdl), sciGetNameLength(pfiguremdl)); 807 sciInitName(pobj, sciGetName(pfiguremdl));
808 sciSetResize((sciPointObj *) pobj,sciGetResize(pobj)); 808 sciSetResize((sciPointObj *) pobj,sciGetResize(pobj));
809 sciSetWindowDim( pobj, sciGetWindowWidth(pfiguremdl), sciGetWindowHeight(pfiguremdl) ) ; 809 sciSetWindowDim( pobj, sciGetWindowWidth(pfiguremdl), sciGetWindowHeight(pfiguremdl) ) ;
810 if (sciSetDimension( pobj, sciGetWidth(pfiguremdl), sciGetHeight(pfiguremdl) ) != RESIZE_SUCCESS) 810 if (sciSetDimension( pobj, sciGetWidth(pfiguremdl), sciGetHeight(pfiguremdl) ) != RESIZE_SUCCESS)
diff --git a/scilab/modules/graphics/src/c/SetProperty.c b/scilab/modules/graphics/src/c/SetProperty.c
index 1224b40..cc66c00 100644
--- a/scilab/modules/graphics/src/c/SetProperty.c
+++ b/scilab/modules/graphics/src/c/SetProperty.c
@@ -2180,51 +2180,44 @@ sciSetResize (sciPointObj * pobj, BOOL value)
2180 2180
2181 2181
2182 2182
2183/**sciSetName 2183int sciInitName(sciPointObj * pobj, char * newName)
2184 * Sets the name of the Figure
2185 * @param sciPointObj * pobj: the pointer to the entity
2186 * @param char pvalue: a pointer to the string contening name
2187 * @param int length: the length of the string (without the ending (char)0 ).
2188 * @return
2189 */
2190int
2191sciSetName (sciPointObj * pobj, char *pvalue, int length)
2192{ 2184{
2193 switch (sciGetEntityType (pobj)) 2185 switch (sciGetEntityType (pobj))
2194 { 2186 {
2195 case SCI_FIGURE: 2187 case SCI_FIGURE:
2196 { 2188 {
2197 /* the length of the C string */ 2189 int newNameLength;
2198 int realLength = length + 1 ;
2199 int percentStatus = 0 ; 2190 int percentStatus = 0 ;
2200 if( realLength > SCI_FIGURE_NAME_LENGTH )
2201 {
2202 sciprint(_("Figure name is limited to %d characters.\n"), SCI_FIGURE_NAME_LENGTH - 1 );
2203 return -1 ;
2204 }
2205 2191
2206 percentStatus = checkPercent( pvalue ) ; 2192 /* first case newName is NULL */
2207 if ( percentStatus < 0 ) 2193 if (newName == NULL)
2194 {
2195 /* Just set tan empty title for the phisical window if needed */
2196 if (!isFigureModel(pobj))
2197 {
2198 sciSetJavaTitle(pobj, "");
2199 }
2200
2201 return 0;
2202 }
2203
2204 /* newName is a valid string */
2205 newNameLength = strlen(newName);
2206
2207 /* Reallocate name */
2208 pFIGURE_FEATURE(pobj)->name = MALLOC( (newNameLength + 1) * sizeof(char) );
2209
2210 /* copy the string */
2211 strcpy(pFIGURE_FEATURE(pobj)->name, newName) ;
2212
2213 /* Update the name of the physical window if one exists */
2214 if (!isFigureModel(pobj))
2208 { 2215 {
2209 sciprint(_("Figure name may not contains any %% character, except a single %%d.\n")) ; 2216 /* In this case, we need to send the name to the physical window */
2210 return -1 ; 2217 if ( checkPercent(newName) == 0 )
2211 }
2212
2213 strcpy (pFIGURE_FEATURE (pobj)->name, pvalue ) ;
2214 pFIGURE_FEATURE (pobj)->namelen = length ;
2215
2216 if (pobj != getFigureModel())
2217 {
2218 char * str = NULL ;
2219 if ( percentStatus == 0 )
2220 { 2218 {
2221 str = CALLOC( realLength, sizeof(char) ) ; 2219 /* no %d, set the java title directly */
2222 if ( str == NULL ) 2220 sciSetJavaTitle(pobj, pFIGURE_FEATURE(pobj)->name);
2223 {
2224 sciprint(_("%s: No more memory.\n"),"sciSetName");
2225 return -1 ;
2226 }
2227 strcpy( str, pvalue ) ;
2228 } 2221 }
2229 else 2222 else
2230 { 2223 {
@@ -2232,33 +2225,62 @@ sciSetName (sciPointObj * pobj, char *pvalue, int length)
2232 /* get the number digits of the window number */ 2225 /* get the number digits of the window number */
2233 int figureNumber = sciGetNum( pobj ) ; 2226 int figureNumber = sciGetNum( pobj ) ;
2234 int nbDigits = GET_NB_DIGITS( figureNumber ) ; 2227 int nbDigits = GET_NB_DIGITS( figureNumber ) ;
2235 realLength = realLength + nbDigits - 2 ; /* -2 for the %d */ 2228 int realTitleLength = newNameLength + nbDigits - 2 ; /* -2 for the %d which is replaced */
2236 str = CALLOC( realLength, sizeof(char) ) ; 2229 char * realTitle = MALLOC( (realTitleLength + 1) * sizeof(char) ) ;
2237 if ( str == NULL ) 2230 if ( realTitle == NULL )
2238 { 2231 {
2239 sciprint(_("%s: No more memory.\n"),"sciSetName"); 2232 sciprint(_("%s: No more memory.\n"),"sciSetName");
2240 return -1 ; 2233 return -1 ;
2241 } 2234 }
2242 sprintf( str, pvalue, figureNumber ) ; 2235 sprintf( realTitle, newName, figureNumber ) ;
2243 length = realLength - 1 ; 2236 sciSetJavaTitle(pobj, realTitle);
2237 FREE(realTitle) ;
2244 } 2238 }
2245 2239
2246 /* set the java title */ 2240
2247 sciSetJavaTitle(pobj, str);
2248
2249 FREE(str) ;
2250 } 2241 }
2251 2242
2252 break; 2243 return 0 ;
2253 } 2244 }
2254 case SCI_SUBWIN:
2255 case SCI_AGREG:
2256 default: 2245 default:
2257 printSetGetErrorMessage("name"); 2246 printSetGetErrorMessage("figure_name");
2258 return -1 ; 2247 return -1 ;
2259 break; 2248 break;
2260 } 2249 }
2261 return 0 ; 2250}
2251
2252/**sciSetName
2253 * Sets the name of the Figure
2254 * @param sciPointObj * pobj: the pointer to the entity
2255 * @param char newName: a pointer to the string contening name
2256 * @return
2257 */
2258int
2259sciSetName(sciPointObj * pobj, char * newName)
2260{
2261 if ( newName != NULL
2262 && sciGetName(pobj) != NULL
2263 && strcmp(sciGetName(pobj), newName) == 0)
2264 {
2265 // nothing to do
2266 return 1;
2267 }
2268
2269 /* Check that the string contains at most one %d character */
2270 if (checkPercent(newName) < 0)
2271 {
2272 sciprint(_("Figure name may not contains any %% character, except a single %%d.\n")) ;
2273 return -1 ;
2274 }
2275
2276 /* Free the current name if needed */
2277 if (sciGetName(pobj) != NULL)
2278 {
2279 FREE(pFIGURE_FEATURE(pobj)->name);
2280 pFIGURE_FEATURE(pobj)->name = NULL;
2281 }
2282
2283 return sciInitName(pobj, newName);
2262} 2284}
2263 2285
2264int sciInitNum( sciPointObj * pobj, int value ) 2286int sciInitNum( sciPointObj * pobj, int value )
diff --git a/scilab/modules/graphics/src/c/getHandleProperty/set_figure_name_property.c b/scilab/modules/graphics/src/c/getHandleProperty/set_figure_name_property.c
index cf553e7..c313f97 100644
--- a/scilab/modules/graphics/src/c/getHandleProperty/set_figure_name_property.c
+++ b/scilab/modules/graphics/src/c/getHandleProperty/set_figure_name_property.c
@@ -37,7 +37,7 @@ int set_figure_name_property( sciPointObj * pobj, size_t stackPointer, int value
37 } 37 }
38 /* disable protection since this function will call Java */ 38 /* disable protection since this function will call Java */
39 disableFigureSynchronization(pobj); 39 disableFigureSynchronization(pobj);
40 status = sciSetName( pobj, getStringFromStack( stackPointer ), nbCol * nbRow ) ; 40 status = sciSetName( pobj, getStringFromStack( stackPointer )) ;
41 enableFigureSynchronization(pobj); 41 enableFigureSynchronization(pobj);
42 42
43 return status; 43 return status;
diff --git a/scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJavaMapper.cpp b/scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJavaMapper.cpp
index d00d1ae..11c78ed 100644
--- a/scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJavaMapper.cpp
+++ b/scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJavaMapper.cpp
@@ -153,9 +153,9 @@ void DrawableFigureJavaMapper::setWindowSize(int width, int height)
153 m_pJavaObject->setWindowSize(width, height); 153 m_pJavaObject->setWindowSize(width, height);
154} 154}
155/*---------------------------------------------------------------------------------*/ 155/*---------------------------------------------------------------------------------*/
156void DrawableFigureJavaMapper::setInfoMessage(char * infoMessage) 156void DrawableFigureJavaMapper::setInfoMessage(const char * infoMessage)
157{ 157{
158 m_pJavaObject->setInfoMessage(infoMessage); 158 m_pJavaObject->setInfoMessage((char *) infoMessage);
159} 159}
160/*---------------------------------------------------------------------------------*/ 160/*---------------------------------------------------------------------------------*/
161void DrawableFigureJavaMapper::setAutoResizeMode(bool onOrOff) 161void DrawableFigureJavaMapper::setAutoResizeMode(bool onOrOff)
@@ -210,9 +210,9 @@ void DrawableFigureJavaMapper::rubberBox(bool isClick, bool isZoom, const int in
210 210
211} 211}
212/*---------------------------------------------------------------------------------*/ 212/*---------------------------------------------------------------------------------*/
213void DrawableFigureJavaMapper::setTitle(char * title) 213void DrawableFigureJavaMapper::setTitle(const char * title)
214{ 214{
215 m_pJavaObject->setTitle(title); 215 m_pJavaObject->setTitle((char *) title);
216} 216}
217/*---------------------------------------------------------------------------------*/ 217/*---------------------------------------------------------------------------------*/
218bool DrawableFigureJavaMapper::getRotationDisplacement(int displacement[2]) 218bool DrawableFigureJavaMapper::getRotationDisplacement(int displacement[2])
diff --git a/scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJavaMapper.hxx b/scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJavaMapper.hxx
index 602e64b..d1c5a3a 100644
--- a/scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJavaMapper.hxx
+++ b/scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJavaMapper.hxx
@@ -69,7 +69,7 @@ public:
69 virtual int getWindowHeight(void); 69 virtual int getWindowHeight(void);
70 virtual void setWindowSize(int width, int height); 70 virtual void setWindowSize(int width, int height);
71 71
72 virtual void setInfoMessage(char * infoMessage); 72 virtual void setInfoMessage(const char * infoMessage);
73 73
74 virtual void setAutoResizeMode(bool onOrOff); 74 virtual void setAutoResizeMode(bool onOrOff);
75 virtual bool getAutoResizeMode(void); 75 virtual bool getAutoResizeMode(void);
@@ -81,7 +81,7 @@ public:
81 81
82 virtual void rubberBox(bool isClick, bool isZoom, const int initialRect[4], int endRect[4], int * usedButton); 82 virtual void rubberBox(bool isClick, bool isZoom, const int initialRect[4], int endRect[4], int * usedButton);
83 83
84 virtual void setTitle(char * title); 84 virtual void setTitle(const char * title);
85 85
86 virtual bool getRotationDisplacement(int displacement[2]); 86 virtual bool getRotationDisplacement(int displacement[2]);
87 virtual void stopRotationRecording(void); 87 virtual void stopRotationRecording(void);
diff --git a/scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJoGL.cpp b/scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJoGL.cpp
index 67f8102..ab3bac7 100644
--- a/scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJoGL.cpp
+++ b/scilab/modules/renderer/src/cpp/figureDrawing/DrawableFigureJoGL.cpp
@@ -127,11 +127,7 @@ void DrawableFigureJoGL::setWindowSize( const int size[2] )
127/*---------------------------------------------------------------------------------*/ 127/*---------------------------------------------------------------------------------*/
128void DrawableFigureJoGL::setInfoMessage( const char * message ) 128void DrawableFigureJoGL::setInfoMessage( const char * message )
129{ 129{
130 // we need to create a not const char 130 getFigureJavaMapper()->setInfoMessage(message);
131 char * infoMessage = new char[strlen(message)+1];
132 strcpy(infoMessage, message);
133 getFigureJavaMapper()->setInfoMessage(infoMessage);
134 delete[] infoMessage;
135} 131}
136/*---------------------------------------------------------------------------------*/ 132/*---------------------------------------------------------------------------------*/
137void DrawableFigureJoGL::setAutoResizeMode(bool onOrOff) 133void DrawableFigureJoGL::setAutoResizeMode(bool onOrOff)
@@ -181,11 +177,7 @@ void DrawableFigureJoGL::destroy( void )
181/*---------------------------------------------------------------------------------*/ 177/*---------------------------------------------------------------------------------*/
182void DrawableFigureJoGL::setTitle( const char * title ) 178void DrawableFigureJoGL::setTitle( const char * title )
183{ 179{
184 // we need to create a not const char 180 getFigureJavaMapper()->setTitle(title);
185 char * constTitle = new char[strlen(title)+1];
186 strcpy(constTitle, title);
187 getFigureJavaMapper()->setTitle(constTitle);
188 delete[] constTitle;
189} 181}
190/*---------------------------------------------------------------------------------*/ 182/*---------------------------------------------------------------------------------*/
191bool DrawableFigureJoGL::getRotationDisplacement(int displacement[2]) 183bool DrawableFigureJoGL::getRotationDisplacement(int displacement[2])