diff --git a/src/extensions/rcsb/validation-report/behavior.ts b/src/extensions/rcsb/validation-report/behavior.ts index 00b9d38fce2fb3be8dc3ea11441340be88c38aa6..cf1d189eacb130b9955908016fc8987283344e85 100644 --- a/src/extensions/rcsb/validation-report/behavior.ts +++ b/src/extensions/rcsb/validation-report/behavior.ts @@ -71,8 +71,7 @@ export const RCSBValidationReport = PluginBehavior.create<{ autoAttach: boolean, } unregister() { - // TODO - // DefaultQueryRuntimeTable.removeCustomProp(this.provider.descriptor); + DefaultQueryRuntimeTable.removeCustomProp(this.provider.descriptor); this.ctx.customStructureProperties.unregister(this.provider.descriptor.name); diff --git a/src/mol-plugin/behavior/dynamic/custom-props/computed/accessible-surface-area.ts b/src/mol-plugin/behavior/dynamic/custom-props/computed/accessible-surface-area.ts index 06bc52745878f8666464f6e914d00c5d1d5a0207..6d6be15f83c89ef48ecd885a375c037adbf9811a 100644 --- a/src/mol-plugin/behavior/dynamic/custom-props/computed/accessible-surface-area.ts +++ b/src/mol-plugin/behavior/dynamic/custom-props/computed/accessible-surface-area.ts @@ -51,8 +51,7 @@ export const AccessibleSurfaceArea = PluginBehavior.create<{ autoAttach: boolean } unregister() { - // TODO - // DefaultQueryRuntimeTable.removeCustomProp(this.provider.descriptor); + DefaultQueryRuntimeTable.removeCustomProp(this.provider.descriptor); this.ctx.customStructureProperties.unregister(this.provider.descriptor.name); this.ctx.representation.structure.themes.colorThemeRegistry.remove(AccessibleSurfaceAreaColorThemeProvider); diff --git a/src/mol-script/runtime/query/base.ts b/src/mol-script/runtime/query/base.ts index b9982624de919880b9ede41c136eebfd3381e329..dabc80ad3deb1efa464997beb2d6dc91ab8e8a92 100644 --- a/src/mol-script/runtime/query/base.ts +++ b/src/mol-script/runtime/query/base.ts @@ -11,9 +11,13 @@ import { MSymbol } from '../../language/symbol'; export class QueryRuntimeTable { private map = new Map<string, QuerySymbolRuntime>(); + removeSymbol(runtime: QuerySymbolRuntime) { + this.map.delete(runtime.symbol.id); + } + addSymbol(runtime: QuerySymbolRuntime) { if (this.map.has(runtime.symbol.id)) { - throw new Error(`Symbol '${runtime.symbol.id}' already added.`); + console.warn(`Symbol '${runtime.symbol.id}' already added. Call removeSymbol/removeCustomProps re-adding the symbol.`); } this.map.set(runtime.symbol.id, runtime); } @@ -26,6 +30,14 @@ export class QueryRuntimeTable { } } + removeCustomProp(desc: CustomPropertyDescriptor<any>) { + if (!desc.symbols) return; + + for (const k of Object.keys(desc.symbols)) { + this.removeSymbol((desc.symbols as any)[k]); + } + } + getRuntime(id: string) { return this.map.get(id); }