-
Notifications
You must be signed in to change notification settings - Fork 0
Add project save/load workflow to calculator example #12
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
Add project save/load workflow to calculator example #12
Conversation
…t-save-and-load-issue-eg36j4
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting
| void FlowchartManager::saveAllFlowcharts() | ||
| { | ||
| if (_tabWidget->count() == 0) | ||
| return; | ||
|
|
||
| if (_projectDirectory.isEmpty() && !promptForProjectDirectory()) { | ||
| updateActionsState(); | ||
| return; | ||
| } | ||
|
|
||
| if (!ensureProjectLocation()) { | ||
| QMessageBox::warning(this, | ||
| tr("Save Flowchart"), | ||
| tr("Unable to access the selected project folder.")); | ||
| updateActionsState(); | ||
| return; | ||
| } | ||
|
|
||
| QSet<QString> usedNames = collectProjectFileNames(); | ||
|
|
||
| bool anySaved = false; | ||
| bool encounteredError = false; | ||
|
|
||
| for (int i = 0; i < _tabWidget->count(); ++i) { | ||
| FlowchartPage *page = pageAt(i); | ||
| if (!page) | ||
| continue; | ||
|
|
||
| bool const requiresPath = page->filePath().isEmpty(); | ||
| QString const path = ensureProjectPathFor(page, &usedNames); | ||
| if (path.isEmpty()) { | ||
| encounteredError = true; | ||
| break; | ||
| } | ||
|
|
||
| if (!requiresPath && !page->isModified()) | ||
| QFileInfo const info(path); | ||
| if (!page->isModified() && info.exists()) | ||
| continue; | ||
|
|
||
| bool const saved = saveFlowchart(page, requiresPath, !requiresPath); | ||
|
|
||
| if (!saved) { | ||
| if (requiresPath) | ||
| break; | ||
|
|
||
| continue; | ||
| if (!page->save()) { | ||
| encounteredError = true; | ||
| break; | ||
| } | ||
|
|
||
| anySaved = true; | ||
| } | ||
|
|
||
| if (encounteredError) { | ||
| QMessageBox::warning(this, | ||
| tr("Save Flowchart"), | ||
| tr("Failed to save one or more flowcharts.")); | ||
| } | ||
|
|
||
| if (anySaved) | ||
| updateWindowModifiedFlag(); | ||
|
|
||
| writeProjectManifest(); | ||
| updateActionsState(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid writing project manifest after failed Save All
The Save All loop assigns each tab a path via ensureProjectPathFor before attempting page->save(). When any save fails, _filePath remains set even though no file was written, but the code still calls writeProjectManifest() unconditionally. The manifest therefore contains entries for flowcharts that were not saved and whose files do not exist, so re-opening the project later will try to load missing files. Consider skipping the manifest update (or rolling back the assigned file paths) when encounteredError is true.
Useful? React with 👍 / 👎.
Summary
Testing
https://chatgpt.com/codex/tasks/task_e_68edb5fb39ec832d8fffe84e1c68846f