Fix item global matrix error ()

Bug happen when item is drawn after an empty symbol that should be drawn
in a separate canvas context (partial opacity or special blend mode).
As bounds are empty, symbol drawing process is interrupted but its
global matrix is not removed from the stack.
Closes 
This commit is contained in:
Samuel Asensi 2018-10-13 14:41:38 +02:00 committed by Jürg Lehni
parent 5245436e36
commit 5cd1ca13c5
2 changed files with 14 additions and 1 deletions
src/item
test/tests

View file

@ -4327,8 +4327,12 @@ new function() { // Injection scope for hit-test functions shared with project
// Apply the parent's global matrix to the calculation of correct
// bounds.
var bounds = this.getStrokeBounds(viewMatrix);
if (!bounds.width || !bounds.height)
if (!bounds.width || !bounds.height) {
// Item won't be drawn so its global matrix need to be removed
// from the stack (#1561).
matrices.pop();
return;
}
// Store previous offset and save the main context, so we can
// draw onto it later.
prevOffset = param.offset;

View file

@ -789,3 +789,12 @@ test('group.internalBounds with child and child.applyMatrix = false (#1250)', fu
equals(group.internalBounds, new Rectangle(0, 0, 250, 250),
'group.internalBounds after scaling item1');
});
test('#1561 item._globalMatrix on item after empty symbol', function(){
var symbol = new SymbolItem(new Path());
symbol.opacity = 0.5;
symbol.skew(10);
var item = new Path.Circle(new Point(0,0), 10);
view.update();
equals(item._globalMatrix, new Matrix());
});