Commit: 3b0a5dd15884aed00d988d73a72f4946673f8be9
Author: Campbell Barton
Date:   Thu Jun 23 07:52:58 2016 +1000
Branches: blender2.8
https://developer.blender.org/rB3b0a5dd15884aed00d988d73a72f4946673f8be9

Merge branch 'master' into blender2.8

===================================================================



===================================================================

diff --cc source/blender/blenkernel/intern/library.c
index 64c9ddb,fe16df1..5f7bded
--- a/source/blender/blenkernel/intern/library.c
+++ b/source/blender/blenkernel/intern/library.c
@@@ -106,12 -104,9 +104,8 @@@
  #include "BKE_mask.h"
  #include "BKE_node.h"
  #include "BKE_object.h"
- #include "BKE_paint.h"
 -#include "BKE_particle.h"
  #include "BKE_packedFile.h"
  #include "BKE_speaker.h"
- #include "BKE_sound.h"
- #include "BKE_screen.h"
  #include "BKE_scene.h"
  #include "BKE_text.h"
  #include "BKE_texture.h"
diff --cc source/blender/blenkernel/intern/library_remap.c
index 0000000,4bde075..9335d41
mode 000000,100644..100644
--- a/source/blender/blenkernel/intern/library_remap.c
+++ b/source/blender/blenkernel/intern/library_remap.c
@@@ -1,0 -1,768 +1,764 @@@
+ /*
+  * ***** BEGIN GPL LICENSE BLOCK *****
+  *
+  * This program is free software; you can redistribute it and/or
+  * modify it under the terms of the GNU General Public License
+  * as published by the Free Software Foundation; either version 2
+  * of the License, or (at your option) any later version.
+  *
+  * This program is distributed in the hope that it will be useful,
+  * but WITHOUT ANY WARRANTY; without even the implied warranty of
+  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+  * GNU General Public License for more details.
+  *
+  * You should have received a copy of the GNU General Public License
+  * along with this program; if not, write to the Free Software Foundation,
+  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+  *
+  * ***** END GPL LICENSE BLOCK *****
+  */
+ 
+ /** \file blender/blenkernel/intern/library_remap.c
+  *  \ingroup bke
+  *
+  * Contains management of ID's and libraries remap, unlink and free logic.
+  */
+ 
+ #include <stdio.h>
+ #include <ctype.h>
+ #include <string.h>
+ #include <stdlib.h>
+ #include <stddef.h>
+ #include <assert.h>
+ 
+ #include "MEM_guardedalloc.h"
+ 
+ /* all types are needed here, in order to do memory operations */
+ #include "DNA_anim_types.h"
+ #include "DNA_armature_types.h"
+ #include "DNA_brush_types.h"
+ #include "DNA_camera_types.h"
+ #include "DNA_group_types.h"
+ #include "DNA_gpencil_types.h"
+ #include "DNA_ipo_types.h"
+ #include "DNA_key_types.h"
+ #include "DNA_lamp_types.h"
+ #include "DNA_lattice_types.h"
+ #include "DNA_linestyle_types.h"
+ #include "DNA_material_types.h"
+ #include "DNA_mesh_types.h"
+ #include "DNA_meta_types.h"
+ #include "DNA_movieclip_types.h"
+ #include "DNA_mask_types.h"
+ #include "DNA_node_types.h"
+ #include "DNA_object_types.h"
+ #include "DNA_scene_types.h"
+ #include "DNA_screen_types.h"
+ #include "DNA_speaker_types.h"
+ #include "DNA_sound_types.h"
+ #include "DNA_text_types.h"
+ #include "DNA_vfont_types.h"
+ #include "DNA_windowmanager_types.h"
+ #include "DNA_world_types.h"
+ 
+ #include "BLI_blenlib.h"
+ #include "BLI_utildefines.h"
+ 
+ #include "BKE_action.h"
+ #include "BKE_animsys.h"
+ #include "BKE_armature.h"
+ #include "BKE_brush.h"
+ #include "BKE_camera.h"
+ #include "BKE_curve.h"
+ #include "BKE_depsgraph.h"
+ #include "BKE_fcurve.h"
+ #include "BKE_font.h"
+ #include "BKE_group.h"
+ #include "BKE_gpencil.h"
+ #include "BKE_idprop.h"
+ #include "BKE_image.h"
+ #include "BKE_ipo.h"
+ #include "BKE_key.h"
+ #include "BKE_lamp.h"
+ #include "BKE_lattice.h"
+ #include "BKE_library.h"
+ #include "BKE_library_query.h"
+ #include "BKE_library_remap.h"
+ #include "BKE_linestyle.h"
+ #include "BKE_mesh.h"
+ #include "BKE_material.h"
+ #include "BKE_main.h"
+ #include "BKE_mball.h"
+ #include "BKE_movieclip.h"
+ #include "BKE_mask.h"
+ #include "BKE_node.h"
+ #include "BKE_object.h"
+ #include "BKE_paint.h"
 -#include "BKE_particle.h"
+ #include "BKE_speaker.h"
+ #include "BKE_sound.h"
+ #include "BKE_screen.h"
+ #include "BKE_scene.h"
+ #include "BKE_text.h"
+ #include "BKE_texture.h"
+ #include "BKE_world.h"
+ 
+ #ifdef WITH_PYTHON
+ #include "BPY_extern.h"
+ #endif
+ 
+ static BKE_library_free_window_manager_cb free_windowmanager_cb = NULL;
+ 
+ void 
BKE_library_callback_free_window_manager_set(BKE_library_free_window_manager_cb 
func)
+ {
+       free_windowmanager_cb = func;
+ }
+ 
+ static BKE_library_free_notifier_reference_cb free_notifier_reference_cb = 
NULL;
+ 
+ void 
BKE_library_callback_free_notifier_reference_set(BKE_library_free_notifier_reference_cb
 func)
+ {
+       free_notifier_reference_cb = func;
+ }
+ 
+ static BKE_library_remap_editor_id_reference_cb remap_editor_id_reference_cb 
= NULL;
+ 
+ void 
BKE_library_callback_remap_editor_id_reference_set(BKE_library_remap_editor_id_reference_cb
 func)
+ {
+       remap_editor_id_reference_cb = func;
+ }
+ 
+ typedef struct IDRemap {
+       ID *old_id;
+       ID *new_id;
+       ID *id;  /* The ID in which we are replacing old_id by new_id usages. */
+       short flag;
+ 
+       /* 'Output' data. */
+       short status;
+       int skipped_direct;  /* Number of direct usecases that could not be 
remapped (e.g.: obdata when in edit mode). */
+       int skipped_indirect;  /* Number of indirect usecases that could not be 
remapped. */
+       int skipped_refcounted;  /* Number of skipped usecases that refcount 
the datablock. */
+ } IDRemap;
+ 
+ /* IDRemap->flag enums defined in BKE_library.h */
+ 
+ /* IDRemap->status */
+ enum {
+       /* *** Set by callback. *** */
+       ID_REMAP_IS_LINKED_DIRECT       = 1 << 0,  /* new_id is directly linked 
in current .blend. */
+       ID_REMAP_IS_USER_ONE_SKIPPED    = 1 << 1,  /* There was some skipped 
'user_one' usages of old_id. */
+ };
+ 
+ static int foreach_libblock_remap_callback(void *user_data, ID 
*UNUSED(id_self), ID **id_p, int cb_flag)
+ {
+       IDRemap *id_remap_data = user_data;
+       ID *old_id = id_remap_data->old_id;
+       ID *new_id = id_remap_data->new_id;
+       ID *id = id_remap_data->id;
+ 
+       if (!old_id) {  /* Used to cleanup all IDs used by a specific one. */
+               BLI_assert(!new_id);
+               old_id = *id_p;
+       }
+ 
+       if (*id_p && (*id_p == old_id)) {
+               /* Note: proxy usage implies LIB_TAG_EXTERN, so on this aspect 
it is direct,
+                *       on the other hand since they get reset to lib data on 
file open/reload it is indirect too...
+                *       Edit Mode is also a 'skip direct' case. */
+               const bool is_obj = (GS(id->name) == ID_OB);
+               const bool is_proxy = (is_obj && (((Object *)id)->proxy || 
((Object *)id)->proxy_group));
+               const bool is_obj_editmode = (is_obj && 
BKE_object_is_in_editmode((Object *)id));
+               /* Note that indirect data from same file as processed ID is 
**not** considered indirect! */
+               const bool is_indirect = ((id->lib != NULL) && (id->lib != 
old_id->lib));
+               const bool skip_indirect = (id_remap_data->flag & 
ID_REMAP_SKIP_INDIRECT_USAGE) != 0;
+               const bool is_never_null = ((cb_flag & IDWALK_NEVER_NULL) && 
(new_id == NULL) &&
+                                           (id_remap_data->flag & 
ID_REMAP_FORCE_NEVER_NULL_USAGE) == 0);
+               const bool skip_never_null = (id_remap_data->flag & 
ID_REMAP_SKIP_NEVER_NULL_USAGE) != 0;
+ 
+               if ((id_remap_data->flag & ID_REMAP_FLAG_NEVER_NULL_USAGE) && 
(cb_flag & IDWALK_NEVER_NULL)) {
+                       id->tag |= LIB_TAG_DOIT;
+               }
+ 
+               /* Special hack in case it's Object->data and we are in edit 
mode (skipped_direct too). */
+               if ((is_never_null && skip_never_null) ||
+                   (is_obj_editmode && (((Object *)id)->data == *id_p)) ||
+                   (skip_indirect && (is_proxy || is_indirect)))
+               {
+                       if (is_never_null || is_proxy || is_obj_editmode) {
+                               id_remap_data->skipped_direct++;
+                       }
+                       else {
+                               id_remap_data->skipped_indirect++;
+                       }
+                       if (cb_flag & IDWALK_USER) {
+                               id_remap_data->skipped_refcounted++;
+                       }
+                       else if (cb_flag & IDWALK_USER_ONE) {
+                               /* No need to count number of times this 
happens, just a flag is enough. */
+                               id_remap_data->status |= 
ID_REMAP_IS_USER_ONE_SKIPPED;
+                       }
+               }
+               else {
+                       if (!is_never_null) {
+                               *id_p = new_id;
+                       }
+                       if (cb_flag & IDWALK_USER) {
+                               id_us_min(old_id);
+                               /* We do not want to handle 
LIB_TAG_INDIRECT/LIB_TAG_EXTERN here. */
+                               if (new_id)
+                                       new_id->us++;
+                       }
+                       else if (cb_flag & IDWALK_USER_ONE) {
+                               id_us_ensure_real(new_id);
+                               /* We cannot affect old_id->us directly, 
LIB_TAG_EXTRAUSER(_SET) are assumed to be set as needed,
+                                * that extra user is processed in final 
handling... */
+                       }
+                       if (!is_indirect) {
+                               id_remap_data->status |= 
ID_REMAP_IS_LINKED_DIRECT;
+                       }
+               }
+       }
+ 
+       return IDWALK_RET_NOP;
+ }
+ 
+ /**
+  * Execute the 'data' part of the remapping (that is, all ID pointers from 
other ID datablocks).
+  *
+  * Behavior differs depending on whether given \a id is NULL or not:
+  * - \a id NULL: \a old_id must be non-NULL, \a new_id may be NULL (unlinking 
\a old_id) or not
+  *   (remapping \a old_id to \a new_id). The whole \a bmain database is 
checked, and all pointers to \a old_id
+  *   are remapped to \a new_id.
+  * - \a id is non-NULL:
+  *   + If \a old_id is NULL, \a new_id must also be NULL, and all ID pointers 
from \a id are cleared (i.e. \a id
+  *     does not references any other datablock anymore).
+  *   + If \a old_id is non-NULL, behavior is as with a NULL \a id, but only 
for given \a id.
+  *
+  * \param bmain: the Main data storage to operate on (can be NULL if \a id is 
non-NULL).
+  * \param id: the datablock to operate on (can be NULL if \a bmain is 
non-NULL).
+  * \param old_id: the datablock to dereference (may be NULL if \a id is 
non-NULL).
+  * \param new_id: the new datablock to replace \a old_id references with (may 
be NULL).
+  * \param r_id_remap_data: if non-NULL, the IDRemap struct to use (uselful to 
retrieve info about remapping process).
+  */
+ static void libblock_remap_data(
+         Main *bmain, ID *id, ID *old_id, ID *new_id, const short remap_flags, 
IDRemap *r_id_remap_data)
+ {
+       IDRemap id_remap_data;
+       ListBase *lb_array[MAX_LIBARRAY];
+       int i;
+ 
+       if (r_id_remap_data == NULL) {
+               r_id_remap_data = &id_remap_data;
+       }
+       r_id_remap_data->old_id = old_id;
+       r_id_remap_data->new_id = new_id;
+       r_id_remap_data->id = NULL;
+       r_id_remap_data->flag = remap_flags;
+       r_id_remap_data->status = 0;
+       r_id_remap_data->skipped_direct = 0;
+       r_id_remap_data->skipped_indirect = 0;
+       r_id_remap_data->skipped_refcounted = 0;
+ 
+       if (id) {

@@ Diff output truncated at 10240 characters. @@

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to