Follow-up to r60433 (related to Bug #36878): additional checks for NULL line styles.

This commit is contained in:
Tamito Kajiyama 2013-09-30 23:02:29 +00:00
parent e28bd0d302
commit aaba317c76
4 changed files with 39 additions and 4 deletions

@ -530,6 +530,8 @@ class RENDERLAYER_PT_freestyle_linestyle(RenderLayerFreestyleEditorButtonsPanel,
linestyle = lineset.linestyle
layout.template_ID(lineset, "linestyle", new="scene.freestyle_linestyle_new")
if linestyle is None:
return
row = layout.row(align=True)
row.prop(linestyle, "panel", expand=True)
if linestyle.panel == 'STROKES':

@ -107,7 +107,7 @@ void BKE_freestyle_config_copy(FreestyleConfig *new_config, FreestyleConfig *con
static void copy_lineset(FreestyleLineSet *new_lineset, FreestyleLineSet *lineset)
{
new_lineset->linestyle = lineset->linestyle;
if (lineset->linestyle)
if (new_lineset->linestyle)
new_lineset->linestyle->id.us++;
new_lineset->flags = lineset->flags;
new_lineset->selection = lineset->selection;

@ -860,8 +860,12 @@ static int freestyle_linestyle_new_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active lineset to add a new line style to");
return OPERATOR_CANCELLED;
}
lineset->linestyle->id.us--;
lineset->linestyle = BKE_copy_linestyle(lineset->linestyle);
if (lineset->linestyle) {
lineset->linestyle->id.us--;
lineset->linestyle = BKE_copy_linestyle(lineset->linestyle);
} else {
lineset->linestyle = BKE_new_linestyle("LineStyle", NULL);
}
WM_event_add_notifier(C, NC_SCENE | ND_RENDER_OPTIONS, scene);
@ -894,6 +898,10 @@ static int freestyle_color_modifier_add_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to");
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;
@ -933,6 +941,10 @@ static int freestyle_alpha_modifier_add_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to");
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;
@ -972,6 +984,10 @@ static int freestyle_thickness_modifier_add_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to");
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;
@ -1011,6 +1027,10 @@ static int freestyle_geometry_modifier_add_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style to add the modifier to");
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;
@ -1064,6 +1084,10 @@ static int freestyle_modifier_remove_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to");
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:
@ -1114,6 +1138,10 @@ static int freestyle_modifier_copy_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to");
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:
@ -1165,6 +1193,10 @@ static int freestyle_modifier_move_exec(bContext *C, wmOperator *op)
BKE_report(op->reports, RPT_ERROR, "No active lineset and associated line style the modifier belongs to");
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:

@ -1541,7 +1541,8 @@ static void rna_FreestyleLineSet_linestyle_set(PointerRNA *ptr, PointerRNA value
{
FreestyleLineSet *lineset = (FreestyleLineSet *)ptr->data;
lineset->linestyle->id.us--;
if (lineset->linestyle)
lineset->linestyle->id.us--;
lineset->linestyle = (FreestyleLineStyle *)value.data;
lineset->linestyle->id.us++;
}