Fixed memory references which keep unneeded objects in memory
This commit is contained in:
parent
69287ebbd1
commit
f81bab0775
4 changed files with 26 additions and 10 deletions
|
@ -993,7 +993,14 @@ export class ConnectionHandler {
|
|||
this.pluginCmdRegistry?.destroy();
|
||||
this.pluginCmdRegistry = undefined;
|
||||
|
||||
this._local_client?.destroy();
|
||||
if(this._local_client) {
|
||||
const voiceHandle = this._local_client.getVoiceClient();
|
||||
if(voiceHandle) {
|
||||
this._local_client.setVoiceClient(undefined);
|
||||
this.serverConnection.getVoiceConnection().unregisterVoiceClient(voiceHandle);
|
||||
}
|
||||
this._local_client.destroy();
|
||||
}
|
||||
this._local_client = undefined;
|
||||
|
||||
this.channelTree?.destroy();
|
||||
|
|
|
@ -226,10 +226,8 @@ export class ClientEntry extends ChannelTreeEntry<ClientEvents> {
|
|||
|
||||
destroy() {
|
||||
if(this.voiceHandle) {
|
||||
log.warn(LogCategory.AUDIO, tr("Destroying client with an active audio handle. This could cause memory leaks!"));
|
||||
/* TODO: Unregister all voice events? */
|
||||
this.voiceHandle.abortReplay();
|
||||
this.voiceHandle = undefined;
|
||||
log.error(LogCategory.AUDIO, tr("Destroying client with an active audio handle. This could cause memory leaks!"));
|
||||
this.setVoiceClient(undefined);
|
||||
}
|
||||
|
||||
this._channel = undefined;
|
||||
|
|
|
@ -20,21 +20,30 @@ import {spawnFileTransferModal} from "tc-shared/ui/modal/transfer/ModalFileTrans
|
|||
import {GroupManager, GroupManagerEvents} from "tc-shared/permission/GroupManager";
|
||||
import {ServerEntry} from "tc-shared/tree/Server";
|
||||
import {spawnChannelTreePopout} from "tc-shared/ui/tree/popout/Controller";
|
||||
import {server_connections} from "tc-shared/ConnectionManager";
|
||||
|
||||
export function renderChannelTree(channelTree: ChannelTree, target: HTMLElement) {
|
||||
const events = new Registry<ChannelTreeUIEvents>();
|
||||
events.enableDebug("channel-tree-view");
|
||||
initializeChannelTreeController(events, channelTree);
|
||||
|
||||
ReactDOM.render(
|
||||
<ChannelTreeRenderer handlerId={channelTree.client.handlerId} events={events} />
|
||||
, target);
|
||||
ReactDOM.render(<ChannelTreeRenderer handlerId={channelTree.client.handlerId} events={events} />, target);
|
||||
|
||||
let handlerDestroyListener;
|
||||
server_connections.events().on("notify_handler_deleted", handlerDestroyListener = event => {
|
||||
if(event.handler !== channelTree.client) {
|
||||
return;
|
||||
}
|
||||
|
||||
ReactDOM.unmountComponentAtNode(target);
|
||||
server_connections.events().off("notify_handler_deleted", handlerDestroyListener);
|
||||
events.fire("notify_destroy");
|
||||
events.destroy();
|
||||
});
|
||||
|
||||
/*
|
||||
(window as any).chan_pop = () => {
|
||||
spawnChannelTreePopout(channelTree.client);
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
/* FIXME: Client move is not a part of the channel tree, it's part of our own controller here */
|
||||
|
|
|
@ -15,6 +15,8 @@ export class AudioClient {
|
|||
async initialize() { }
|
||||
|
||||
destroy() {
|
||||
this.callback_ended = undefined;
|
||||
this.callback_decoded = undefined;
|
||||
this.handle.destroyClient(this.clientId);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue