From 4e8e4b78ec3b49079fd2c838a850ce27f036790a Mon Sep 17 00:00:00 2001 From: tomascz Date: Sat, 25 Dec 2021 15:22:50 +0100 Subject: [PATCH] [#40] Track Map: General improvements and bugfixes (Part 24: Fixed concurrent access to the disk) --- Main/src/ViewTrackMap.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Main/src/ViewTrackMap.cpp b/Main/src/ViewTrackMap.cpp index 57d13d77..9cb3d993 100644 --- a/Main/src/ViewTrackMap.cpp +++ b/Main/src/ViewTrackMap.cpp @@ -229,12 +229,19 @@ break; const div_t d=div(trackNumber,nHeads); // . scanning the Track to draw its Sector Statuses + { EXCLUSIVELY_LOCK_IMAGE(*image); + if (!::IsWindow(pvtm->m_hWnd)) // TrackMap may not exist if, for instance, switched to another view while still scanning some Track(s) + continue; ti.cylinder=d.quot, ti.head=d.rem; //if (pvtm->displayType==TDisplayType::STATUS) // commented out because this scanning always needed ti.nSectors=image->ScanTrack( ti.cylinder, ti.head, nullptr, ti.bufferId, ti.bufferLength, ti.bufferStartNanoseconds ); + } // . scanning the Track to draw its Sector data if (pvtm->displayType>=TDisplayType::DATA_OK_ONLY){ TFdcStatus statuses[(TSector)-1]; + EXCLUSIVELY_LOCK_IMAGE(*image); + if (!::IsWindow(pvtm->m_hWnd)) // TrackMap may not exist if, for instance, switched to another view while still scanning some Track(s) + continue; image->GetTrackData( ti.cylinder, ti.head, Revolution::CURRENT, ti.bufferId, sectorIdAndPositionIdentity, ti.nSectors, ti.bufferSectorData, ti.bufferLength, statuses ); for( TSector n=0; ndisplayType!=TDisplayType::DATA_ALL && !statuses[n].IsWithoutError()) @@ -638,6 +645,7 @@ // - disposing the RainbowPens (assuming that the FillerByte color is a stock object) for( int t=TRACK_MAP_COLORS_COUNT; t--; ::DeleteObject(rainbowBrushes[t]) ); // - base + EXCLUSIVELY_LOCK_IMAGE(*IMAGE); __super::OnDestroy(); }