@@ -8130,7 +8130,7 @@ static void pyrna_subtype_set_rna(PyObject *newclass, StructRNA *srna)
8130
8130
/* *
8131
8131
* \return borrowed reference.
8132
8132
*/
8133
- static PyObject *pyrna_srna_PyBase (StructRNA *srna) // , PyObject *bpy_types_dict)
8133
+ static PyObject *pyrna_srna_PyBase (StructRNA *srna)
8134
8134
{
8135
8135
/* Assume RNA_struct_py_type_get(srna) was already checked. */
8136
8136
StructRNA *base;
@@ -8153,9 +8153,15 @@ static PyObject *pyrna_srna_PyBase(StructRNA *srna) //, PyObject *bpy_types_dic
8153
8153
return py_base;
8154
8154
}
8155
8155
8156
- /* Check if we have a native Python subclass, use it when it exists
8157
- * return a borrowed reference. */
8156
+ /* *
8157
+ * Check if we have a native Python subclass, use it when it exists
8158
+ * return a borrowed reference.
8159
+ */
8158
8160
static PyObject *bpy_types_dict = nullptr ;
8161
+ void BPY_rna_types_dict_set (PyObject *dict)
8162
+ {
8163
+ bpy_types_dict = dict; /* Borrow. */
8164
+ }
8159
8165
8160
8166
/* *
8161
8167
* Return the #PyTypeObject or null,
@@ -8164,22 +8170,10 @@ static PyObject *bpy_types_dict = nullptr;
8164
8170
*/
8165
8171
static PyObject *pyrna_srna_ExternalType (StructRNA *srna)
8166
8172
{
8167
- const char *idname = RNA_struct_identifier (srna);
8168
- PyObject *newclass;
8169
-
8170
- if (bpy_types_dict == nullptr ) {
8171
- PyObject *bpy_types = PyImport_ImportModuleLevel (" _bpy_types" , nullptr , nullptr , nullptr , 0 );
8173
+ BLI_assert (bpy_types_dict);
8172
8174
8173
- if (bpy_types == nullptr ) {
8174
- PyErr_Print ();
8175
- CLOG_ERROR (BPY_LOG_RNA, " failed to find '_bpy_types' module" );
8176
- return nullptr ;
8177
- }
8178
- bpy_types_dict = PyModule_GetDict (bpy_types); /* Borrow. */
8179
- Py_DECREF (bpy_types); /* Fairly safe to assume the dict is kept. */
8180
- }
8181
-
8182
- newclass = PyDict_GetItemString (bpy_types_dict, idname);
8175
+ const char *idname = RNA_struct_identifier (srna);
8176
+ PyObject *newclass = PyDict_GetItemString (bpy_types_dict, idname);
8183
8177
8184
8178
/* Sanity check, could skip this unless in debug mode. */
8185
8179
if (newclass) {
0 commit comments