Freestyle: Fix for error handling in SCENE_OT_freestyle_stroke_material_create.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user