Просмотр исходного кода

Fix CD-ROM eject button not taking effect.

The log messages got printed but the eject did not apply
because of accidental copy of the image_config_t structure.
Modified so that compiler will detect this mistake in future.
Petteri Aimonen 2 лет назад
Родитель
Сommit
b3528b18b9
2 измененных файлов с 5 добавлено и 1 удалено
  1. 1 1
      src/BlueSCSI_disk.cpp
  2. 4 0
      src/BlueSCSI_disk.h

+ 1 - 1
src/BlueSCSI_disk.cpp

@@ -550,7 +550,7 @@ static void diskEjectAction(uint8_t buttonId)
     log("Eject button pressed for channel ", buttonId);
     for (uint8_t i = 0; i < S2S_MAX_TARGETS; i++)
     {
-        image_config_t img = g_DiskImages[i];
+        image_config_t &img = g_DiskImages[i];
         if (img.ejectButton == buttonId)
         {
             if (img.deviceType == S2S_CFG_OPTICAL)

+ 4 - 0
src/BlueSCSI_disk.h

@@ -42,6 +42,10 @@ extern "C" {
 // Extended configuration stored alongside the normal SCSI2SD target information
 struct image_config_t: public S2S_TargetCfg
 {
+    // There should be only one global instance of this struct per device, so disallow copy constructor.
+    image_config_t() = default;
+    image_config_t(const image_config_t&) = delete;
+
     ImageBackingStore file;
 
     // For CD-ROM drive ejection