Make it safe to call set_drive multiple times.

Not an intended usage, but I'll definitely lose context if not careful.
This commit is contained in:
Thomas Harte committed 2026-11-17 14:30:32 -05:00
1 parent 58d10a9066
commit 89a77c728d
1 file changed
+7 -2
+7 -2
View File
@@ -410,12 +410,17 @@ void IWM::propose_shift(const uint8_t bit) {
}
void IWM::set_drive(const int slot, IWMDrive *const drive) {
if(drives_[slot]) {
drives_[slot]->set_event_delegate(nullptr);
drives_[slot]->set_clocking_hint_observer(nullptr);
}
drive_is_rotating_[slot] = false;
drives_[slot] = drive;
if(drive) {
drive->set_event_delegate(this);
drive->set_clocking_hint_observer(this);
} else {
drive_is_rotating_[slot] = false;
}
}