Hi Tom, There was an error in the function calling code, fix in svn, hopefully it works now.
Brecht. On Sun, Jul 24, 2011 at 12:02 AM, Tom Edwards <cont...@steamreview.org> wrote: > Brecht, I see uninitialised memory whenever I should see the default. It > has never worked, and there are no code examples in the whole of Blender > to go on. > > Declaring the array static doesn't help, but I must admit I hadn't > thought of it! > > This is what ends up in rna_texture_gen.c: > >> static float rna_EnvironmentMap_save_layout_default[12] = { >> 0.0f, >> 0.0f, >> 0.0f, >> 1.0f, >> 0.0f, >> 2.0f, >> 1.0f, >> 0.0f, >> 1.0f, >> 1.0f, >> 1.0f, >> 2.0f >> }; >> >> FloatPropertyRNA rna_EnvironmentMap_save_layout = { >> {NULL, (PropertyRNA*)&rna_EnvironmentMap_save_scene, >> -1, "layout", 3, "File layout", >> "Snip", >> 0, >> PROP_FLOAT, PROP_NONE|PROP_UNIT_NONE, NULL, 1, {12, 0, 0}, 12, >> NULL, 0, NULL, NULL, >> 0, -1, NULL}, >> NULL, NULL, NULL, NULL, NULL, 0.0f, 0.0f, -FLT_MAX, FLT_MAX, 1.0f, >> 3, 0.0f, rna_EnvironmentMap_save_layout_default >> }; > > Which does suggest that I'm doing things right... > > Here is the entire API: <http://pastebin.com/VZdrDeMs>. There wasn't a > texture API at all before I started, if that makes any difference. > > On 23/07/2011 8:32, Brecht Van Lommel wrote: >> Hi Tom, >> >> It's not clear to me when you saw uninitialized memory, am I right >> thinking that the malloc made it work, but didn't look like a good >> solution? In other places the array is defined "static" to keep it in >> memory, without a malloc. >> >> Brecht. >> >> On Fri, Jul 22, 2011 at 3:45 PM, Tom Edwards<cont...@steamreview.org> wrote: >>> I can't work out how to provide a default value for an RNA array >>> parameter. Ominously, the unit tests don't cover this at all. >>> >>> The code is: >>> >>> const int default_layout_size = sizeof(float) * 12; >>> const float default_layout_stack[] = { 0,0, 0,1, 0,2, 1,0, 1,1, 1,2 }; >>> >>> float* default_layout_heap = (float*)malloc(default_layout_size); >>> memcpy(default_layout_heap,default_layout_stack,default_layout_size); >>> >>> ... >>> >>> parm = RNA_def_float_array(func, "layout", 12, default_layout_heap, >>> 0.0f, 0.0f, "File layout", "Snip", 0.0f, 0.0f); >>> >>> There is no problem if a value is provided, but the default appears to >>> be uninitialised memory. >>> _______________________________________________ >>> Bf-committers mailing list >>> Bf-committers@blender.org >>> http://lists.blender.org/mailman/listinfo/bf-committers >>> >> _______________________________________________ >> Bf-committers mailing list >> Bf-committers@blender.org >> http://lists.blender.org/mailman/listinfo/bf-committers >> > _______________________________________________ > Bf-committers mailing list > Bf-committers@blender.org > http://lists.blender.org/mailman/listinfo/bf-committers > _______________________________________________ Bf-committers mailing list Bf-committers@blender.org http://lists.blender.org/mailman/listinfo/bf-committers