Commit cab41cc
Image viewer: construct ImageSource from bitmap to bypass Task binding race
The viewer's template selector binds to ImageSource.TemplateKey via a
Task-based async binding (TemplateKeyAsync^). On the first read the
Task is pending and the binding returns default(ImageSourceTemplateType)
= Default, which is mapped to a "Unsupported Format" text template.
The selector doesn't re-pick when the Task completes later, so the
"unsupported" text sticks around even though TemplateKey eventually
resolved to Image.
The previous fix (await GetOrRefreshTemplateKeyAsync before assigning)
didn't help because TemplateKeyAsync returns a *fresh* Task on every
access — pre-resolving the underlying field still goes through a new
Task at binding time.
Switch to ImageSource's bitmap-only constructor, which sets
TemplateKey = Image synchronously in the ctor body. AdvancedImageBox
renders the decoded bitmap regardless of whether the bytes were JPEG,
PNG, or WebP, which is exactly what we need for CivArchive's
extensionless CDN URLs (img.genur.art/sig/.../base64).
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent b6f12d3 commit cab41cc
1 file changed
Lines changed: 11 additions & 8 deletions
Lines changed: 11 additions & 8 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
462 | 462 | | |
463 | 463 | | |
464 | 464 | | |
465 | | - | |
466 | | - | |
467 | | - | |
468 | | - | |
| 465 | + | |
| 466 | + | |
| 467 | + | |
| 468 | + | |
| 469 | + | |
| 470 | + | |
| 471 | + | |
| 472 | + | |
469 | 473 | | |
470 | 474 | | |
471 | 475 | | |
472 | 476 | | |
473 | 477 | | |
474 | | - | |
475 | | - | |
476 | | - | |
477 | | - | |
| 478 | + | |
| 479 | + | |
| 480 | + | |
478 | 481 | | |
479 | 482 | | |
480 | 483 | | |
| |||
0 commit comments