[Bf-blender-cvs] [d6502fe] temp_widgets_update_tagging: Merge branch 'wiggly-widgets' into temp_widgets_update_tagging

Julian Eisel noreply at git.blender.org
Wed Mar 9 15:59:45 CET 2016


Commit: d6502fe94c563025121942765ab05e6412dc31c2
Author: Julian Eisel
Date:   Wed Mar 9 15:59:18 2016 +0100
Branches: temp_widgets_update_tagging
https://developer.blender.org/rBd6502fe94c563025121942765ab05e6412dc31c2

Merge branch 'wiggly-widgets' into temp_widgets_update_tagging

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

M	source/blender/blenkernel/intern/action.c
M	source/blender/blenkernel/intern/armature.c
M	source/blender/blenkernel/intern/library_query.c
M	source/blender/blenkernel/intern/object.c
M	source/blender/blenloader/intern/readfile.c
M	source/blender/makesrna/intern/rna_pose.c
M	source/blender/windowmanager/widgets/intern/wm_widget.c
M	source/blender/windowmanager/widgets/intern/wm_widget_intern.h
M	source/blender/windowmanager/widgets/intern/wm_widgetgroup.c
M	source/blender/windowmanager/widgets/intern/wm_widgetmap.c
M	source/gameengine/Converter/BL_ArmatureObject.cpp

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

diff --git a/source/blender/blenkernel/intern/action.c b/source/blender/blenkernel/intern/action.c
index b77ae45..b680aaf 100644
--- a/source/blender/blenkernel/intern/action.c
+++ b/source/blender/blenkernel/intern/action.c
@@ -776,6 +776,14 @@ void BKE_pose_channels_remove(
  */
 void BKE_pose_channel_free_ex(bPoseChannel *pchan, bool do_id_user)
 {
+	if (pchan->fmap_object) {
+		if (do_id_user) {
+			id_us_min(&pchan->fmap_object->id);
+		}
+		pchan->fmap_object = NULL;
+	}
+	pchan->fmap = NULL;
+
 	if (pchan->custom) {
 		if (do_id_user) {
 			id_us_min(&pchan->custom->id);
@@ -917,6 +925,13 @@ void BKE_pose_channel_copy_data(bPoseChannel *pchan, const bPoseChannel *pchan_f
 		pchan->prop = IDP_CopyProperty(pchan_from->prop);
 	}
 
+	/* face map */
+	pchan->fmap_object = pchan_from->fmap_object;
+	pchan->fmap = pchan_from->fmap;
+	if (pchan->fmap_object) {
+		id_us_plus(&pchan->fmap_object->id);
+	}
+
 	/* custom shape */
 	pchan->custom = pchan_from->custom;
 	if (pchan->custom) {
diff --git a/source/blender/blenkernel/intern/armature.c b/source/blender/blenkernel/intern/armature.c
index 54fe989..2f380de 100644
--- a/source/blender/blenkernel/intern/armature.c
+++ b/source/blender/blenkernel/intern/armature.c
@@ -1755,11 +1755,19 @@ static void pose_proxy_synchronize(Object *ob, Object *from, int layer_protected
 			
 			/* copy data in temp back over to the cleaned-out (but still allocated) original channel */
 			*pchan = pchanw;
+			if (pchan->fmap_object) {
+				id_us_plus(&pchan->fmap_object->id);
+			}
 			if (pchan->custom) {
 				id_us_plus(&pchan->custom->id);
 			}
 		}
 		else {
+			pchan->fmap_object = pchanp->fmap_object;
+			pchan->fmap = pchanp->fmap;
+			if (pchan->fmap_object) {
+				id_us_plus(&pchan->fmap_object->id);
+			}
 			/* always copy custom shape */
 			pchan->custom = pchanp->custom;
 			if (pchan->custom) {
diff --git a/source/blender/blenkernel/intern/library_query.c b/source/blender/blenkernel/intern/library_query.c
index f5e17c0..6e9bdbf 100644
--- a/source/blender/blenkernel/intern/library_query.c
+++ b/source/blender/blenkernel/intern/library_query.c
@@ -346,6 +346,7 @@ void BKE_library_foreach_ID_link(ID *id, LibraryIDLinkCallback callback, void *u
 			if (object->pose) {
 				bPoseChannel *pchan;
 				for (pchan = object->pose->chanbase.first; pchan; pchan = pchan->next) {
+					CALLBACK_INVOKE(pchan->fmap_object, IDWALK_USER);
 					CALLBACK_INVOKE(pchan->custom, IDWALK_USER);
 					BKE_constraints_id_loop(&pchan->constraints, library_foreach_constraintObjectLooper, &data);
 				}
diff --git a/source/blender/blenkernel/intern/object.c b/source/blender/blenkernel/intern/object.c
index b55af88..e481f49 100644
--- a/source/blender/blenkernel/intern/object.c
+++ b/source/blender/blenkernel/intern/object.c
@@ -577,6 +577,10 @@ void BKE_object_unlink(Main *bmain, Object *ob)
 							cti->flush_constraint_targets(con, &targets, 0);
 					}
 				}
+				if (pchan->fmap_object == ob) {
+					pchan->fmap_object = NULL;
+					pchan->fmap = NULL;
+				}
 				if (pchan->custom == ob)
 					pchan->custom = NULL;
 			}
@@ -1717,10 +1721,11 @@ static void armature_set_id_extern(Object *ob)
 	unsigned int lay = arm->layer_protected;
 	
 	for (pchan = ob->pose->chanbase.first; pchan; pchan = pchan->next) {
-		if (!(pchan->bone->layer & lay))
+		if (!(pchan->bone->layer & lay)) {
+			id_lib_extern((ID *)pchan->fmap_object);
 			id_lib_extern((ID *)pchan->custom);
+		}
 	}
-			
 }
 
 void BKE_object_copy_proxy_drivers(Object *ob, Object *target)
diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index 60565ec..32802a0 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -3233,8 +3233,10 @@ static void lib_link_pose(FileData *fd, Main *bmain, Object *ob, bPose *pose)
 		
 		pchan->fmap_object = newlibadr_us(fd, arm->id.lib, pchan->fmap_object);
 		if (pchan->fmap_object) {
+			bFaceMap *fmap = fmap_find_name(pchan->fmap_object, pchan->fmap->name);
 			/* fix fmap pointer now that we've got updated fmap_object */
-			pchan->fmap = fmap_find_name(pchan->fmap_object, pchan->fmap->name);
+			MEM_freeN(pchan->fmap);
+			pchan->fmap = fmap;
 		}
 
 		pchan->custom = newlibadr_us(fd, arm->id.lib, pchan->custom);
@@ -9061,6 +9063,7 @@ static void expand_pose(FileData *fd, Main *mainvar, bPose *pose)
 	
 	for (chan = pose->chanbase.first; chan; chan = chan->next) {
 		expand_constraints(fd, mainvar, &chan->constraints);
+		expand_doit(fd, mainvar, chan->fmap_object);
 		expand_doit(fd, mainvar, chan->custom);
 	}
 }
diff --git a/source/blender/makesrna/intern/rna_pose.c b/source/blender/makesrna/intern/rna_pose.c
index b8d76fc..f7f0acc 100644
--- a/source/blender/makesrna/intern/rna_pose.c
+++ b/source/blender/makesrna/intern/rna_pose.c
@@ -290,10 +290,16 @@ static void rna_PoseChannel_bone_fmap_object_set(PointerRNA *ptr, PointerRNA val
 {
 	bPoseChannel *pchan = (bPoseChannel *)ptr->data;
 
-	pchan->fmap_object = value.data;
-	if (!pchan->fmap_object) {
+	if (pchan->fmap_object) {
+		id_us_min(&pchan->fmap_object->id);
+		pchan->fmap_object = NULL;
+	}
+	else {
 		pchan->fmap = NULL;
 	}
+
+	pchan->fmap_object = value.data;
+	id_us_plus(&pchan->fmap_object->id);
 }
 
 static int rna_PoseChannel_has_ik_get(PointerRNA *ptr)
diff --git a/source/blender/windowmanager/widgets/intern/wm_widget.c b/source/blender/windowmanager/widgets/intern/wm_widget.c
index e60535d..520c9ba 100644
--- a/source/blender/windowmanager/widgets/intern/wm_widget.c
+++ b/source/blender/windowmanager/widgets/intern/wm_widget.c
@@ -329,8 +329,7 @@ void wm_widget_deselect(const bContext *C, wmWidgetMap *wmap, wmWidget *widget)
 
 	/* update array data */
 	if ((*tot_selected) <= 1) {
-		MEM_SAFE_FREE(*sel);
-		*tot_selected = 0;
+		wm_widgetmap_selected_delete(wmap);
 	}
 	else {
 		*sel = MEM_reallocN(*sel, sizeof(**sel) * (*tot_selected));
@@ -356,7 +355,7 @@ void wm_widget_select(bContext *C, wmWidgetMap *wmap, wmWidget *widget)
 
 	(*tot_selected)++;
 
-	*sel = MEM_reallocN(*sel, sizeof(**sel) * (*tot_selected));
+	*sel = MEM_reallocN(*sel, sizeof(wmWidget *) * (*tot_selected));
 	(*sel)[(*tot_selected) - 1] = widget;
 
 	widget->flag |= WM_WIDGET_SELECTED;
diff --git a/source/blender/windowmanager/widgets/intern/wm_widget_intern.h b/source/blender/windowmanager/widgets/intern/wm_widget_intern.h
index c91c203..0cd4760 100644
--- a/source/blender/windowmanager/widgets/intern/wm_widget_intern.h
+++ b/source/blender/windowmanager/widgets/intern/wm_widget_intern.h
@@ -73,7 +73,7 @@ enum {
 	TWEAK_MODAL_PRECISION_OFF,
 };
 
-void wm_widgetgroup_free(bContext *C, struct wmWidgetMap *wmap, struct wmWidgetGroup *wgroup);
+void wm_widgetgroup_free(bContext *C, wmWidgetMap *wmap, struct wmWidgetGroup *wgroup);
 
 void wm_widgetgrouptype_keymap_init(struct wmWidgetGroupType *wgrouptype, struct wmKeyConfig *keyconf);
 
@@ -97,6 +97,8 @@ typedef struct wmWidgetMapType {
 	ListBase widgetgrouptypes;
 } wmWidgetMapType;
 
+void wm_widgetmap_selected_delete(wmWidgetMap *wmap);
+
 
 /* -------------------------------------------------------------------- */
 /* Widget drawing */
diff --git a/source/blender/windowmanager/widgets/intern/wm_widgetgroup.c b/source/blender/windowmanager/widgets/intern/wm_widgetgroup.c
index 1d60ccb..deb0c31 100644
--- a/source/blender/windowmanager/widgets/intern/wm_widgetgroup.c
+++ b/source/blender/windowmanager/widgets/intern/wm_widgetgroup.c
@@ -74,6 +74,7 @@ void wm_widgetgroup_free(bContext *C, wmWidgetMap *wmap, wmWidgetGroup *wgroup)
 		wm_widget_delete(&wgroup->widgets, widget);
 		widget = widget_next;
 	}
+	BLI_assert(BLI_listbase_is_empty(&wgroup->widgets));
 
 #ifdef WITH_PYTHON
 	if (wgroup->py_instance) {
diff --git a/source/blender/windowmanager/widgets/intern/wm_widgetmap.c b/source/blender/windowmanager/widgets/intern/wm_widgetmap.c
index bd1525a..6b03e09 100644
--- a/source/blender/windowmanager/widgets/intern/wm_widgetmap.c
+++ b/source/blender/windowmanager/widgets/intern/wm_widgetmap.c
@@ -103,6 +103,12 @@ wmWidgetMap *WM_widgetmap_from_type(const struct wmWidgetMapType_Params *wmap_pa
 	return wmap;
 }
 
+void wm_widgetmap_selected_delete(wmWidgetMap *wmap)
+{
+	MEM_SAFE_FREE(wmap->wmap_context.selected_widgets);
+	wmap->wmap_context.tot_selected = 0;
+}
+
 void WM_widgetmap_delete(wmWidgetMap *wmap)
 {
 	if (!wmap)
@@ -113,10 +119,8 @@ void WM_widgetmap_delete(wmWidgetMap *wmap)
 		wm_widgetgroup_free(NULL, wmap, wgroup);
 	}
 	BLI_assert(BLI_listbase_is_empty(&wmap->widgetgroups));
-	BLI_listbase_clear(&wmap->widgetgroups);
 
-	/* XXX shouldn't widgets in wmap_context.selected_widgets be freed here? */
-	MEM_SAFE_FREE(wmap->wmap_context.selected_widgets);
+	wm_widgetmap_selected_delete(wmap);
 
 	MEM_freeN(wmap);
 }
@@ -474,8 +478,7 @@ bool wm_widgetmap_deselect_all(wmWidgetMap *wmap, wmWidget ***sel)
 		(*sel)[i]->flag &= ~WM_WIDGET_SELECTED;
 		(*sel)[i] = NULL;
 	}
-	MEM_SAFE_FREE(*sel);
-	wmap->wmap_context.tot_selected = 0;
+	wm_widgetmap_selected_delete(wmap);
 
 	/* always return true, we already checked
 	 * if there's anything to deselect */
@@ -668,7 +671,7 @@ wmWidget *wm_widgetmap_get_highlighted_widget(wmWidgetMap *wmap)
 
 void wm_widgetmap_set_active_widget(wmWidgetMap *wmap, bContext *C, const wmEvent *event, wmWidget *widget)
 {
-	if (widget) {
+	if (widget && C) {
 		widget->flag |= WM_WIDGET_ACTIVE;
 		wmap->wmap_context.active_widget = widget;
 
@@ -720,8 +723,10 @@ void wm_widgetmap_set_active_widget(wmWidgetMap *wmap, bContext *C, const wmEven
 		}
 		wmap->wmap_context.active_widget = NULL;
 
-		ED_region_tag_redraw(CTX_wm_region(C));
-		WM_event_add_mousemove(C);
+		if (C) {
+			ED_region_tag_redraw(CTX_wm_region(C));
+			WM_event_add_mousemove(C);
+		}
 	}
 }
 
diff --git a/source/gameengine/Converter/BL_ArmatureObject.cpp b/source/gameengine/Converter/BL_ArmatureObject.cpp
index a1819a8..df732fb 100644
--- a/source/gameengine/Converter/BL_ArmatureObject.cpp
+++ b/source/gameengine/Converter/BL_ArmatureObject.cpp
@@ -129,6 +129,9 @@ static void game_copy_pose(bPose **dst, bPose *src, int copy_constraint)
 			BLI_listbase_clear(&pchan->constraints);
 		}
 
+		if (pchan->fmap_object) {
+			id_

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list