Skip to content

Commit ce9310d

Browse files
committed
Fixed workspace bug (#891)
1 parent 4f1d2f0 commit ce9310d

File tree

1 file changed

+39
-29
lines changed

1 file changed

+39
-29
lines changed

Emulator/VAmiga/Components/Amiga.cpp

+39-29
Original file line numberDiff line numberDiff line change
@@ -352,45 +352,55 @@ Amiga::saveWorkspace(const fs::path &path)
352352

353353
auto exportADF = [&](FloppyDrive& drive, string name) {
354354

355-
if (!drive.hasDisk()) return;
356-
357-
string file = name + (config.compressWorkspaces ? ".adz" : ".adf");
358-
359-
try {
355+
if (drive.hasDisk()) {
360356

361-
if (config.compressWorkspaces) {
362-
363-
ADZFile(ADFFile(drive)).writeToFile(path / file);
364-
} else {
365-
ADFFile(drive).writeToFile(path / file);
366-
}
367-
drive.markDiskAsUnmodified();
357+
string file = name + (config.compressWorkspaces ? ".adz" : ".adf");
368358

369-
df << "try " << name << " insert " << file << "\n";
370-
df << "try " << name << (drive.hasProtectedDisk() ? " protect\n" : " unprotect\n");
359+
try {
360+
361+
if (config.compressWorkspaces) {
362+
363+
ADZFile(ADFFile(drive)).writeToFile(path / file);
364+
} else {
365+
ADFFile(drive).writeToFile(path / file);
366+
}
367+
drive.markDiskAsUnmodified();
368+
369+
df << "try " << name << " insert " << file << "\n";
370+
df << "try " << name << (drive.hasProtectedDisk() ? " protect\n" : " unprotect\n");
371+
372+
} catch (...) { }
373+
374+
} else {
371375

372-
} catch (...) { }
376+
df << "try " << name << " eject\n";
377+
}
373378
};
374379

375380
auto exportHDF = [&](HardDrive& drive, string name) {
376381

377-
if (!drive.hasDisk()) return;
378-
379-
string file = name + (config.compressWorkspaces ? ".hdz" : ".hdf");
380-
381-
try {
382+
if (drive.hasDisk()) {
382383

383-
if (config.compressWorkspaces) {
384-
HDZFile(HDFFile(drive)).writeToFile(path / file);
385-
} else {
386-
HDFFile(drive).writeToFile(path / file);
387-
}
388-
drive.markDiskAsUnmodified();
384+
string file = name + (config.compressWorkspaces ? ".hdz" : ".hdf");
389385

390-
hd << "try " << name << " attach " << file << "\n";
391-
hd << "try " << name << (drive.hasProtectedDisk() ? " protect\n" : " unprotect\n");
386+
try {
387+
388+
if (config.compressWorkspaces) {
389+
HDZFile(HDFFile(drive)).writeToFile(path / file);
390+
} else {
391+
HDFFile(drive).writeToFile(path / file);
392+
}
393+
drive.markDiskAsUnmodified();
394+
395+
hd << "try " << name << " attach " << file << "\n";
396+
hd << "try " << name << (drive.hasProtectedDisk() ? " protect\n" : " unprotect\n");
397+
398+
} catch (...) { }
399+
400+
} else {
392401

393-
} catch (...) { }
402+
hd << "try " << name << " disconnect\n";
403+
}
394404
};
395405

396406
// If a file with the specified name exists, delete it

0 commit comments

Comments
 (0)