Corrected failed assertion in restore and delete snapshot functions in the SnapshotManager

This commit is contained in:
Nav
2023-04-15 12:35:30 +01:00
parent f1daa9066d
commit 080bfcffbc

View File

@@ -262,7 +262,9 @@ namespace Bloom::Widgets
if (snapshotViewerIt == this->snapshotViewersById.end()) { if (snapshotViewerIt == this->snapshotViewersById.end()) {
const auto& snapshotIt = this->snapshotsById.find(snapshotId); const auto& snapshotIt = this->snapshotsById.find(snapshotId);
assert(snapshotIt != this->snapshotsById.end()); if (snapshotIt == this->snapshotsById.end()) {
return;
}
snapshotViewerIt = this->snapshotViewersById.insert( snapshotViewerIt = this->snapshotViewersById.insert(
snapshotId, snapshotId,
@@ -277,7 +279,11 @@ namespace Bloom::Widgets
void SnapshotManager::deleteSnapshot(const QString& snapshotId, bool confirmationPromptEnabled) { void SnapshotManager::deleteSnapshot(const QString& snapshotId, bool confirmationPromptEnabled) {
const auto& snapshotIt = this->snapshotsById.find(snapshotId); const auto& snapshotIt = this->snapshotsById.find(snapshotId);
assert(snapshotIt != this->snapshotsById.end());
if (snapshotIt == this->snapshotsById.end()) {
return;
}
const auto& snapshot = snapshotIt.value(); const auto& snapshot = snapshotIt.value();
if (confirmationPromptEnabled) { if (confirmationPromptEnabled) {
@@ -349,7 +355,11 @@ namespace Bloom::Widgets
void SnapshotManager::restoreSnapshot(const QString& snapshotId, bool confirmationPromptEnabled) { void SnapshotManager::restoreSnapshot(const QString& snapshotId, bool confirmationPromptEnabled) {
const auto& snapshotIt = this->snapshotsById.find(snapshotId); const auto& snapshotIt = this->snapshotsById.find(snapshotId);
assert(snapshotIt != this->snapshotsById.end());
if (snapshotIt == this->snapshotsById.end()) {
return;
}
const auto& snapshot = snapshotIt.value(); const auto& snapshot = snapshotIt.value();
if (confirmationPromptEnabled) { if (confirmationPromptEnabled) {