multi-column comboboxes -> HISE crashes constantly
-
Hello to all,
this code causes HISE to crash constantly. Does anyone have an idea what the problem could be?
When loading the project for the first time, everything works fine and the ComboBoxes are filled with the sample names. However, after I have pressed “compile” a few times, HISE crashes every time.
Does anyone see the error or are the multi-column comboboxes perhaps still a little buggy?
Thank you very much
OliCODE:
const var sampleMaps = Sampler.getSampleMapList(); const var sampleCombos = [Content.getComponent("cmbSamples1"), Content.getComponent("cmbSamples2"), Content.getComponent("cmbSamples3"), Content.getComponent("cmbSamples4")]; for(c in sampleCombos) { c.set("items", ""); for(w in sampleMaps) { if(w.contains("Bass_")) c.addItem("Bass::" + w.replace("Bass_")); if(w.contains("Bell_")) c.addItem("Bell::" + w.replace("Bell_")); if(w.contains("Brass_")) c.addItem("Brass::" + w.replace("Brass_")); if(w.contains("Drum_")) c.addItem("Drum::" + w.replace("Drum_")); if(w.contains("FX_")) c.addItem("FX::" + w.replace("FX_")); if(w.contains("Git_")) c.addItem("Git::" + w.replace("Git_")); if(w.contains("Keys_")) c.addItem("Keys::" + w.replace("Keys_")); if(w.contains("Lead_")) c.addItem("Lead::" + w.replace("Lead_")); if(w.contains("Pad_")) c.addItem("Pad::" + w.replace("Pad_")); if(w.contains("Plug_")) c.addItem("Plug::" + w.replace("Plug_")); if(w.contains("Seq_")) c.addItem("Seq::" + w.replace("Seq_")); if(w.contains("String_")) c.addItem("String::" + w.replace("String_")); if(w.contains("Voice_")) c.addItem("Voice::" + w.replace("Voice_")); } }
-
@Oli-Ullmann how do you know this is whats crashing HISE?
and
String.replace(var substringToLookFor, var replacement)
-
@Lindon Yes, I have commented out the code and pressed “compile” several times. It no longer crashes. But the tip with the correct notation is good. I'll try it out right away and let you know if it has fixed the problem. Thanks to you. :-)
-
@Oli-Ullmann You can probably simplify this a lot with something like the following:
const var sampleMaps = Sampler.getSampleMapList(); const cmbSamples = Content.getAllComponents("cmbSamples"); populateComboBoxes(); inline function populateComboBoxes() { for(c in cmbSamples) { c.set("items", ""); for (s in sampleMaps) { local firstSegment = s.substring(0, s.indexOf("_") + 1); c.addItem(firstSegment.replace("_", "::") + firstSegment); } } }
It's probably not this code that is causing your crash, but something else, possibly related to the combo box. Try to recreate the issue in an isolated project.
-
@Lindon said in multi-column comboboxes -> HISE crashes constantly:
@Oli-Ullmann how do you know this is whats crashing HISE?
and
String.replace(var substringToLookFor, var replacement)
Unfortunately, it still crashes.
-
and why not do the replace once(on the sampleMapList) and then update all 4 with "items"
const var sampleMaps = Sampler.getSampleMapList(); for (map in sampleMaps) { if(map.contains("Bass_")) map.replace("Bass_", "Bass::"); if(map.contains("Bell_")) map.replace("Bell_","Bell::"); if(map.contains("Brass_")) map.replace("Brass_","Brass::"); if(map.contains("Drum_")) map.replace("Drum_","Drum::" ); if(map.contains("FX_")) map.replace("FX_","FX::"); if(map.contains("Git_")) map.replace("Git_","Git::"); if(map.contains("Keys_")) map.replace("Keys_","Keys::"); if(map.contains("Lead_")) map.replace("Lead_","Lead::"); if(map.contains("Pad_")) map.replace("Pad_","Pad::"); if(map.contains("Plug_")) map.replace("Plug_","Plug::" ); if(map.contains("Seq_")) map..replace("Seq_","Seq::"); if(map.contains("String_")) map.replace("String_","String::" ); if(map.contains("Voice_")) map.replace("Voice_","Voice::"); } } Console.print(trace(sampleMaps)); const var sampleCombos = [Content.getComponent("cmbSamples1"), Content.getComponent("cmbSamples2"), Content.getComponent("cmbSamples3"), Content.getComponent("cmbSamples4")]; for(c in sampleCombos) { c.set("items", sampleMaps); }
-
-
@Oli-Ullmann look at what you are getting back in the array sampleMaps after you've done the substitution, you are actually probably better off doing
if(map.indexOf("Bass_") == 0)
rather than
if(map.contains("Bass_"))
to make sure you are replacing one only occurrence
Dave's approach is even better...
-
@Lindon Thank you!
-
@Oli-Ullmann this is interesting:
const var sampleMaps = ["Bass_ONE","Bass_Two","Bass_three"]; const cmbSamples = Content.getAllComponents("ComboBox"); for (map in sampleMaps) { reg firstSegment = map.substring(0, map.indexOf("_") + 1); reg secondSegment = map.substring(map.indexOf("_") + 1, map.length); Console.print(firstSegment.indexOf("_")); firstSegment.replace("_", "::"); Console.print(firstSegment); Console.print(secondSegment); }
replace isnt working....for me at least..
-
@Lindon Ok here you go.. the best of Dave and me ...
const var sampleMaps = ["Bass_ONE","Bass_Two","Bass_three","Gtr_One"]; const cmbSamples = Content.getAllComponents("ComboBox"); for (map in sampleMaps) { reg firstSegment = map.substring(0, map.indexOf("_") + 1); reg secondSegment = map.substring(map.indexOf("_") + 1, map.length); firstSegment = firstSegment.replace("_", "::"); map = firstSegment + secondSegment; } Console.print(trace(sampleMaps)); populateComboBoxes(); inline function populateComboBoxes() { for(c in cmbSamples) { c.set("items", sampleMaps.join("\n")); } }
-
@Lindon Thank you very much! I'll try that out right away! :-)
-
@Lindon Wrap it in a function to avoid wasting reg variables.
-
@d-healey yes yes ....I know...Im lazy.
-
@Lindon so here is it all wrapped in one function call
const var sampleMaps = ["Bass_ONE","Bass_Two","Bass_three","Gtr_One"]; const cmbSamples = Content.getAllComponents("ComboBox"); populateComboBoxes(); inline function populateComboBoxes() { for (map in sampleMaps) { local firstSegment = map.substring(0, map.indexOf("_") + 1); local secondSegment = map.substring(map.indexOf("_") + 1, map.length); firstSegment = firstSegment.replace("_", "::"); map = firstSegment + secondSegment; } for(c in cmbSamples) { c.set("items", sampleMaps.join("\n")); } }
-