Merge pull request #8414 from Jetz72/fixes20250816

Attempt to fix another NPE in deserializing decks
This commit is contained in:
kevlahnota
2025-08-17 06:14:31 +08:00
committed by GitHub

View File

@@ -210,11 +210,14 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
super.cloneFieldsTo(clone); super.cloneFieldsTo(clone);
final Deck result = (Deck) clone; final Deck result = (Deck) clone;
loadDeferredSections(); loadDeferredSections();
// parts shouldn't be null
if (parts != null) {
for (Entry<DeckSection, CardPool> kv : parts.entrySet()) { for (Entry<DeckSection, CardPool> kv : parts.entrySet()) {
CardPool cp = new CardPool(); CardPool cp = new CardPool();
result.parts.put(kv.getKey(), cp); result.parts.put(kv.getKey(), cp);
cp.addAll(kv.getValue()); cp.addAll(kv.getValue());
} }
}
result.setAiHints(StringUtils.join(aiHints, " | ")); result.setAiHints(StringUtils.join(aiHints, " | "));
result.setDraftNotes(draftNotes); result.setDraftNotes(draftNotes);
//noinspection ConstantValue //noinspection ConstantValue
@@ -633,7 +636,7 @@ public class Deck extends DeckBase implements Iterable<Entry<DeckSection, CardPo
private Object readResolve() throws ObjectStreamException { private Object readResolve() throws ObjectStreamException {
//If we deserialized an old deck that doesn't have tags, fix it here. //If we deserialized an old deck that doesn't have tags, fix it here.
if(this.tags == null) if(this.tags == null)
return new Deck(this); return new Deck(this, this.getName() == null ? "" : this.getName());
return this; return this;
} }