-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
tiled crash when trying to select an object in warn/error callback from issues view #4189
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
Comments
Hmm, this isn't crashing Tiled on my system (Linux) either on latest It seems rather unlikely that this issue would depend on the operating system. Maybe it depends on the Qt version? Are you using the 32-bit of 64-bit version of Tiled? Could you try whether it also crashes when you just do this instead: obj.map.selectedObjects = [obj]; |
The installer I used was called The code I provided I think is doing the same, e.g. making a new array and then pushing to it, I've tried a few variants. The centerOn method works great and it moves to the position. Is there perhaps something wrong with the object i'm putting into the list? Is it because I need to select the layer first via code? the I'll see if I can make a smaller reproduce in another test project |
I've created a reproduce repository here https://drive.google.com/drive/folders/14GUFRjK77p1ep700L9dVvCyCOVgDETly?usp=sharing since I can not attach it as a 7zip file.
The following code snippet is the extension in the extensions folder next to the project in case I remove the drive link at some point function createErrorCallback(obj = undefined) {
return () => {
tiled.alert("tiled is crashing now");
if (obj) {
// First select the object
// TODO: Figure out how to do this, my attempts to do this crashes tiled
obj.map.selectedObjects = [];
obj.map.selectedObjects.push(obj);
// obj.layer.selected = true;
// obj.selected = true;
// Then center the view on it
tiled.mapEditor.currentMapView.centerOn(obj.x + obj.width / 2, obj.y + obj.height / 2);
}
};
}
// Register the format
const mapDataFormat = {
name: "Map Exporter",
extension: "json",
write: function (map, fileName) {
tiled.log("Processing " + map.layerCount + " layers...");
for (let i = 0; i < map.layerCount; ++i) {
const layer = map.layerAt(i);
for (let i = 0; i < layer.objectCount; ++i) {
const obj = layer.objectAt(i);
tiled.error(`Object ${obj.name} error, double click to select`, createErrorCallback(obj));
}
}
return ""; // When a non-empty string is returned, it is shown as error message.
},
};
tiled.registerMapFormat("mapData", mapDataFormat);
tiled.log("MapData format registered successfully!"); |
I have just used |
Describe the bug
When registering a callback for tiled.warn or tiled.error and clicking on it in the issue tab tiled crashes when setting selected or trying to change selectedObjects
To Reproduce
Steps to reproduce the behavior:
Expected behavior
That the object would be selected in the tiled editor
Specifications:
The text was updated successfully, but these errors were encountered: