This won't work, should be `if (TileLayer *tileLayer = layer->asTileLayer())` otherwise it will crash when dealing with an ObjectGroup.