Commit Graph

3 Commits

Author SHA1 Message Date
montanon
807007ad8a Fix bitmap memory leaks, load concurrency, money clamp
Bitmap disposal (6 files):
- SlotModel.SetImage: dispose old Avalonia Bitmap + input SKBitmap
- PKMEditorVM: dispose old SpriteImage, LegalityImage, BallSprite
  and intermediate SKBitmaps on every update
- SAVEditorVM: dispose old BoxWallpaper + SKBitmap on box navigation
- WondercardVM: dispose old GiftSlotModel.Sprite on refresh
- QRDialogVM: dispose intermediate SKBitmaps during QR generation
- Added ToAvaloniaBitmapAndDispose helper for owned SKBitmap conversion

Concurrency:
- MainWindowVM: add _isLoading guard to prevent concurrent LoadFileAsync
  calls from drag-drop or rapid Open clicks

Money clamp:
- Trainer8/8a/8b/9/9a: clamp Money to sav.MaxMoney on save
  (was allowing values exceeding game maximums)
2026-03-18 15:32:37 -03:00
montanon
075d22d2d7 Fix undo atomicity, 40+ unchecked casts, data loss, deadlock
Undo/Redo:
- Swap operations now push a single atomic undo entry (was 2)
- Sort/Clear operations now push undo snapshots for all affected slots
- Redo stack properly invalidated after sort/clear

Unchecked casts (17 files):
- All (ushort)PlayedHours across 9 trainer VMs → Math.Clamp
- All (byte)/(ushort)/(uint) casts in Misc4/5, Donut9a, DonutEditor9a,
  Poffin8b, Pokedex9a, FestivalPlaza7, ZygardeCell7, Roamer6
- PlayedMinutes/Seconds: % 60 → Math.Clamp(0, 59)
- SAVTrainer6 TID16/SID16: uint.TryParse → ushort.TryParse
- Trainer7 SnapCount/Thumbs: (uint)negative → Math.Max(0, ...)
- Trainer8 WattTotal: (int)uint overflow → Math.Min(int.MaxValue)
- Trainer8b BP: (uint)negative → Math.Max(0, ...)

Data loss fixes:
- Poffin8b: MstID (poffin type) now written back on save
- MemoryAmie: Sociability changed from byte to uint (preserves >255)
- MemoryAmie: VarIndex reset after list rebuild (prevents stale index)

Bounds checks:
- BoxExporter: validate SelectedNamerIndex, try-catch Export
- KChart: validate ability ID before array access
- SAVRoamer6: clamp species/roam-state indices to valid range
- HallOfFame6: clarified ref struct write-through (not a bug)

Other:
- App shutdown: synchronous JSON save (eliminates deadlock risk)
- ShowPromptAsync: real dialog implementation (was no-op stub)
- PKHeXSettings: expose SerializerOptions for sync serialization
2026-03-18 15:32:37 -03:00
montanon
0924a37978 Add Gen 7-8 subform dialogs
24 generation-specific subforms:

Gen 7: Trainer7, Trainer7GG, PokedexSM, PokedexGG,
       FestivalPlaza, ZygardeCell, Capture7GG, Pokebean,
       HallOfFame7
Gen 8: Trainer8 (SwSh), Trainer8a (LA), Trainer8b (BDSP),
       PokedexSWSH, PokedexBDSP, PokedexLA,
       PokedexResearchEditorLA, ResearchTask8aPanel,
       BlockDump8, FlagWork8b, Misc8b, Poffin8b,
       SealStickers8b, Underground8b, Raid8
2026-03-18 15:32:35 -03:00