diff --git a/CHANGELOG.md b/CHANGELOG.md index f92f02b4..11e4696d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ The **"Breaking Changes"** listed below are changes that have been made in the d - Fix some file dialogs returning to an incorrect window when closed. - Fix bug where reloading a layout would overwrite all unsaved changes. - Fix bug where layout json and blockdata could be saved separately leading to inconsistent data. +- Fix crash when saving tilesets with fewer palettes than the maximum. ## [5.4.1] - 2024-03-21 ### Fixed diff --git a/src/project.cpp b/src/project.cpp index 88e3d9d1..43b62ecf 100644 --- a/src/project.cpp +++ b/src/project.cpp @@ -1130,7 +1130,8 @@ void Project::saveTilesetTilesImage(Tileset *tileset) { } void Project::saveTilesetPalettes(Tileset *tileset) { - for (int i = 0; i < Project::getNumPalettesTotal(); i++) { + int numPalettes = qMin(tileset->palettePaths.length(), tileset->palettes.length()); + for (int i = 0; i < numPalettes; i++) { QString filepath = tileset->palettePaths.at(i); PaletteUtil::writeJASC(filepath, tileset->palettes.at(i).toVector(), 0, 16); }