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

Can't set Tile.objectGroup back to null #3495

Closed
juanitogan opened this issue Oct 10, 2022 · 1 comment · Fixed by #3502
Closed

Can't set Tile.objectGroup back to null #3495

juanitogan opened this issue Oct 10, 2022 · 1 comment · Fixed by #3502
Labels
bug Broken behavior. good first issue Good thing to start with, and don't be shy to ask for help! hacktoberfest Good thing to try for Hacktoberfest participants.

Comments

@juanitogan
Copy link

Describe the bug

I can't find a way to remove an ObjectGroup from a Tile. That is, to set Tile.objectGroup back to null after setting it. Either I'm just not finding it, or a method or something is missing.

The best I can currently do is either loop through and remove all objects from the group, or assign it a new empty group.

To Reproduce

tile.objectGroup = new ObjectGroup()
tile.objectGroup = null

Expected behavior

The ObjectGroup associated with the tile in case collision shapes were defined. Returns null if no collision shapes were defined for this tile.

If it can be null (which it can), I should be able to set it back to null, either directly or via method.

Specifications:

  • OS: Windows 10
  • Tiled Version: 1.9.2
@juanitogan juanitogan added the bug Broken behavior. label Oct 10, 2022
@bjorn
Copy link
Member

bjorn commented Oct 18, 2022

Yeah, I think there is no reason for this early null check:

void EditableTile::setObjectGroup(EditableObjectGroup *editableObjectGroup)
{
if (!editableObjectGroup) {
ScriptManager::instance().throwNullArgError(0);
return;
}

It can be done later where necessary such that we set the tile's object group to null, which is already supported as per this code:

std::unique_ptr<ObjectGroup> clonedGroup;
if (!objectGroup->isEmpty())
clonedGroup.reset(objectGroup->clone());
QUndoStack *undoStack = mTilesetDocument->undoStack();
mApplyingChanges = true;
undoStack->push(new ChangeTileObjectGroup(mTilesetDocument, mTile, std::move(clonedGroup)));

@bjorn bjorn added good first issue Good thing to start with, and don't be shy to ask for help! hacktoberfest Good thing to try for Hacktoberfest participants. labels Oct 18, 2022
lhiginbotham added a commit to lhiginbotham/tiled that referenced this issue Oct 21, 2022
	- fixes mapeditor#3495 by handling the case where a user calls `tile.objectGroup = null`, allowing the user to clear out assigned collision shape objects
@bjorn bjorn closed this as completed in f138cf5 Oct 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Broken behavior. good first issue Good thing to start with, and don't be shy to ask for help! hacktoberfest Good thing to try for Hacktoberfest participants.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants