Commit fbc005b1 authored by Agata Cacko's avatar Agata Cacko
Browse files

Don't assert on invalid 0-bytes palettes

Before this commit, Krita would assert when the palette stored in
.kra file was 0-bytes. While it is an incorrect situation,
Krita shouldn't crash/assert, but inform the user about it
and load the rest of the file.
parent a9cb5a08
......@@ -542,10 +542,14 @@ void KisKraLoader::loadPalettes(KoStore *store, KisDocument *doc)
KoColorSetSP newPalette(new KoColorSet(filename));
store->open(m_d->imageName + PALETTE_PATH + filename);
QByteArray data = store->read(store->size());
newPalette->fromByteArray(data, KisGlobalResourcesInterface::instance());
newPalette->setIsEditable(true);
store->close();
list.append(newPalette);
if (data.size() > 0) {
newPalette->fromByteArray(data, KisGlobalResourcesInterface::instance());
newPalette->setIsEditable(true);
store->close();
list.append(newPalette);
} else {
m_d->warningMessages.append(i18nc("Warning message on loading a .kra file", "Embedded palette is empty and cannot be loaded. The name of the palette: %1", filename));
}
}
doc->setPaletteList(list);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment