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:
authorBastien Montagne <b.mont29@gmail.com>2020-02-14 14:50:52 +0300
committerBastien Montagne <b.mont29@gmail.com>2020-02-14 14:52:47 +0300
commit1c1b78eab584e9c4ccdd60568af94d6ec5ef999c (patch)
tree48f2622a2669871f320cf82000abb3e166eddd30 /source/blender/blenkernel/intern/lib_query.c
parente277e8d085037414f34b27f9c1a26cbbf2507c3e (diff)
Make libquery resilient to old blend-files missing pointers.
This makes libquery usable during blendfile reading phases. Some pointers that shall never be NULL in modern Main database did not exist before.
Diffstat (limited to 'source/blender/blenkernel/intern/lib_query.c')
-rw-r--r--source/blender/blenkernel/intern/lib_query.c17
1 files changed, 11 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/lib_query.c b/source/blender/blenkernel/intern/lib_query.c
index fcbb1458749..4b4d744c41a 100644
--- a/source/blender/blenkernel/intern/lib_query.c
+++ b/source/blender/blenkernel/intern/lib_query.c
@@ -528,7 +528,10 @@ static void library_foreach_ID_link(Main *bmain,
SEQ_END;
}
- library_foreach_collection(&data, scene->master_collection);
+ /* This pointer can be NULL during old files reading, better be safe than sorry. */
+ if (scene->master_collection != NULL) {
+ library_foreach_collection(&data, scene->master_collection);
+ }
ViewLayer *view_layer;
for (view_layer = scene->view_layers.first; view_layer; view_layer = view_layer->next) {
@@ -1030,13 +1033,15 @@ static void library_foreach_ID_link(Main *bmain,
wmWindowManager *wm = (wmWindowManager *)id;
for (wmWindow *win = wm->windows.first; win; win = win->next) {
- ID *workspace = (ID *)BKE_workspace_active_get(win->workspace_hook);
-
CALLBACK_INVOKE(win->scene, IDWALK_CB_USER_ONE);
- CALLBACK_INVOKE_ID(workspace, IDWALK_CB_NOP);
- /* allow callback to set a different workspace */
- BKE_workspace_active_set(win->workspace_hook, (WorkSpace *)workspace);
+ /* This pointer can be NULL during old files reading, better be safe than sorry. */
+ if (win->workspace_hook != NULL) {
+ ID *workspace = (ID *)BKE_workspace_active_get(win->workspace_hook);
+ CALLBACK_INVOKE_ID(workspace, IDWALK_CB_NOP);
+ /* allow callback to set a different workspace */
+ BKE_workspace_active_set(win->workspace_hook, (WorkSpace *)workspace);
+ }
}
break;
}