[Csnd] FLsetText from udo
Date | 2018-12-07 23:24 |
From | Richard Knight |
Subject | [Csnd] FLsetText from udo |
Hello This printed the correct score line, but FLsetText did strange things. Sometimes unusual characters were set in the FLbox, once the full score line was set, and sometimes "%d" was set. Any ideas/suggestions/workarounds appreciated. |
Date | 2018-12-09 20:31 |
From | jpff |
Subject | Re: [Csnd] FLsetText from udo |
I finally got round to looking at this. Yes it is very odd. As you hinted it is a udo problem as inserting the code inline in instr 1 corrects the output. I think we need Syephen's thougts on this as it looks as if the udo is caching data from a previous call. I will continue to look but really this is not my area. ==John On Fri, 7 Dec 2018, Richard Knight wrote: > > Hello > I'm trying to set the text of FLboxes from a udo (the example given below is > a cut down version, there is a specific reason I want to try and do this from > a udo). > Passing the widget handle to the opcode, the FLsetText works on the first > FLbox but then on the subsequent FLboxes, every one that has had FLsetText > called on it previously has the text set. > > Looks like a similar thing was mentioned on the list by Dominik K on > 2017-09-03 but couldn't find any solution. I have tried a few workarounds and > experienced some unusual behaviour. For example I put the FlsetText in an > instr, and then called this from the udo using > Score sprintf "i98 0 1 \"%s\" %d", StringToSet, ilabelhandle > prints Score > scoreline Score > > This printed the correct score line, but FLsetText did strange things. > Sometimes unusual characters were set in the FLbox, once the full score line > was set, and sometimes "%d" was set. > > Any ideas/suggestions/workarounds appreciated. > Richard > > > |
Date | 2018-12-10 02:20 |
From | Richard Knight |
Subject | Re: [Csnd] FLsetText from udo |
Thanks. I don't urge anyone to spend too long looking at it, doesn't seem like the most clear of things to track down. I have a workaround for what I'm doing now but with a little less code reusability. Richard On Sun, 9 Dec 2018 20:31:37 +0000, jpff wrote: I finally got round to looking at this. Yes it is very odd. As you hinted it is a udo problem as inserting the code inline in instr 1 corrects the output. I think we need Syephen's thougts on this as it looks as if the udo is caching data from a previous call. I will continue to look but really this is not my area. ==John On Fri, 7 Dec 2018, Richard Knight wrote:Hello I'm trying to set the text of FLboxes from a udo (the example given below is a cut down version, there is a specific reason I want to try and do this from a udo). Passing the widget handle to the opcode, the FLsetText works on the first FLbox but then on the subsequent FLboxes, every one that has had FLsetText called on it previously has the text set. Looks like a similar thing was mentioned on the list by Dominik K on 2017-09-03 but couldn't find any solution. I have tried a few workarounds and experienced some unusual behaviour. For example I put the FlsetText in an instr, and then called this from the udo using Score sprintf "i98 0 1 \"%s\" %d", StringToSet, ilabelhandle prints Score scoreline Score This printed the correct score line, but FLsetText did strange things. Sometimes unusual characters were set in the FLbox, once the full score line was set, and sometimes "%d" was set. Any ideas/suggestions/workarounds appreciated. Richard -odac sr = 44100 kr = 44100 nchnls = 2 0dbfs = 1 seed 1 FLpanel "Example", 200, 200 gib1 FLbox "test", 1, 10, 20, 200, 50, 0, 0 gib2 FLbox "test", 1, 10, 20, 200, 50, 0, 50 gib3 FLbox "test", 1, 10, 20, 200, 50, 0, 100 gib4 FLbox "empty", 1, 10, 20, 200, 50, 0, 150 FLpanelEnd FLrun opcode update, 0, iS ihandle, Sval xin print ihandle FLsetText Sval, ihandle endop instr 1 Sval strget p4 update gib1, Sval endin instr 2 Sval strget p4 update gib2, Sval endin instr 3 Sval strget p4 update gib3, Sval endin f0 10 i1 0 1 "box 1: 1" ; gib1 shows "box 1: 1" ; ihandle printed = 0 i1 1 1 "box 1: 2" ; gib1 shows "box 2: 2" ; ihandle printed = 0 i2 2 1 "box 2: 1" ; gib1, gib2 show "box 2: 1" ; ihandle printed = 1 i2 3 1 "box 2: 2" ; gib1, gib2 show "box 2: 2" ; ihandle printed = 1 i3 4 1 "box 3: 1" ; gib1, gib2, gib3 show "box 3: 1" ; ihandle printed = 2 i3 5 1 "box 3: 2" ; gib1, gib2, gib3 show "box 3: 2" ; ihandle printed = 2 Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted hereCsound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here -- http://rk.1bpm.net/ |
Date | 2018-12-10 03:36 |
From | Richard Knight |
Subject | Re: [Csnd] FLsetText from udo |
In InOut/widgets.cpp, if I change line 3331 in fl_setText from
On Mon, 10 Dec 2018 02:20:23 +0000, Richard Knight wrote:
-- http://rk.1bpm.net/ |
Date | 2018-12-10 10:48 |
From | John ff |
Subject | Re: [Csnd] FLsetText from udo |
The use of a copy of the string makes sense but why does it work out of the udo? Will look at it later Sent from TypeApp On Dec 10, 2018, 03:37, at 03:37, Richard Knight |
Date | 2018-12-10 11:43 |
From | jpff |
Subject | Re: [Csnd] FLsetText from udo |
Thanks; I understand it now and have committed a fix. I might have a small memory leak, but if so I know how to adjust the code for that. Until then the version in github should work. ==John ff On Mon, 10 Dec 2018, Richard Knight wrote: > > In InOut/widgets.cpp, if I change line 3331 in fl_setText from > char *text = p->itext->data; > to > char *text = (char *)csound->Malloc(csound, strlen(p->itext->data) + 1); > strcpy(text, p->itext->data); > > it seems to fix the set text issue. I'm quite new to languages where I have to > think about memory management, and in fact csound internals, so not sure if > this is the ideal way to do it, but I'll certainly have a look around further. > > > > On Mon, 10 Dec 2018 02:20:23 +0000, Richard Knight wrote: > > Thanks. I don't urge anyone to spend too long looking at it, > doesn't seem like the most clear of things to track down. I have a > workaround for what I'm doing now but with a little less code > reusability. > Did a quick test to see if the behaviour was similar with any of > the other FLset... opcodes: > > FLhide/FLshow - works ok doing this in a udo. > FLsetColor, FLsetTextColor, FLsetFont - not sure if these are > designed to actually be used in performance, as they work from a > udo/instr but only at initialisation/when score time = 0. Couldn't > find anything in the docs saying they can't be used, but may have > overlooked something. > > Richard > > On Sun, 9 Dec 2018 20:31:37 +0000, jpff wrote: > > I finally got round to looking at this. Yes it is very odd. As you > hinted it is a udo problem as inserting the code inline in instr 1 > corrects the output. I think we need Syephen's thougts on this as it > looks as if the udo is caching data from a previous call. I will continue > to look but really this is not my area. > > ==John > > > On Fri, 7 Dec 2018, Richard Knight wrote: > > > Hello > I'm trying to set the text of FLboxes from a udo (the example given below is > a cut down version, there is a specific reason I want to try and do this from > a udo). > Passing the widget handle to the opcode, the FLsetText works on the first > FLbox but then on the subsequent FLboxes, every one that has had FLsetText > called on it previously has the text set. > > Looks like a similar thing was mentioned on the list by Dominik K on > 2017-09-03 but couldn't find any solution. I have tried a few workarounds and > experienced some unusual behaviour. For example I put the FlsetText in an > instr, and then called this from the udo using > Score sprintf "i98 0 1 \"%s\" %d", StringToSet, ilabelhandle > prints Score > scoreline Score > > This printed the correct score line, but FLsetText did strange things. > Sometimes unusual characters were set in the FLbox, once the full score line > was set, and sometimes "%d" was set. > > Any ideas/suggestions/workarounds appreciated. > Richard > > > > > -odac > > > sr = 44100 > kr = 44100 > nchnls = 2 > 0dbfs = 1 > seed 1 > > > FLpanel "Example", 200, 200 > > gib1 FLbox "test", 1, 10, 20, 200, 50, 0, 0 > gib2 FLbox "test", 1, 10, 20, 200, 50, 0, 50 > gib3 FLbox "test", 1, 10, 20, 200, 50, 0, 100 > gib4 FLbox "empty", 1, 10, 20, 200, 50, 0, 150 > > FLpanelEnd > FLrun > > > opcode update, 0, iS > ihandle, Sval xin > print ihandle > FLsetText Sval, ihandle > endop > > > > instr 1 > Sval strget p4 > update gib1, Sval > endin > > > instr 2 > Sval strget p4 > update gib2, Sval > endin > > > instr 3 > Sval strget p4 > update gib3, Sval > endin > > > > > f0 10 > > i1 0 1 "box 1: 1" ; gib1 shows "box 1: 1" ; ihandle printed = 0 > i1 1 1 "box 1: 2" ; gib1 shows "box 2: 2" ; ihandle printed = 0 > > i2 2 1 "box 2: 1" ; gib1, gib2 show "box 2: 1" ; ihandle printed = 1 > i2 3 1 "box 2: 2" ; gib1, gib2 show "box 2: 2" ; ihandle printed = 1 > > i3 4 1 "box 3: 1" ; gib1, gib2, gib3 show "box 3: 1" ; ihandle printed = 2 > i3 5 1 "box 3: 2" ; gib1, gib2, gib3 show "box 3: 2" ; ihandle printed = 2 > > > > > Csound mailing list Csound@listserv.heanet.ie > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to > https://github.com/csound/csound/issues Discussions of bugs and features can > be posted here > > > Csound mailing list > Csound@listserv.heanet.ie > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND > Send bugs reports to > https://github.com/csound/csound/issues > Discussions of bugs and features can be posted here > > -- > > > http://rk.1bpm.net/ > > Csound mailing list Csound@listserv.heanet.ie > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to > https://github.com/csound/csound/issues Discussions of bugs and features > can be posted here > > -- > > > http://rk.1bpm.net/ > Csound mailing list Csound@listserv.heanet.ie > https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to > https://github.com/csound/csound/issues Discussions of bugs and features can > be posted here > Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here |
Date | 2018-12-10 12:38 |
From | Richard Knight |
Subject | Re: [Csnd] FLsetText from udo |
That's great, thank you. I will endeavor to have a read through and try to understand your fix. On Mon, 10 Dec 2018 11:43:28 +0000, jpff wrote: Thanks; I understand it now and have committed a fix. I might have a small memory leak, but if so I know how to adjust the code for that. Until then the version in github should work. ==John ff On Mon, 10 Dec 2018, Richard Knight wrote:In InOut/widgets.cpp, if I change line 3331 in fl_setText from char *text = p->itext->data; to char *text = (char *)csound->Malloc(csound, strlen(p->itext->data) + 1); strcpy(text, p->itext->data); it seems to fix the set text issue. I'm quite new to languages where I have to think about memory management, and in fact csound internals, so not sure if this is the ideal way to do it, but I'll certainly have a look around further. On Mon, 10 Dec 2018 02:20:23 +0000, Richard Knight wrote: Thanks. I don't urge anyone to spend too long looking at it, doesn't seem like the most clear of things to track down. I have a workaround for what I'm doing now but with a little less code reusability. Did a quick test to see if the behaviour was similar with any of the other FLset... opcodes: FLhide/FLshow - works ok doing this in a udo. FLsetColor, FLsetTextColor, FLsetFont - not sure if these are designed to actually be used in performance, as they work from a udo/instr but only at initialisation/when score time = 0. Couldn't find anything in the docs saying they can't be used, but may have overlooked something. Richard On Sun, 9 Dec 2018 20:31:37 +0000, jpff wrote: I finally got round to looking at this. Yes it is very odd. As you hinted it is a udo problem as inserting the code inline in instr 1 corrects the output. I think we need Syephen's thougts on this as it looks as if the udo is caching data from a previous call. I will continue to look but really this is not my area. ==John On Fri, 7 Dec 2018, Richard Knight wrote: Hello I'm trying to set the text of FLboxes from a udo (the example given below is a cut down version, there is a specific reason I want to try and do this from a udo). Passing the widget handle to the opcode, the FLsetText works on the first FLbox but then on the subsequent FLboxes, every one that has had FLsetText called on it previously has the text set. Looks like a similar thing was mentioned on the list by Dominik K on 2017-09-03 but couldn't find any solution. I have tried a few workarounds and experienced some unusual behaviour. For example I put the FlsetText in an instr, and then called this from the udo using Score sprintf "i98 0 1 \"%s\" %d", StringToSet, ilabelhandle prints Score scoreline Score This printed the correct score line, but FLsetText did strange things. Sometimes unusual characters were set in the FLbox, once the full score line was set, and sometimes "%d" was set. Any ideas/suggestions/workarounds appreciated. Richard -odac sr = 44100 kr = 44100 nchnls = 2 0dbfs = 1 seed 1 FLpanel "Example", 200, 200 gib1 FLbox "test", 1, 10, 20, 200, 50, 0, 0 gib2 FLbox "test", 1, 10, 20, 200, 50, 0, 50 gib3 FLbox "test", 1, 10, 20, 200, 50, 0, 100 gib4 FLbox "empty", 1, 10, 20, 200, 50, 0, 150 FLpanelEnd FLrun opcode update, 0, iS ihandle, Sval xin print ihandle FLsetText Sval, ihandle endop instr 1 Sval strget p4 update gib1, Sval endin instr 2 Sval strget p4 update gib2, Sval endin instr 3 Sval strget p4 update gib3, Sval endin f0 10 i1 0 1 "box 1: 1" ; gib1 shows "box 1: 1" ; ihandle printed = 0 i1 1 1 "box 1: 2" ; gib1 shows "box 2: 2" ; ihandle printed = 0 i2 2 1 "box 2: 1" ; gib1, gib2 show "box 2: 1" ; ihandle printed = 1 i2 3 1 "box 2: 2" ; gib1, gib2 show "box 2: 2" ; ihandle printed = 1 i3 4 1 "box 3: 1" ; gib1, gib2, gib3 show "box 3: 1" ; ihandle printed = 2 i3 5 1 "box 3: 2" ; gib1, gib2, gib3 show "box 3: 2" ; ihandle printed = 2 Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here -- http://rk.1bpm.net/ Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here -- http://rk.1bpm.net/ Csound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted hereCsound mailing list Csound@listserv.heanet.ie https://listserv.heanet.ie/cgi-bin/wa?A0=CSOUND Send bugs reports to https://github.com/csound/csound/issues Discussions of bugs and features can be posted here -- http://rk.1bpm.net/ |