Fix Tileset copy construction/assignment

This commit is contained in:
BigBahss 2021-03-07 19:17:17 -05:00
parent f166652ccc
commit a68a9baf2e
2 changed files with 53 additions and 2 deletions

View file

@ -10,8 +10,8 @@ class Tileset
{
public:
Tileset() = default;
Tileset(const Tileset &other) = default;
Tileset &operator=(const Tileset &other) = default;
Tileset(const Tileset &other);
Tileset &operator=(const Tileset &other);
public:
QString name;

View file

@ -8,6 +8,57 @@
#include <QImage>
Tileset::Tileset(const Tileset &other)
: name(other.name),
is_compressed(other.is_compressed),
is_secondary(other.is_secondary),
padding(other.padding),
tiles_label(other.tiles_label),
palettes_label(other.palettes_label),
metatiles_label(other.metatiles_label),
metatiles_path(other.metatiles_path),
callback_label(other.callback_label),
metatile_attrs_label(other.metatile_attrs_label),
metatile_attrs_path(other.metatile_attrs_path),
tilesImagePath(other.tilesImagePath),
tilesImage(other.tilesImage),
palettePaths(other.palettePaths),
tiles(other.tiles),
palettes(other.palettes),
palettePreviews(other.palettePreviews)
{
for (auto *metatile : other.metatiles) {
metatiles.append(new Metatile(*metatile));
}
}
Tileset &Tileset::operator=(const Tileset &other) {
name = other.name;
is_compressed = other.is_compressed;
is_secondary = other.is_secondary;
padding = other.padding;
tiles_label = other.tiles_label;
palettes_label = other.palettes_label;
metatiles_label = other.metatiles_label;
metatiles_path = other.metatiles_path;
callback_label = other.callback_label;
metatile_attrs_label = other.metatile_attrs_label;
metatile_attrs_path = other.metatile_attrs_path;
tilesImagePath = other.tilesImagePath;
tilesImage = other.tilesImage;
palettePaths = other.palettePaths;
tiles = other.tiles;
palettes = other.palettes;
palettePreviews = other.palettePreviews;
metatiles.clear();
for (auto *metatile : other.metatiles) {
metatiles.append(new Metatile(*metatile));
}
return *this;
}
Tileset* Tileset::getBlockTileset(int metatile_index, Tileset *primaryTileset, Tileset *secondaryTileset) {
if (metatile_index < Project::getNumMetatilesPrimary()) {
return primaryTileset;