Will give me a drop down menu containing the array values.
However trying to insert values into a globally defined non-static array inside the plugin constructer method crashes Xojo on load but is working in debugger. For example: (same properties method)
//inserting "0, 1, 2, 3, 4" into an array
const char* charArray[5];
static void VectorConstructor(REALcontrolInstance control)
{
for (int i = 0; i < 5; i++) {
string newNumString = "";
const char* newNumChar = "";
newNumString = to_string(i);
newNumChar = newNumString.c_str();
charArray[i] = newNumChar;
}
Can Xojo/Xojo plugins not accept arrays that are non-static? Is there something i’m missing?
First it looks like you make a definition of the property with a list of enum labels. Looks fine.
But the code there is strange.
Since you use std::string there, the ptr you get from c_str() function is temporary. putting it in charArray[] won’t be good, since on access later it will point to released string.
I’m trying to create a drop-down menu property of a class containing file names from a specified folder.
The properties definition requires a const char* and the file names are returned as a stringstream hence the example of code before containing the data type conversions.
As you pointed out my current method won’t work, is there a better way of doing this conversion to work with what i’m trying to accomplish?
Code compiles fine into dll file through visual studio, but no crash log as it’s failing when Xojo is loading in plugins. As far as i know Xojo doesn’t create crash logs during load time.
I suspect that Björn may be correct and i have been testing solutions with malloc memory allocation, but am yet to have a working project.
You say the plugin defines a drop-down menu in the inspector properties pane of the IDE. That is only possible with a static array. Usually this is being done for a REALcontrol. Any other way other than a static array will crash Xojo. Our plugins use these static arrays in many cases to ease the setup of a plugin for runtime purposes.