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:
1 parent
58d10a9066
commit
89a77c728d
1 file changed
+7
-2
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user