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

Creating TileLayers in groups via API do not inherit the TileMaps size #3291

Closed
Miepee opened this issue Mar 5, 2022 · 0 comments
Closed
Assignees
Labels
bug Broken behavior.

Comments

@Miepee
Copy link
Contributor

Miepee commented Mar 5, 2022

Describe the bug
If a tileLayer that's getting added to a tileMap does not have a size set but tileMap does, then Tiled tries to set the layer's size tot he map size:

    // If this map has a valid size but the tile layer that's getting added
    // doesn't, default the layer's size to the map size.
    if (editableLayer->isTileLayer()) {
        auto editableTileLayer = static_cast<EditableTileLayer*>(editableLayer);
        if (editableTileLayer->size().isNull() && !size().isNull())
            editableTileLayer->setSize(size());
    }

This however does not occur if the tilerLayer that's being added is part of a group layer.

To Reproduce
Via the js API, do the following:

  • create a tilemap with a certain size
  • create a groupLayer
  • create a tileLayer and add it to the groupLayer

Expected behavior
The tileLayer that's being added to the group should get the size set to the maps' size if it has a valid one.

Platform (please complete the following information):

  • OS: Windows 10
  • Version: Tiled 1.8.2
@bjorn bjorn added the bug Broken behavior. label Mar 7, 2022
@bjorn bjorn self-assigned this Mar 7, 2022
bjorn added a commit that referenced this issue Mar 7, 2022
…oup layer

Otherwise, scripts that add tile layers to group layers, before adding
the group layers to a map, and that do not explicitly set a size on
those tile layers, will end up with 0x0 layers that cause glitches and
do not save correctly.

Closes #3291
@bjorn bjorn closed this as completed in ae4aafa Mar 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Broken behavior.
Projects
None yet
Development

No branches or pull requests

2 participants