gl renderer: Don't crash if the first op is an opacity one

This commit is contained in:
Timm Bäder 2017-12-19 16:00:43 +01:00
parent 490e15021c
commit f044b01549

View File

@ -236,11 +236,20 @@ ops_set_opacity (RenderOpBuilder *builder,
if (builder->current_opacity == opacity)
return opacity;
last_op = &g_array_index (builder->render_ops, RenderOp, builder->render_ops->len - 1);
if (last_op->op == OP_CHANGE_OPACITY)
if (builder->render_ops->len > 0)
{
last_op->opacity = opacity;
last_op = &g_array_index (builder->render_ops, RenderOp, builder->render_ops->len - 1);
if (last_op->op == OP_CHANGE_OPACITY)
{
last_op->opacity = opacity;
}
else
{
op.op = OP_CHANGE_OPACITY;
op.opacity = opacity;
g_array_append_val (builder->render_ops, op);
}
}
else
{