Logic: clear "Script" when setting Script Controller mode to "Module"

The text datablock was linked to the controller. So even if the script was set to 'module' and saved, once linked/appended the object the script would come together.
If someone wants to implement this "clear" only once the file is saved, please go ahead. But I believe it's ok to  loose the script if you change it for module (and with the new datablock lookup it's straightforward/quick to reassign a textblock)

-- bug not reported anywhere, from my own list
This commit is contained in:
Dalai Felinto
2011-06-12 08:34:53 +00:00
parent 9095612b85
commit 6c15d28db2

View File

@@ -87,6 +87,20 @@ static void rna_Controller_type_set(struct PointerRNA *ptr, int value)
}
}
static void rna_Controller_mode_set(struct PointerRNA *ptr, int value)
{
bController *cont= (bController *)ptr->data;
bPythonCont *pycon= (bPythonCont *)cont->data;
// if mode changed and previous mode were Script
if (value != pycon->mode && pycon->mode == CONT_PY_SCRIPT)
{
// clear script to avoid it to get linked with the controller
pycon->text = NULL;
}
pycon->mode = value;
}
static int rna_Controller_state_number_get(struct PointerRNA *ptr)
{
bController *cont= (bController *)ptr->data;
@@ -222,6 +236,7 @@ void RNA_def_controller(BlenderRNA *brna)
prop= RNA_def_property(srna, "mode", PROP_ENUM, PROP_NONE);
RNA_def_property_enum_items(prop, python_controller_modes);
RNA_def_property_enum_funcs(prop, NULL, "rna_Controller_mode_set", NULL);
RNA_def_property_ui_text(prop, "Execution Method", "Python script type (textblock or module - faster)");
RNA_def_property_update(prop, NC_LOGIC, NULL);