Changeset View
Changeset View
Standalone View
Standalone View
source/blender/blenkernel/intern/context.c
| Show First 20 Lines • Show All 56 Lines • ▼ Show 20 Lines | |||||
| #include "BKE_screen.h" | #include "BKE_screen.h" | ||||
| #include "BKE_sound.h" | #include "BKE_sound.h" | ||||
| #include "BKE_workspace.h" | #include "BKE_workspace.h" | ||||
| #include "RE_engine.h" | #include "RE_engine.h" | ||||
| #include "RNA_access.h" | #include "RNA_access.h" | ||||
| #include "CLG_log.h" | |||||
| #ifdef WITH_PYTHON | #ifdef WITH_PYTHON | ||||
| # include "BPY_extern.h" | # include "BPY_extern.h" | ||||
| #endif | #endif | ||||
| static CLG_LogRef LOG = {"bke.context"}; | |||||
| /* struct */ | /* struct */ | ||||
| struct bContext { | struct bContext { | ||||
| int thread; | int thread; | ||||
| /* windowmanager context */ | /* windowmanager context */ | ||||
| struct { | struct { | ||||
| struct wmWindowManager *manager; | struct wmWindowManager *manager; | ||||
| ▲ Show 20 Lines • Show All 173 Lines • ▼ Show 20 Lines | if (UNLIKELY(C && CTX_py_dict_get(C))) { | ||||
| memset(&result, 0, sizeof(bContextDataResult)); | memset(&result, 0, sizeof(bContextDataResult)); | ||||
| BPY_context_member_get((bContext *)C, member, &result); | BPY_context_member_get((bContext *)C, member, &result); | ||||
| if (result.ptr.data) { | if (result.ptr.data) { | ||||
| if (RNA_struct_is_a(result.ptr.type, member_type)) { | if (RNA_struct_is_a(result.ptr.type, member_type)) { | ||||
| return result.ptr.data; | return result.ptr.data; | ||||
| } | } | ||||
| else { | else { | ||||
| printf("PyContext '%s' is a '%s', expected a '%s'\n", | CLOG_WARN(&LOG, "PyContext '%s' is a '%s', expected a '%s'", | ||||
| member, | member, | ||||
| RNA_struct_identifier(result.ptr.type), | RNA_struct_identifier(result.ptr.type), | ||||
| RNA_struct_identifier(member_type)); | RNA_struct_identifier(member_type)); | ||||
| } | } | ||||
| } | } | ||||
| } | } | ||||
| #else | #else | ||||
| UNUSED_VARS(C, member, member_type); | UNUSED_VARS(C, member, member_type); | ||||
| #endif | #endif | ||||
| /* don't allow UI context access from non-main threads */ | /* don't allow UI context access from non-main threads */ | ||||
| ▲ Show 20 Lines • Show All 138 Lines • ▼ Show 20 Lines | |||||
| { | { | ||||
| PointerRNA ptr = CTX_data_pointer_get(C, member); | PointerRNA ptr = CTX_data_pointer_get(C, member); | ||||
| if (ptr.data) { | if (ptr.data) { | ||||
| if (RNA_struct_is_a(ptr.type, type)) { | if (RNA_struct_is_a(ptr.type, type)) { | ||||
| return ptr; | return ptr; | ||||
| } | } | ||||
| else { | else { | ||||
| printf("%s: warning, member '%s' is '%s', not '%s'\n", | CLOG_WARN(&LOG, "member '%s' is '%s', not '%s'", | ||||
| __func__, member, RNA_struct_identifier(ptr.type), RNA_struct_identifier(type)); | member, RNA_struct_identifier(ptr.type), RNA_struct_identifier(type)); | ||||
| } | } | ||||
| } | } | ||||
| return PointerRNA_NULL; | return PointerRNA_NULL; | ||||
| } | } | ||||
| ListBase CTX_data_collection_get(const bContext *C, const char *member) | ListBase CTX_data_collection_get(const bContext *C, const char *member) | ||||
| { | { | ||||
| ▲ Show 20 Lines • Show All 828 Lines • Show Last 20 Lines | |||||