mapeditor / tiled

Flexible level editor
https://www.mapeditor.org/
Other
11.27k stars 1.76k forks source link

Tiled/extensions/SelectLayerTiles.js:33: TypeError: Cannot call method 'disconnect' of undefined #4050

Closed ManPython closed 2 months ago

ManPython commented 2 months ago

Describe the bug In some reason I have log: Tiled/extensions/SelectLayerTiles.js:33: TypeError: Cannot call method 'disconnect' of undefined

To Reproduce

  1. Don't know reason of this.

Expected behavior

Media

Specifications:

eishiya commented 2 months ago

This seems more appropriate to ask in the script's repo? And if you believe this to be a Tiled issue than a problem with the script, you should explain why.

That said, it sounds like you're running into a Tiled bug that was fixed in 1.11-ish (I'm guessing by your Tiled version you meant 1.9.2, not 2.9.2?), so you should be able to run the script without this problem if you use the latest version.

ManPython commented 2 months ago
ManPython commented 2 months ago

1.11.0 not 1.9.2 ..I'm always checking ver on news.. - bad case..

eishiya commented 2 months ago

Another user reported the same issue on Discord. I haven't had it happen (1.11 x64, Win10). Seems intermittent, so perhaps there's still an ownership issue somewhere, causing the signal or the asset to get garbage collected somehow.

ManPython commented 2 months ago

It's start visible when I have more .tmx files with custom parameter, but even using more Tiled I see more unexpected behaviors.

eishiya commented 2 months ago

Bjorn, dogboydog, and I discussed this issue on Discord. The likely cause is that when an Tiled object (a TileMap in this case) owned by C++ is deleted, there's no reliable way to automatically clear any remaining JS-side references to it, they remain non-null. There is probably no way for Tiled to fix this, this is something all Tiled scripts have to watch out for.

I've modified the Select Layer Tiles script to check not only that the TileMap reference exists, but also that it isTileMap, which should be sufficient to also catch deleted TileMaps and avoid trying to disconnect from their signals. Please get the latest version of the script, or add the same check in your local copy: https://github.com/eishiya/tiled-scripts/commit/f4a51aa1fdc57b5ac3748b5ad6b39e7ef5b6a2e5

bjorn commented 2 months ago

Issue fixed in script, so closing this.

This seems more appropriate to ask in the script's repo?

Indeed this should have been reported at https://github.com/eishiya/tiled-scripts/issues, but no problem.