Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Treat failed save actions as cancel actions. #146

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading