mirror of
https://github.com/qelectrotech/qelectrotech-source-mirror.git
synced 2026-10-17 19:34:13 +02:00
Ask before saving over a project file someone else changed
Saving replaced the project file whatever had happened to it since it was opened. If another user, another program or a second QET had saved the same file in between (a shared drive, a copy synced from another PC), their work was lost without a word. QETProject now remembers the project file's size and modification time when it reads it and after each save of its own. Before writing, write() compares them with the file on disk and, if they differ, writes nothing and returns "someone else changed the file on disk at <time> since it was opened". - Interactive save (Ctrl+S, and the save on closing a project) asks: "Someone else changed <file> on disk at <time> since you opened it" with Save as a copy (opens Save As), Overwrite, or Cancel. - Scripts (--run), the command line, MCP and the autosave timer have no one to ask, so they keep the refusal (autosave logs it). Setting QET_OVERWRITE_CHANGED=1 makes a script overwrite on purpose. - A file that does not exist yet, and a Save As to another name, are not a conflict; after Save As the remembered state is the new file's. No change to what is written, so .qet and .qetz stay as they were. Evidence: new tst_changedondisk (unchanged file saves twice; a file written behind the open project is refused; the override overwrites; a Save As target is no conflict) fails on the changed-file case without the source change and passes with it. Full ctest 107/107. Physical check with qet-gui-dialog.sh: file modified behind the open project, Ctrl+S shows the three-button dialog. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MgPFANhWgD66V3v9KVKV58
This commit is contained in:
@@ -131,6 +131,7 @@ class ProjectView : public QWidget
|
||||
QETResult save();
|
||||
QETResult saveAs();
|
||||
QETResult doSave();
|
||||
QETResult writeProject(bool *cancelled);
|
||||
QETResult saveCopyForOlderVersions();
|
||||
int cleanProject();
|
||||
void updateWindowTitle();
|
||||
|
||||
Reference in New Issue
Block a user