Skip to content

Fix silent save failure when file write is denied#3

Open
srfwb wants to merge 2 commits into
AlexHettle:mainfrom
srfwb:fix/silent-save-failure
Open

Fix silent save failure when file write is denied#3
srfwb wants to merge 2 commits into
AlexHettle:mainfrom
srfwb:fix/silent-save-failure

Conversation

@srfwb
Copy link
Copy Markdown
Contributor

@srfwb srfwb commented May 11, 2026

Summary

Fixes #2 — MeadowPy silently fails when saving a file it doesn't have write permission to. The unsaved dot disappears even though nothing was written to disk.

What changed

  • file_manager.py: save_file() now shows a QMessageBox.critical error dialog when the write fails (same style as existing error dialogs in file_explorer.py)
  • workspace_controller.py: action_save() now checks the return value of save_file() — the modified flag and tab title are only updated on success

Impact

All save paths that go through action_save() are fixed:

  • Ctrl+S / toolbar / menu Save
  • Save-before-Run (F5)
  • Save-before-Debug
  • Save on tab close
  • Save on app exit

Save As was already handling failure correctly.

After fix

  • Set a .py file to read-only, open it, edit it, press Ctrl+S — error dialog should appear and the dot should remain
  • Save a normal file — should work as before, dot disappears, status bar shows "Saved"

@AlexHettle
Copy link
Copy Markdown
Owner

Thanks for getting on this right away! I haven't been able to test this one yet myself, but from running the test suite it looks like it hangs on the file_manager tests and doesn't complete it's testing run, which makes me worried there's an issue worse than just non-updated tests:

image

Like I mentioned on the last code review I made, just make sure you're keeping the test suite in mind when making changes, I'll circle back and check this again once you've looked into this. Once again thanks for working on this!

@srfwb srfwb force-pushed the fix/silent-save-failure branch from ddf3b06 to 1a5c408 Compare May 12, 2026 22:25
@srfwb
Copy link
Copy Markdown
Contributor Author

srfwb commented May 12, 2026

Fixed.

@AlexHettle
Copy link
Copy Markdown
Owner

Just tested this. The save error popup now shows correctly for direct Save, Run, and Debug, so this is partially fixed. However, there are still a few cases where MeadowPy continues as if the save succeeded. When I click Run or Debug on a modified file MeadowPy cannot write to, it shows the save error popup but still runs/debugs the old on-disk file. In this scenario, I think Run/Debug should not continue if save-before-run/debug fails. Also, when closing the tab or exiting the app with unsaved changes, MeadowPy shows the “Save before closing?” prompt, but clicking Save behaves as if the file was saved even though it was not. These flows should stop after the failed save, show the save error, and keep the file open and marked unsaved.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Not showing Permission Denied Error

2 participants