Avoid crashing on "scale(1)" (short for "scale(1, 1)")

The scale function on the transform attribute has a short form, where
only the first argument is used.  But optimizeTransform would always
assume that there were two when checking for the identity scale.

Closes: #190
Signed-off-by: Niels Thykier <niels@thykier.net>
This commit is contained in:
Niels Thykier 2018-04-18 05:40:59 +00:00
parent 8ddb7d8913
commit 18e57cddae
3 changed files with 19 additions and 1 deletions

View file

@ -2966,7 +2966,9 @@ def optimizeTransform(transform):
# y1 * uniformscalefactor2
prevArgs[1] *= currArgs[0]
del transform[i]
if prevArgs[0] == prevArgs[1] == 1:
# if prevArgs is [1] or [1, 1], then it is effectively an
# identity matrix and can be removed.
if prevArgs[0] == 1 and (len(prevArgs) == 1 or prevArgs[1] == 1):
# Identity scale!
i -= 1
del transform[i]