Skip to content

Commit 70de64b

Browse files
authored
Fixed exception when paste polygon with ctrl hold (cvat-ai#9367)
1 parent 1d5f0ab commit 70de64b

File tree

4 files changed

+11
-36
lines changed

4 files changed

+11
-36
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Fixed
2+
3+
- UI crashes when paste cuboids with hold Ctrl key
4+
(<https://github.com/cvat-ai/cvat/pull/9367>)

cvat-canvas/src/typescript/drawHandler.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1346,7 +1346,7 @@ export class DrawHandlerImpl implements DrawHandler {
13461346
});
13471347
}
13481348

1349-
if (this.drawInstance && (isFilalblePolygon)) {
1349+
if (this.drawInstance && isFilalblePolygon) {
13501350
const paintHandler = this.drawInstance.remember('_paintHandler');
13511351
if (paintHandler) {
13521352
for (const point of (paintHandler as any).set.members) {
@@ -1398,17 +1398,17 @@ export class DrawHandlerImpl implements DrawHandler {
13981398
}
13991399

14001400
if (this.drawInstance) {
1401-
this.drawInstance.draw('transform');
14021401
this.drawInstance.attr({
14031402
'stroke-width': consts.BASE_STROKE_WIDTH / geometry.scale,
14041403
});
14051404

14061405
const paintHandler = this.drawInstance.remember('_paintHandler');
1407-
1408-
for (const point of (paintHandler as any).set.members) {
1409-
this.strokePoint(point);
1410-
point.attr('stroke-width', `${consts.POINTS_STROKE_WIDTH / geometry.scale}`);
1411-
point.attr('r', `${this.controlPointsSize / geometry.scale}`);
1406+
if (paintHandler) {
1407+
for (const point of (paintHandler as any).set.members) {
1408+
this.strokePoint(point);
1409+
point.attr('stroke-width', `${consts.POINTS_STROKE_WIDTH / geometry.scale}`);
1410+
point.attr('r', `${this.controlPointsSize / geometry.scale}`);
1411+
}
14121412
}
14131413
}
14141414
}

cvat-canvas/src/typescript/editHandler.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,15 +463,13 @@ export class EditHandlerImpl implements EditHandler {
463463
}
464464

465465
if (this.editLine) {
466-
(this.editLine as any).draw('transform');
467466
if (this.editData.state.shapeType !== 'points') {
468467
this.editLine.attr({
469468
'stroke-width': consts.BASE_STROKE_WIDTH / geometry.scale,
470469
});
471470
}
472471

473472
const paintHandler = this.editLine.remember('_paintHandler');
474-
475473
for (const point of paintHandler.set.members) {
476474
point.attr('stroke-width', `${consts.POINTS_STROKE_WIDTH / geometry.scale}`);
477475
point.attr('r', `${this.controlPointsSize / geometry.scale}`);

cvat-canvas/src/typescript/svg.patch.ts

Lines changed: 0 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -59,33 +59,6 @@ SVG.Element.prototype.draw.extend(
5959
}),
6060
);
6161

62-
// Create transform for rect, polyline and polygon
63-
function transform(): void {
64-
this.m = this.el.node.getScreenCTM().inverse();
65-
this.offset = { x: window.pageXOffset, y: window.pageYOffset };
66-
}
67-
68-
SVG.Element.prototype.draw.extend(
69-
'rect',
70-
Object.assign({}, SVG.Element.prototype.draw.plugins.rect, {
71-
transform: transform,
72-
}),
73-
);
74-
75-
SVG.Element.prototype.draw.extend(
76-
'polyline',
77-
Object.assign({}, SVG.Element.prototype.draw.plugins.polyline, {
78-
transform: transform,
79-
}),
80-
);
81-
82-
SVG.Element.prototype.draw.extend(
83-
'polygon',
84-
Object.assign({}, SVG.Element.prototype.draw.plugins.polygon, {
85-
transform: transform,
86-
}),
87-
);
88-
8962
export const CIRCLE_STROKE = '#000';
9063
// Fix method drawCircles
9164
function drawCircles(): void {

0 commit comments

Comments
 (0)