Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMitchell Stokes <mogurijin@gmail.com>2012-06-21 09:41:06 +0400
committerMitchell Stokes <mogurijin@gmail.com>2012-06-21 09:41:06 +0400
commitd8e2c475a0dbfb9de31c363f76899435d80cff8f (patch)
treebf96da27100e88225895bb58e489934494b10191 /source/blender/python
parent501922782fec2cd626e3bea13d67f9e225ab025e (diff)
Fix for [#31396] "bge.logic.LibLoad fails to import text blocks" reported by Leonard Ritter.
Blender's import function check's the Text datablocks in main for additional modules for importing. However, libloaded scenes were 1) not loading Text datablocks and 2) not letting bpy know about them. Text datablocks are now loaded if a Scene is loaded and bpy can now looking through extra Mains to find additional modules.
Diffstat (limited to 'source/blender/python')
-rw-r--r--source/blender/python/generic/bpy_internal_import.c23
-rw-r--r--source/blender/python/generic/bpy_internal_import.h4
2 files changed, 27 insertions, 0 deletions
diff --git a/source/blender/python/generic/bpy_internal_import.c b/source/blender/python/generic/bpy_internal_import.c
index 5999040a2ab..3a46c6971cf 100644
--- a/source/blender/python/generic/bpy_internal_import.c
+++ b/source/blender/python/generic/bpy_internal_import.c
@@ -52,6 +52,7 @@
#include "BKE_main.h"
static Main *bpy_import_main = NULL;
+static ListBase bpy_import_main_list;
/* 'builtins' is most likely PyEval_GetBuiltins() */
void bpy_import_init(PyObject *builtins)
@@ -92,6 +93,16 @@ void bpy_import_main_set(struct Main *maggie)
bpy_import_main = maggie;
}
+void bpy_import_main_extra_add(struct Main *maggie)
+{
+ BLI_addhead(&bpy_import_main_list, maggie);
+}
+
+void bpy_import_main_extra_remove(struct Main *maggie)
+{
+ BLI_remlink_safe(&bpy_import_main_list, maggie);
+}
+
/* returns a dummy filename for a textblock so we can tell what file a text block comes from */
void bpy_text_filename_get(char *fn, size_t fn_len, Text *text)
{
@@ -150,6 +161,18 @@ PyObject *bpy_text_import_name(const char *name, int *found)
text = BLI_findstring(&maggie->text, txtname, offsetof(ID, name) + 2);
+ if (text) {
+ *found = 1;
+ return bpy_text_import(text);
+ }
+
+ /* If we still haven't found the module try additional modules form bpy_import_main_list */
+ maggie = bpy_import_main_list.first;
+ while (maggie && !text) {
+ text = BLI_findstring(&maggie->text, txtname, offsetof(ID, name) + 2);
+ maggie = maggie->next;
+ }
+
if (!text)
return NULL;
else
diff --git a/source/blender/python/generic/bpy_internal_import.h b/source/blender/python/generic/bpy_internal_import.h
index 8b41a575d96..980e6edca03 100644
--- a/source/blender/python/generic/bpy_internal_import.h
+++ b/source/blender/python/generic/bpy_internal_import.h
@@ -62,4 +62,8 @@ extern PyMethodDef bpy_reload_meth;
struct Main *bpy_import_main_get(void);
void bpy_import_main_set(struct Main *maggie);
+/* This is used for importing text from dynamically loaded libraries in the game engine */
+void bpy_import_main_extra_add(struct Main *maggie);
+void bpy_import_main_extra_remove(struct Main *maggie);
+
#endif /* __BPY_INTERNAL_IMPORT_H__ */