Skip to content

Commit

Permalink
Merge pull request aldelaro5#146 from cristian64/treat_failed_save_ac…
Browse files Browse the repository at this point in the history
…tion_as_cancel

Treat failed save actions as cancel actions.
  • Loading branch information
dreamsyntax authored May 18, 2024
2 parents d493afc + 6fc6691 commit bd8f6b0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 12 deletions.
19 changes: 9 additions & 10 deletions Source/GUI/MemWatcher/MemWatchWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ void MemWatchWidget::openWatchFile()
}
}

void MemWatchWidget::saveWatchFile()
bool MemWatchWidget::saveWatchFile()
{
if (QFile::exists(m_watchListFile))
{
Expand All @@ -684,22 +684,20 @@ void MemWatchWidget::saveWatchFile()
"An error occured while creating and opening the watch list file for writting",
QMessageBox::Ok, this);
errorBox->exec();
return;
return false;
}
QJsonObject root;
m_watchModel->writeRootToJsonRecursive(root);
QJsonDocument saveDoc(root);
watchFile.write(saveDoc.toJson());
watchFile.close();
m_hasUnsavedChanges = false;
return true;
}
else
{
saveAsWatchFile();
}
return saveAsWatchFile();
}

void MemWatchWidget::saveAsWatchFile()
bool MemWatchWidget::saveAsWatchFile()
{
QString fileName = QFileDialog::getSaveFileName(this, "Save watch list", m_watchListFile,
"Dolphin memory watches file (*.dmw)");
Expand All @@ -715,7 +713,7 @@ void MemWatchWidget::saveAsWatchFile()
"An error occured while creating and opening the watch list file for writting",
QMessageBox::Ok, this);
errorBox->exec();
return;
return false;
}
QJsonObject root;
m_watchModel->writeRootToJsonRecursive(root);
Expand All @@ -724,7 +722,9 @@ void MemWatchWidget::saveAsWatchFile()
watchFile.close();
m_watchListFile = fileName;
m_hasUnsavedChanges = false;
return true;
}
return false;
}

void MemWatchWidget::clearWatchList()
Expand Down Expand Up @@ -844,8 +844,7 @@ bool MemWatchWidget::warnIfUnsavedChanges()
case QMessageBox::No:
return true;
case QMessageBox::Yes:
saveWatchFile();
return true;
return saveWatchFile();
default:
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions Source/GUI/MemWatcher/MemWatchWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ class MemWatchWidget : public QWidget
void copySelectedWatchesToClipBoard();
void cutSelectedWatchesToClipBoard();
void pasteWatchFromClipBoard(const QModelIndex& referenceIndex);
void saveWatchFile();
void saveAsWatchFile();
bool saveWatchFile();
bool saveAsWatchFile();
void clearWatchList();
void importFromCTFile();
void exportWatchListAsCSV();
Expand Down

0 comments on commit bd8f6b0

Please sign in to comment.