[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [39179] branches/soc-2011-tomato: Merging r39173 through r39178 from trunk into soc-2011-tomato

Sergey Sharybin g.ulairi at gmail.com
Mon Aug 8 14:11:40 CEST 2011


Revision: 39179
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39179
Author:   nazgul
Date:     2011-08-08 12:11:40 +0000 (Mon, 08 Aug 2011)
Log Message:
-----------
Merging r39173 through r39178 from trunk into soc-2011-tomato

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39173
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=39178

Modified Paths:
--------------
    branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_userpref_keymap.py
    branches/soc-2011-tomato/source/blender/editors/include/ED_object.h
    branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c
    branches/soc-2011-tomato/source/blender/editors/object/object_relations.c
    branches/soc-2011-tomato/source/blender/makesrna/RNA_access.h

Property Changed:
----------------
    branches/soc-2011-tomato/


Property changes on: branches/soc-2011-tomato
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/blender:36831-39172
   + /trunk/blender:36831-39178

Modified: branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_userpref_keymap.py
===================================================================
--- branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_userpref_keymap.py	2011-08-08 11:09:56 UTC (rev 39178)
+++ branches/soc-2011-tomato/release/scripts/startup/bl_ui/space_userpref_keymap.py	2011-08-08 12:11:40 UTC (rev 39179)
@@ -545,22 +545,24 @@
     def execute(self, context):
         from os.path import basename
         import shutil
+
         if not self.filepath:
-            raise Exception("Filepath not set")
+            self.report({'ERROR'}, "Filepath not set")
+            return {'CANCELLED'}
 
-        f = open(self.filepath, "r")
-        if not f:
-            raise Exception("Could not open file")
-
         config_name = basename(self.filepath)
 
         path = bpy.utils.user_resource('SCRIPTS', os.path.join("presets", "keyconfig"), create=True)
         path = os.path.join(path, config_name)
 
-        if self.keep_original:
-            shutil.copy(self.filepath, path)
-        else:
-            shutil.move(self.filepath, path)
+        try:
+            if self.keep_original:
+                shutil.copy(self.filepath, path)
+            else:
+                shutil.move(self.filepath, path)
+        except Exception as e:
+            self.report({'ERROR'}, "Installing keymap failed: %s" % e)
+            return {'CANCELLED'}
 
         # sneaky way to check we're actually running the code.
         bpy.utils.keyconfig_set(path)

Modified: branches/soc-2011-tomato/source/blender/editors/include/ED_object.h
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/include/ED_object.h	2011-08-08 11:09:56 UTC (rev 39178)
+++ branches/soc-2011-tomato/source/blender/editors/include/ED_object.h	2011-08-08 12:11:40 UTC (rev 39179)
@@ -108,8 +108,8 @@
 struct Object *ED_object_add_type(struct bContext *C, int type, float *loc, float *rot, int enter_editmode, unsigned int layer);
 
 void ED_object_single_users(struct Main *bmain, struct Scene *scene, int full);
+void ED_object_single_user(struct Scene *scene, struct Object *ob);
 
-
 /* object motion paths */
 void ED_objects_clear_paths(struct bContext *C);
 void ED_objects_recalculate_paths(struct bContext *C, struct Scene *scene);

Modified: branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c	2011-08-08 11:09:56 UTC (rev 39178)
+++ branches/soc-2011-tomato/source/blender/editors/interface/interface_templates.c	2011-08-08 12:11:40 UTC (rev 39179)
@@ -53,6 +53,7 @@
 #include "BKE_displist.h"
 
 #include "ED_screen.h"
+#include "ED_object.h"
 #include "ED_render.h"
 
 #include "RNA_access.h"
@@ -275,18 +276,28 @@
 			break;
 		case UI_ID_ALONE:
 			if(id) {
+				const int do_scene_obj= (GS(id->name) == ID_OB) &&
+				                        (template->ptr.type == &RNA_SceneObjects);
+
 				/* make copy */
-				if(id_copy(id, &newid, 0) && newid) {
-					/* copy animation actions too */
-					BKE_copy_animdata_id_action(id);
-					/* us is 1 by convention, but RNA_property_pointer_set
-					   will also incremement it, so set it to zero */
-					newid->us= 0;
+				if(do_scene_obj) {
+					Scene *scene= CTX_data_scene(C);
+					ED_object_single_user(scene, (struct Object *)id);
+					WM_event_add_notifier(C, NC_SCENE|ND_OB_ACTIVE, scene);
+				}
+				else {
+					if(id_copy(id, &newid, 0) && newid) {
+						/* copy animation actions too */
+						BKE_copy_animdata_id_action(id);
+						/* us is 1 by convention, but RNA_property_pointer_set
+						   will also incremement it, so set it to zero */
+						newid->us= 0;
 
-					/* assign copy */
-					RNA_id_pointer_create(newid, &idptr);
-					RNA_property_pointer_set(&template->ptr, template->prop, idptr);
-					RNA_property_update(C, &template->ptr, template->prop);
+						/* assign copy */
+						RNA_id_pointer_create(newid, &idptr);
+						RNA_property_pointer_set(&template->ptr, template->prop, idptr);
+						RNA_property_update(C, &template->ptr, template->prop);
+					}
 				}
 			}
 			break;
@@ -404,10 +415,7 @@
 
 			sprintf(str, "%d", id->us);
 
-			if(id->us<10)
-				but= uiDefBut(block, BUT, 0, str, 0,0,UI_UNIT_X,UI_UNIT_Y, NULL, 0, 0, 0, 0, "Displays number of users of this data. Click to make a single-user copy.");
-			else
-				but= uiDefBut(block, BUT, 0, str, 0,0,UI_UNIT_X+10,UI_UNIT_Y, NULL, 0, 0, 0, 0, "Displays number of users of this data. Click to make a single-user copy.");
+			but= uiDefBut(block, BUT, 0, str, 0,0,UI_UNIT_X + ((id->us < 10) ? 0:10), UI_UNIT_Y, NULL, 0, 0, 0, 0, "Displays number of users of this data. Click to make a single-user copy.");
 
 			uiButSetNFunc(but, template_id_cb, MEM_dupallocN(template), SET_INT_IN_POINTER(UI_ID_ALONE));
 			if(!id_copy(id, NULL, 1 /* test only */) || (idfrom && idfrom->lib) || !editable)

Modified: branches/soc-2011-tomato/source/blender/editors/object/object_relations.c
===================================================================
--- branches/soc-2011-tomato/source/blender/editors/object/object_relations.c	2011-08-08 11:09:56 UTC (rev 39178)
+++ branches/soc-2011-tomato/source/blender/editors/object/object_relations.c	2011-08-08 12:11:40 UTC (rev 39179)
@@ -1402,6 +1402,20 @@
 	set_sca_new_poins();
 }
 
+/* not an especially efficient function, only added so the single user
+ * button can be functional.*/
+void ED_object_single_user(Scene *scene, Object *ob)
+{
+	Base *base;
+
+	for(base= FIRSTBASE; base; base= base->next) {
+		if(base->object == ob)  base->flag |=  OB_DONE;
+		else					base->flag &= ~OB_DONE;
+	}
+
+	single_object_users(scene, NULL, OB_DONE);
+}
+
 static void new_id_matar(Material **matar, int totcol)
 {
 	ID *id;

Modified: branches/soc-2011-tomato/source/blender/makesrna/RNA_access.h
===================================================================
--- branches/soc-2011-tomato/source/blender/makesrna/RNA_access.h	2011-08-08 11:09:56 UTC (rev 39178)
+++ branches/soc-2011-tomato/source/blender/makesrna/RNA_access.h	2011-08-08 12:11:40 UTC (rev 39179)
@@ -392,6 +392,7 @@
 extern StructRNA RNA_SceneGameData;
 extern StructRNA RNA_SceneRenderLayer;
 extern StructRNA RNA_SceneSequence;
+extern StructRNA RNA_SceneObjects;
 extern StructRNA RNA_Scopes;
 extern StructRNA RNA_Screen;
 extern StructRNA RNA_ScrewModifier;




More information about the Bf-blender-cvs mailing list