Cleanup: style, use braces for the Python API
This commit is contained in:
@@ -98,8 +98,9 @@ void BPY_context_update(bContext *C)
|
||||
/* don't do this from a non-main (e.g. render) thread, it can cause a race
|
||||
* condition on C->data.recursion. ideal solution would be to disable
|
||||
* context entirely from non-main threads, but that's more complicated */
|
||||
if (!BLI_thread_is_main())
|
||||
if (!BLI_thread_is_main()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BPy_SetContext(C);
|
||||
bpy_import_main_set(CTX_data_main(C));
|
||||
@@ -110,8 +111,9 @@ void bpy_context_set(bContext *C, PyGILState_STATE *gilstate)
|
||||
{
|
||||
py_call_level++;
|
||||
|
||||
if (gilstate)
|
||||
if (gilstate) {
|
||||
*gilstate = PyGILState_Ensure();
|
||||
}
|
||||
|
||||
if (py_call_level == 1) {
|
||||
BPY_context_update(C);
|
||||
@@ -135,8 +137,9 @@ void bpy_context_clear(bContext *UNUSED(C), PyGILState_STATE *gilstate)
|
||||
{
|
||||
py_call_level--;
|
||||
|
||||
if (gilstate)
|
||||
if (gilstate) {
|
||||
PyGILState_Release(*gilstate);
|
||||
}
|
||||
|
||||
if (py_call_level < 0) {
|
||||
fprintf(stderr, "ERROR: Python context internal state bug. this should not happen!\n");
|
||||
@@ -163,14 +166,16 @@ void BPY_text_free_code(Text *text)
|
||||
PyGILState_STATE gilstate;
|
||||
bool use_gil = !PyC_IsInterpreterActive();
|
||||
|
||||
if (use_gil)
|
||||
if (use_gil) {
|
||||
gilstate = PyGILState_Ensure();
|
||||
}
|
||||
|
||||
Py_DECREF((PyObject *)text->compiled);
|
||||
text->compiled = NULL;
|
||||
|
||||
if (use_gil)
|
||||
if (use_gil) {
|
||||
PyGILState_Release(gilstate);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,8 +189,9 @@ void BPY_modules_update(bContext *C)
|
||||
|
||||
/* refreshes the main struct */
|
||||
BPY_update_rna_module();
|
||||
if (bpy_context_module)
|
||||
if (bpy_context_module) {
|
||||
bpy_context_module->ptr.data = (void *)C;
|
||||
}
|
||||
}
|
||||
|
||||
void BPY_context_set(bContext *C)
|
||||
@@ -371,11 +377,13 @@ void BPY_python_end(void)
|
||||
printf("*bpy stats* - ");
|
||||
printf("tot exec: %d, ", bpy_timer_count);
|
||||
printf("tot run: %.4fsec, ", bpy_timer_run_tot);
|
||||
if (bpy_timer_count > 0)
|
||||
if (bpy_timer_count > 0) {
|
||||
printf("average run: %.6fsec, ", (bpy_timer_run_tot / bpy_timer_count));
|
||||
}
|
||||
|
||||
if (bpy_timer > 0.0)
|
||||
if (bpy_timer > 0.0) {
|
||||
printf("tot usage %.4f%%", (bpy_timer_run_tot / bpy_timer) * 100.0);
|
||||
}
|
||||
|
||||
printf("\n");
|
||||
|
||||
@@ -750,8 +758,9 @@ void BPY_modules_load_user(bContext *C)
|
||||
Text *text;
|
||||
|
||||
/* can happen on file load */
|
||||
if (bmain == NULL)
|
||||
if (bmain == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* update pointers since this can run from a nested script
|
||||
* on file load */
|
||||
@@ -802,8 +811,9 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
|
||||
PointerRNA *ptr = NULL;
|
||||
bool done = false;
|
||||
|
||||
if (use_gil)
|
||||
if (use_gil) {
|
||||
gilstate = PyGILState_Ensure();
|
||||
}
|
||||
|
||||
pyctx = (PyObject *)CTX_py_dict_get(C);
|
||||
item = PyDict_GetItemString(pyctx, member);
|
||||
@@ -870,8 +880,9 @@ int BPY_context_member_get(bContext *C, const char *member, bContextDataResult *
|
||||
CLOG_INFO(BPY_LOG_CONTEXT, 2, "'%s' found", member);
|
||||
}
|
||||
|
||||
if (use_gil)
|
||||
if (use_gil) {
|
||||
PyGILState_Release(gilstate);
|
||||
}
|
||||
|
||||
return done;
|
||||
}
|
||||
@@ -971,8 +982,9 @@ PyInit_bpy(void)
|
||||
dealloc_obj_Type.tp_dealloc = dealloc_obj_dealloc;
|
||||
dealloc_obj_Type.tp_flags = Py_TPFLAGS_DEFAULT;
|
||||
|
||||
if (PyType_Ready(&dealloc_obj_Type) < 0)
|
||||
if (PyType_Ready(&dealloc_obj_Type) < 0) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dob = (dealloc_obj *) dealloc_obj_Type.tp_alloc(&dealloc_obj_Type, 0);
|
||||
dob->mod = bpy_proxy; /* borrow */
|
||||
|
||||
Reference in New Issue
Block a user