removed ED_ prefix from script operator.
python operator api was crashing when unknown operators were called.
This commit is contained in:
		@@ -73,12 +73,12 @@ static int run_pyfile_exec(bContext *C, wmOperator *op)
 | 
			
		||||
	return OPERATOR_FINISHED;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void ED_SCRIPT_OT_run_pyfile(wmOperatorType *ot)
 | 
			
		||||
void SCRIPT_OT_run_pyfile(wmOperatorType *ot)
 | 
			
		||||
{
 | 
			
		||||
 | 
			
		||||
	/* identifiers */
 | 
			
		||||
	ot->name= "Run python file";
 | 
			
		||||
	ot->idname= "ED_SCRIPT_OT_run_pyfile";
 | 
			
		||||
	ot->idname= "SCRIPT_OT_run_pyfile";
 | 
			
		||||
 | 
			
		||||
	/* api callbacks */
 | 
			
		||||
	ot->exec= run_pyfile_exec;
 | 
			
		||||
 
 | 
			
		||||
@@ -39,7 +39,7 @@ void script_operatortypes(void);
 | 
			
		||||
void script_keymap(struct wmWindowManager *wm);
 | 
			
		||||
 | 
			
		||||
/* script_edit.c */
 | 
			
		||||
void ED_SCRIPT_OT_run_pyfile(struct wmOperatorType *ot);
 | 
			
		||||
void SCRIPT_OT_run_pyfile(struct wmOperatorType *ot);
 | 
			
		||||
 | 
			
		||||
#endif /* ED_SCRIPT_INTERN_H */
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -59,7 +59,7 @@
 | 
			
		||||
 | 
			
		||||
void script_operatortypes(void)
 | 
			
		||||
{
 | 
			
		||||
	WM_operatortype_append(ED_SCRIPT_OT_run_pyfile);
 | 
			
		||||
	WM_operatortype_append(SCRIPT_OT_run_pyfile);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
void script_keymap(wmWindowManager *wm)
 | 
			
		||||
@@ -67,6 +67,6 @@ void script_keymap(wmWindowManager *wm)
 | 
			
		||||
	ListBase *keymap= WM_keymap_listbase(wm, "Script", SPACE_SCRIPT, 0);
 | 
			
		||||
 | 
			
		||||
	/* TODO - this is just while we have no way to load a text datablock */
 | 
			
		||||
	RNA_string_set(WM_keymap_add_item(keymap, "ED_SCRIPT_OT_run_pyfile", PKEY, KM_PRESS, 0, 0)->ptr, "filename", "test.py");
 | 
			
		||||
	RNA_string_set(WM_keymap_add_item(keymap, "SCRIPT_OT_run_pyfile", PKEY, KM_PRESS, 0, 0)->ptr, "filename", "test.py");
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -114,7 +114,7 @@ void view3d_keymap(wmWindowManager *wm)
 | 
			
		||||
	WM_keymap_add_item(keymap, "VIEW3D_OT_circle_select", CKEY, KM_PRESS, 0, 0);
 | 
			
		||||
 | 
			
		||||
	/* TODO - this is just while we have no way to load a text datablock */
 | 
			
		||||
	RNA_string_set(WM_keymap_add_item(keymap, "ED_SCRIPT_OT_run_pyfile", PKEY, KM_PRESS, 0, 0)->ptr, "filename", "test.py");
 | 
			
		||||
	RNA_string_set(WM_keymap_add_item(keymap, "SCRIPT_OT_run_pyfile", PKEY, KM_PRESS, 0, 0)->ptr, "filename", "test.py");
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -77,10 +77,11 @@ static PyObject *pyop_base_getattro( BPy_OperatorBase * self, PyObject *pyname )
 | 
			
		||||
		ot = WM_operatortype_find(name);
 | 
			
		||||
 | 
			
		||||
		if (ot) {
 | 
			
		||||
			return pyop_func_CreatePyObject(self->C, name);
 | 
			
		||||
			ret= pyop_func_CreatePyObject(self->C, name);
 | 
			
		||||
		}
 | 
			
		||||
		else {
 | 
			
		||||
			PyErr_Format( PyExc_AttributeError, "Operator \"%s\" not found", name);
 | 
			
		||||
			ret= NULL;
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
@@ -101,18 +102,17 @@ static PyObject * pyop_func_call(BPy_OperatorFunc * self, PyObject *args, PyObje
 | 
			
		||||
	PropertyRNA *prop, *iterprop;
 | 
			
		||||
	CollectionPropertyIterator iter;
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
	if (ot == NULL) {
 | 
			
		||||
		PyErr_SetString( PyExc_SystemError, "Operator could not be found");
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	if (PyTuple_Size(args)) {
 | 
			
		||||
		PyErr_SetString( PyExc_AttributeError, "All operator args must be keywords");
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	ot= WM_operatortype_find(self->name);
 | 
			
		||||
	if (ot == NULL) {
 | 
			
		||||
		PyErr_SetString( PyExc_SystemError, "Operator could not be found");
 | 
			
		||||
		return NULL;
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	RNA_pointer_create(NULL, NULL, ot->srna, &properties, &ptr);
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -70,10 +70,8 @@ static char *pyrna_enum_as_string(PointerRNA *ptr, PropertyRNA *prop)
 | 
			
		||||
	RNA_property_enum_items(ptr, prop, &item, &totitem);
 | 
			
		||||
 | 
			
		||||
	for (i=0; i<totitem; i++) {
 | 
			
		||||
		if (i<totitem-1)
 | 
			
		||||
			BLI_dynstr_appendf(dynstr, "'%s', ", item[i].identifier);
 | 
			
		||||
		else
 | 
			
		||||
			BLI_dynstr_appendf(dynstr, "'%s'", item[i].identifier);
 | 
			
		||||
		
 | 
			
		||||
		BLI_dynstr_appendf(dynstr, i?", '%s'":"'%s'", item[i].identifier);
 | 
			
		||||
	}
 | 
			
		||||
	
 | 
			
		||||
	cstring = BLI_dynstr_get_cstring(dynstr);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user