- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Hi, the application that I'm developing is an engineering application. Users open an existing model database file, do some work, and then save the file. I need a feature to check whether or not the user has actually changed the data in a model so that he/she can be prompted appropriately to save before closing/quiting the application. I have created a rudimentary way of doing this by writing out the structure to file before and after editing and then comparing checksums. This method is not particularly elegant and the checksum routine I obtained is a stand alone executable that I need to run via the SYSTEM command (and thus temporarily throws up a console window over my application). I also have a suspicion that the method is not bomb-proof.
I wonder therefore if anyone has any suggestions or recommendations on how one might implement this?
Thanks,
Angus.
링크가 복사됨
8 응답
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
You could keep track of changes (at least in a rough way) by setting a flag each time the user
presses an OK button or whatever is relevant in your application. Irealise that this is
not always possible or reliable and then saving the data in a file is indeed a much easier
way.
To compare the contents of two files, you could use an MPD5 checksum orSHA1 or any of
these cryptographic keys. You ought to be able to find plenty of implementations on the Internet
for them. It would then be a matter of creating an interface to the routine(s) and then you'd
be independent of an external program
Regards,
Arjen
presses an OK button or whatever is relevant in your application. Irealise that this is
not always possible or reliable and then saving the data in a file is indeed a much easier
way.
To compare the contents of two files, you could use an MPD5 checksum orSHA1 or any of
these cryptographic keys. You ought to be able to find plenty of implementations on the Internet
for them. It would then be a matter of creating an interface to the routine(s) and then you'd
be independent of an external program
Regards,
Arjen
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
In a GUI application this would often be handled by having every event handling procedure that could modify the data set a document-global file-has-been-changed flag. This same flag is cleared when the document is saved, or if the entire undo stack since the last save gets popped.
(In your case, every "user entry point" style procedure in the "do some work" part of your description would need to set this flag.)
(In your case, every "user entry point" style procedure in the "do some work" part of your description would need to set this flag.)
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Let's hope that you hold a protected master copy of the data file that user's cannot screw up and replace with the screwed-up version?
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Thanks arjenmarkus, the software already knows where a data structure might change so I just need a checking routine. I'll take another look for an implementation of the checksum routines you suggest.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Thanks IanH, yes I already know when the data might change using my own flag model_database_changed. I just need a quick and reliable method for making the check as to whether or not the data in a structure has changed.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
Good point - hopefully my software will protect the user against this .... but that is yet to be tried in practise! I have not yet coded an undo/redo facility into the software but that is probably something I need to consider for the future.
- 신규로 표시
- 북마크
- 구독
- 소거
- RSS 피드 구독
- 강조
- 인쇄
- 부적절한 컨텐트 신고
All edit dialogs should operate on a copy of the original data structure. If the user ends the edit with "ok/accept", the edited copy then replaces the original and sets the "changed" flag; if the user cancels the dialog, the edited material simply vaporises and the original is left intact.