Skip to content
Snippets Groups Projects
Commit 26e6e0ab authored by David Sehnal's avatar David Sehnal
Browse files

Task cancellation fix

parent 2a74d5eb
No related branches found
No related tags found
No related merge requests found
...@@ -11,7 +11,7 @@ import { CustomPropertyRegistry } from '../mol-model-props/common/custom-propert ...@@ -11,7 +11,7 @@ import { CustomPropertyRegistry } from '../mol-model-props/common/custom-propert
import { StructureRepresentationRegistry } from '../mol-repr/structure/registry'; import { StructureRepresentationRegistry } from '../mol-repr/structure/registry';
import { VolumeRepresentationRegistry } from '../mol-repr/volume/registry'; import { VolumeRepresentationRegistry } from '../mol-repr/volume/registry';
import { State, StateTransform, StateTransformer } from '../mol-state'; import { State, StateTransform, StateTransformer } from '../mol-state';
import { Task } from '../mol-task'; import { Task, Progress } from '../mol-task';
import { ColorTheme } from '../mol-theme/color'; import { ColorTheme } from '../mol-theme/color';
import { SizeTheme } from '../mol-theme/size'; import { SizeTheme } from '../mol-theme/size';
import { ThemeRegistryContext } from '../mol-theme/theme'; import { ThemeRegistryContext } from '../mol-theme/theme';
...@@ -176,8 +176,8 @@ export class PluginContext { ...@@ -176,8 +176,8 @@ export class PluginContext {
return this.tasks.run(task); return this.tasks.run(task);
} }
requestTaskAbort(task: Task<any> | number, reason?: string) { requestTaskAbort(progress: Progress, reason?: string) {
this.tasks.requestAbort(task, reason); this.tasks.requestAbort(progress, reason);
} }
dispose() { dispose() {
......
...@@ -34,7 +34,7 @@ export class BackgroundTaskProgress extends PluginUIComponent<{ }, { tracked: Or ...@@ -34,7 +34,7 @@ export class BackgroundTaskProgress extends PluginUIComponent<{ }, { tracked: Or
class ProgressEntry extends PluginUIComponent<{ event: TaskManager.ProgressEvent }> { class ProgressEntry extends PluginUIComponent<{ event: TaskManager.ProgressEvent }> {
abort = () => { abort = () => {
this.plugin.requestTaskAbort(this.props.event.id, 'User Request'); this.plugin.requestTaskAbort(this.props.event.progress, 'User Request');
} }
render() { render() {
......
...@@ -22,7 +22,7 @@ class TaskManager { ...@@ -22,7 +22,7 @@ class TaskManager {
private track(internalId: number, taskId: number) { private track(internalId: number, taskId: number) {
return (progress: Progress) => { return (progress: Progress) => {
if (progress.canAbort && progress.requestAbort && this.abortRequests.has(taskId)) { if (progress.canAbort && progress.requestAbort && this.abortRequests.has(progress.root.progress.taskId)) {
progress.requestAbort(this.abortRequests.get(taskId)); progress.requestAbort(this.abortRequests.get(taskId));
} }
const elapsed = now() - progress.root.progress.startedTime; const elapsed = now() - progress.root.progress.startedTime;
...@@ -45,8 +45,8 @@ class TaskManager { ...@@ -45,8 +45,8 @@ class TaskManager {
} }
} }
requestAbort(task: Task<any> | number, reason?: string) { requestAbort(progress: Progress, reason?: string) {
this.abortRequests.set(typeof task === 'number' ? task : task.id, reason); this.abortRequests.set(progress.root.progress.taskId, reason);
} }
dispose() { dispose() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment