Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bug] plugin-minimap dispose处理不干净,导致报错 #3943

Closed
cyrilluce opened this issue Sep 27, 2023 · 2 comments · Fixed by #3950
Closed

[bug] plugin-minimap dispose处理不干净,导致报错 #3943

cyrilluce opened this issue Sep 27, 2023 · 2 comments · Fixed by #3950

Comments

@cyrilluce
Copy link
Contributor

Describe the bug

minimap当前的清理逻辑为

  protected onRemove() {
    this.stopListening()
    this.targetGraph.model = new Model() // <----- 这里
    this.targetGraph.dispose()
  }

原本的意图应该是防止graph.dispose时自动clearCells,导致model被清空。

但现在这个写法会导致 graph.renderer.sheduler dispose 时,未能正确清理UI渲染相关的监听器,从而导致报错

此问题仅在minimap单独销毁时出现(例如动态开关/切换minimap)

Your Example Website or App

Steps to Reproduce the Bug or Issue

Expected behavior

不应该有报错

Screenshots or Videos

可以看到经过反复注册销毁,graph.model上绑定了很多未清理的监听器
image

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 2.11.1]

Additional context

No response

@cyrilluce
Copy link
Contributor Author

一种临时修复方法

import { Graph } from '@antv/x6';
import { MiniMap } from '@antv/x6-plugin-minimap';

export default class MyMinimapPlugin extends MiniMap {
    onRemove() {
        this.stopListening();
        // TODO 过于hack,如果graph的代码变了,这里也会有问题
        this.targetGraph.clearCells = noop;
        this.targetGraph.dispose();
    }
}

function noop(this: Graph) {
    return this;
}

@x6-bot
Copy link
Contributor

x6-bot bot commented Oct 2, 2024

This thread has been automatically locked because it has not had recent activity.

Please open a new issue for related bugs and link to relevant comments in this thread.

@x6-bot x6-bot bot locked as resolved and limited conversation to collaborators Oct 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant