From 89a77c728dfd8f6853fbbf4af0ebad896a852b0e Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 17 Nov 2026 14:30:32 -0500 Subject: [PATCH] Make it safe to call set_drive multiple times. Not an intended usage, but I'll definitely lose context if not careful. --- Components/DiskII/IWM.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/Components/DiskII/IWM.cpp b/Components/DiskII/IWM.cpp index 0ed23ecc0..6a3ad5379 100644 --- a/Components/DiskII/IWM.cpp +++ b/Components/DiskII/IWM.cpp @@ -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; } }