mirror of
https://github.com/nasa/openmct.git
synced 2025-02-21 01:42:31 +00:00
[ObjectAPI] Cleanup code and remove possible memory leak (#6269)
* Destroy mutable after refresh * Check if domainObject supports mutation before getting mutable
This commit is contained in:
parent
3c36ba9a71
commit
b57974b462
@ -225,24 +225,21 @@ export default class ObjectAPI {
|
||||
throw new Error('Provider does not support get!');
|
||||
}
|
||||
|
||||
let objectPromise = provider.get(identifier, abortSignal).then(result => {
|
||||
let objectPromise = provider.get(identifier, abortSignal).then(domainObject => {
|
||||
delete this.cache[keystring];
|
||||
domainObject = this.applyGetInterceptors(identifier, domainObject);
|
||||
|
||||
result = this.applyGetInterceptors(identifier, result);
|
||||
if (result.isMutable) {
|
||||
result.$refresh(result);
|
||||
} else {
|
||||
let mutableDomainObject = this.toMutable(result);
|
||||
mutableDomainObject.$refresh(result);
|
||||
if (this.supportsMutation(identifier)) {
|
||||
const mutableDomainObject = this.toMutable(domainObject);
|
||||
mutableDomainObject.$refresh(domainObject);
|
||||
this.destroyMutable(mutableDomainObject);
|
||||
}
|
||||
|
||||
return result;
|
||||
}).catch((result) => {
|
||||
console.warn(`Failed to retrieve ${keystring}:`, result);
|
||||
|
||||
return domainObject;
|
||||
}).catch((error) => {
|
||||
console.warn(`Failed to retrieve ${keystring}:`, error);
|
||||
delete this.cache[keystring];
|
||||
|
||||
result = this.applyGetInterceptors(identifier);
|
||||
const result = this.applyGetInterceptors(identifier);
|
||||
|
||||
return result;
|
||||
});
|
||||
|
Loading…
x
Reference in New Issue
Block a user