Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed exception 'this.el.node.getScreenCTM() is null' when cancel drawing shape for any tracker #8080

Merged
merged 2 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog.d/20240625_125241_boris.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
### Fixed

- Exception 'this.el.node.getScreenCTM() is null' when cancel drawing shape for any tracker
(<https://github.com/cvat-ai/cvat/pull/8080>)
43 changes: 31 additions & 12 deletions cvat-canvas/src/typescript/interactionHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export class InteractionHandlerImpl implements InteractionHandler {
private thresholdWasModified: boolean;
private controlPointsSize: number;
private selectedShapeOpacity: number;
private cancelled: boolean;

private prepareResult(): InteractionResult[] {
return this.interactionShapes.map(
Expand Down Expand Up @@ -193,6 +194,10 @@ export class InteractionHandlerImpl implements InteractionHandler {
this.canvas.on('mousedown.interaction', eventListener);
this.currentInteractionShape
.on('drawstop', (): void => {
if (this.cancelled) {
return;
}

this.canvas.off('mousedown.interaction', eventListener);
this.interactionShapes.push(this.currentInteractionShape);
this.shapesWereUpdated = true;
Expand Down Expand Up @@ -239,6 +244,11 @@ export class InteractionHandlerImpl implements InteractionHandler {
}

private release(): void {
if (this.currentInteractionShape && this.currentInteractionShape.remember('_paintHandler')) {
// Cancel active drawing first
(this.currentInteractionShape as any).draw('cancel');
}

if (this.drawnIntermediateShape) {
this.selectize(false, this.drawnIntermediateShape);
this.drawnIntermediateShape.remove();
Expand Down Expand Up @@ -529,20 +539,28 @@ export class InteractionHandlerImpl implements InteractionHandler {
}

public interact(interactionData: InteractionData): void {
if (interactionData.intermediateShape) {
this.intermediateShape = interactionData.intermediateShape;
this.updateIntermediateShape();
if (this.interactionData.startWithBox) {
this.interactionShapes[0].style({ visibility: 'hidden' });
if (interactionData.enabled) {
this.cancelled = false;
if (interactionData.intermediateShape) {
this.intermediateShape = interactionData.intermediateShape;
this.updateIntermediateShape();
if (this.interactionData.startWithBox) {
this.interactionShapes[0].style({ visibility: 'hidden' });
}
} else if (this.visualComponentsChanged(interactionData)) {
this.interactionData = { ...this.interactionData, ...interactionData };
this.initInteraction();
} else if (interactionData.enabled) {
this.interactionData = interactionData;
this.initInteraction();
this.startInteraction();
}
} else if (interactionData.enabled && this.visualComponentsChanged(interactionData)) {
this.interactionData = { ...this.interactionData, ...interactionData };
this.initInteraction();
} else if (interactionData.enabled) {
this.interactionData = interactionData;
this.initInteraction();
this.startInteraction();
} else {
if (this.currentInteractionShape && this.currentInteractionShape.remember('_paintHandler')) {
// Finish active drawing first if possible
(this.currentInteractionShape as any).draw('stop');
}

this.onInteraction(this.prepareResult(), this.shouldRaiseEvent(false), true);
this.release();
this.interactionData = interactionData;
Expand Down Expand Up @@ -571,6 +589,7 @@ export class InteractionHandlerImpl implements InteractionHandler {
}

public cancel(): void {
this.cancelled = true;
this.release();
this.onInteraction(null);
}
Expand Down
Loading