fix(tui): prevent image ID collisions between modules

- allocateImageId() now returns random IDs instead of sequential
- Static images no longer auto-allocate IDs (transient display)
- Only explicit imageId usage (like DOSBox) gets tracked IDs
- Suppress emulators exit logging in DOSBox dispose

Fixes image replacement bug when extension and main app both
allocated sequential IDs starting at 1.
This commit is contained in:
Mario Zechner 2026-01-22 04:52:55 +01:00
parent df1d5c40ea
commit fbd6b7f9ba
3 changed files with 26 additions and 22 deletions

View file

@ -206,8 +206,23 @@ export class DosboxComponent implements Component {
this.kittyPushed = false;
}
if (this.ci) {
void this.ci.exit().catch(() => undefined);
// Suppress emulators exit logging
const origLog = console.log;
const origError = console.error;
console.log = () => {};
console.error = () => {};
const ci = this.ci;
this.ci = null;
void ci
.exit()
.catch(() => undefined)
.finally(() => {
// Restore after a delay to catch async logging
setTimeout(() => {
console.log = origLog;
console.error = origError;
}, 100);
});
}
}
}