[Bf-blender-cvs] [2843aa1] master: Freestyle: Fix for error handling in SCENE_OT_freestyle_stroke_material_create.

Tamito Kajiyama noreply at git.blender.org
Tue Aug 12 03:18:17 CEST 2014


Commit: 2843aa1501c5aabebe1701c88cd30b501e6b4aa5
Author: Tamito Kajiyama
Date:   Sun Jul 20 20:09:46 2014 +0900
Branches: master
https://developer.blender.org/rB2843aa1501c5aabebe1701c88cd30b501e6b4aa5

Freestyle: Fix for error handling in SCENE_OT_freestyle_stroke_material_create.

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

M	source/blender/editors/render/render_shading.c
M	source/blender/freestyle/FRS_freestyle.h
M	source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp

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

diff --git a/source/blender/editors/render/render_shading.c b/source/blender/editors/render/render_shading.c
index 021e4aa..5c3bd8f 100644
--- a/source/blender/editors/render/render_shading.c
+++ b/source/blender/editors/render/render_shading.c
@@ -1254,8 +1254,14 @@ static int freestyle_stroke_material_create_exec(bContext *C, wmOperator *op)
 {
 	Main *bmain = CTX_data_main(C);
 	Scene *scene = CTX_data_scene(C);
+	FreestyleLineStyle *linestyle = BKE_linestyle_active_from_scene(scene);
 
-	FRS_create_stroke_material(C, bmain, scene);
+	if (!linestyle) {
+		BKE_report(op->reports, RPT_ERROR, "No active line style in the current scene");
+		return OPERATOR_CANCELLED;
+	}
+
+	FRS_create_stroke_material(C, bmain, linestyle);
 
 	return OPERATOR_FINISHED;
 }
diff --git a/source/blender/freestyle/FRS_freestyle.h b/source/blender/freestyle/FRS_freestyle.h
index c3bf854..3777f8d 100644
--- a/source/blender/freestyle/FRS_freestyle.h
+++ b/source/blender/freestyle/FRS_freestyle.h
@@ -32,6 +32,7 @@ extern "C" {
 struct Render;
 struct Material;
 struct FreestyleConfig;
+struct FreestyleLineStyle;
 struct bContext;
 
 extern struct Scene *freestyle_scene;
@@ -59,7 +60,7 @@ void FRS_move_active_lineset_up(struct FreestyleConfig *config);
 void FRS_move_active_lineset_down(struct FreestyleConfig *config);
 
 /* Testing */
-struct Material *FRS_create_stroke_material(struct bContext *C, struct Main *bmain, struct Scene *scene);
+struct Material *FRS_create_stroke_material(struct bContext *C, struct Main *bmain, struct FreestyleLineStyle *linestyle);
 
 #ifdef __cplusplus
 }
diff --git a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
index 1c8df35..bba4f58 100644
--- a/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
+++ b/source/blender/freestyle/intern/blender_interface/FRS_freestyle.cpp
@@ -735,16 +735,9 @@ void FRS_move_active_lineset_down(FreestyleConfig *config)
 
 // Testing
 
-Material *FRS_create_stroke_material(bContext *C, Main *bmain, Scene *scene)
+Material *FRS_create_stroke_material(bContext *C, Main *bmain, struct FreestyleLineStyle *linestyle)
 {
-	FreestyleLineStyle *linestyle = BKE_linestyle_active_from_scene(scene);
-	Material *ma;
-
-	if (!linestyle) {
-		cout << "FRS_create_stroke_material: No active line style in the current scene" << endl;
-		return NULL;
-	}
-	ma = BlenderStrokeRenderer::GetStrokeShader(C, bmain, linestyle->nodetree, true);
+	Material *ma = BlenderStrokeRenderer::GetStrokeShader(C, bmain, linestyle->nodetree, true);
 	ma->id.us = 0;
 	return ma;
 }




More information about the Bf-blender-cvs mailing list