[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60462] trunk/blender/source/blender/ editors/render/render_shading.c: de-duplicate report strings for freestyle error checks
Campbell Barton
ideasman42 at gmail.com
Tue Oct 1 04:51:40 CEST 2013
Revision: 60462
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60462
Author: campbellbarton
Date: 2013-10-01 02:51:39 +0000 (Tue, 01 Oct 2013)
Log Message:
-----------
de-duplicate report strings for freestyle error checks
Modified Paths:
--------------
trunk/blender/source/blender/editors/render/render_shading.c
Modified: trunk/blender/source/blender/editors/render/render_shading.c
===================================================================
--- trunk/blender/source/blender/editors/render/render_shading.c 2013-09-30 23:48:31 UTC (rev 60461)
+++ trunk/blender/source/blender/editors/render/render_shading.c 2013-10-01 02:51:39 UTC (rev 60462)
@@ -588,6 +588,20 @@
#ifdef WITH_FREESTYLE
+static bool freestyle_linestyle_check_report(FreestyleLineSet *lineset, ReportList *reports)
+{
+ if (!lineset) {
+ BKE_report(reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to");
+ return false;
+ }
+ if (!lineset->linestyle) {
+ BKE_report(reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)");
+ return false;
+ }
+
+ return true;
+}
+
static int freestyle_active_module_poll(bContext *C)
{
PointerRNA ptr = CTX_data_pointer_get_type(C, "freestyle_module", &RNA_FreestyleModuleSettings);
@@ -894,14 +908,10 @@
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig);
int type = RNA_enum_get(op->ptr, "type");
- if (!lineset) {
- BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to");
+ if (!freestyle_linestyle_check_report(lineset, op->reports)) {
return OPERATOR_CANCELLED;
}
- if (!lineset->linestyle) {
- BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)");
- return OPERATOR_CANCELLED;
- }
+
if (BKE_add_linestyle_color_modifier(lineset->linestyle, type) == NULL) {
BKE_report(op->reports, RPT_ERROR, "Unknown line color modifier type");
return OPERATOR_CANCELLED;
@@ -937,14 +947,10 @@
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig);
int type = RNA_enum_get(op->ptr, "type");
- if (!lineset) {
- BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to");
+ if (!freestyle_linestyle_check_report(lineset, op->reports)) {
return OPERATOR_CANCELLED;
}
- if (!lineset->linestyle) {
- BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)");
- return OPERATOR_CANCELLED;
- }
+
if (BKE_add_linestyle_alpha_modifier(lineset->linestyle, type) == NULL) {
BKE_report(op->reports, RPT_ERROR, "Unknown alpha transparency modifier type");
return OPERATOR_CANCELLED;
@@ -980,14 +986,10 @@
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig);
int type = RNA_enum_get(op->ptr, "type");
- if (!lineset) {
- BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to");
+ if (!freestyle_linestyle_check_report(lineset, op->reports)) {
return OPERATOR_CANCELLED;
}
- if (!lineset->linestyle) {
- BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)");
- return OPERATOR_CANCELLED;
- }
+
if (BKE_add_linestyle_thickness_modifier(lineset->linestyle, type) == NULL) {
BKE_report(op->reports, RPT_ERROR, "Unknown line thickness modifier type");
return OPERATOR_CANCELLED;
@@ -1023,14 +1025,10 @@
FreestyleLineSet *lineset = BKE_freestyle_lineset_get_active(&srl->freestyleConfig);
int type = RNA_enum_get(op->ptr, "type");
- if (!lineset) {
- BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to");
+ if (!freestyle_linestyle_check_report(lineset, op->reports)) {
return OPERATOR_CANCELLED;
}
- if (!lineset->linestyle) {
- BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)");
- return OPERATOR_CANCELLED;
- }
+
if (BKE_add_linestyle_geometry_modifier(lineset->linestyle, type) == NULL) {
BKE_report(op->reports, RPT_ERROR, "Unknown stroke geometry modifier type");
return OPERATOR_CANCELLED;
@@ -1080,14 +1078,9 @@
PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier);
LineStyleModifier *modifier = ptr.data;
- if (!lineset) {
- BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to");
+ if (!freestyle_linestyle_check_report(lineset, op->reports)) {
return OPERATOR_CANCELLED;
}
- if (!lineset->linestyle) {
- BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)");
- return OPERATOR_CANCELLED;
- }
switch (freestyle_get_modifier_type(&ptr)) {
case LS_MODIFIER_TYPE_COLOR:
@@ -1134,14 +1127,9 @@
PointerRNA ptr = CTX_data_pointer_get_type(C, "modifier", &RNA_LineStyleModifier);
LineStyleModifier *modifier = ptr.data;
- if (!lineset) {
- BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to");
+ if (!freestyle_linestyle_check_report(lineset, op->reports)) {
return OPERATOR_CANCELLED;
}
- if (!lineset->linestyle) {
- BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)");
- return OPERATOR_CANCELLED;
- }
switch (freestyle_get_modifier_type(&ptr)) {
case LS_MODIFIER_TYPE_COLOR:
@@ -1189,14 +1177,9 @@
LineStyleModifier *modifier = ptr.data;
int dir = RNA_enum_get(op->ptr, "direction");
- if (!lineset) {
- BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to");
+ if (!freestyle_linestyle_check_report(lineset, op->reports)) {
return OPERATOR_CANCELLED;
}
- if (!lineset->linestyle) {
- BKE_report(op->reports, RPT_ERROR, "The active lineset does not have a line style (indicating data corruption)");
- return OPERATOR_CANCELLED;
- }
switch (freestyle_get_modifier_type(&ptr)) {
case LS_MODIFIER_TYPE_COLOR:
More information about the Bf-blender-cvs
mailing list