提交 086228e3 编写于 作者: J Joao Moreno

🐛 disposing reference should never happen twice

上级 da3dae82
......@@ -2,8 +2,11 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { once } from 'vs/base/common/functional';
export const empty: IDisposable = Object.freeze({
dispose() { }
});
......@@ -109,12 +112,12 @@ export abstract class ReferenceCollection<T> {
}
const { object } = reference;
const dispose = () => {
const dispose = once(() => {
if (--reference.counter === 0) {
this.destroyReferencedObject(reference.object);
delete this.references[key];
}
};
});
reference.counter++;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册