fix: crash when replay file is deleted during version mismatch prompt#1837
fix: crash when replay file is deleted during version mismatch prompt#1837bobtista wants to merge 5 commits intoTheSuperHackers:mainfrom
Conversation
66502a8 to
9d06998
Compare
There was a problem hiding this comment.
There is already an established pathway for handling file deletion during a confirmation popup in ReplayMenu::delateReplay. Adopting this logic would simplify the implementation and resolve the message and list refresh inconsistencies of this change, which I've tabulated below for clarity.
| Action | Refreshes list | Message |
|---|---|---|
| DELETE REPLAY | Yes | The system cannot find the specified file. |
| LOAD REPLAY | No | This replay cannot be loaded because the file no longer exists on this device. |
9d06998 to
c5b68b2
Compare
Thank you - I implemented it this way, rebased the latest main, and force pushed |
|
| Filename | Overview |
|---|---|
| Generals/Code/GameEngine/Source/Common/Recorder.cpp | Moves m_mode = RECORDERMODETYPE_PLAYBACK after file validation to prevent crash if file is NULL during playback updates |
| Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp | Adds pre-playback file existence check and conditional menu hiding; uses 0xFFFFFFFF for VC6 compatibility instead of INVALID_FILE_ATTRIBUTES |
| GeneralsMD/Code/GameEngine/Source/Common/Recorder.cpp | Identical change to vanilla Generals: delays playback mode assignment until after successful file validation |
| GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp | Identical change to vanilla Generals: adds file existence validation and conditional menu hiding with VC6-compatible constant |
Last reviewed commit: c50a803
| if(!TheRecorder->playbackFile(asciiFilename)) | ||
| { | ||
| char buffer[1024]; | ||
| FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(), 0, buffer, sizeof(buffer), nullptr ); |
There was a problem hiding this comment.
Wrong error source
In reallyLoadReplay, the failure path uses GetLastError() to build the UI message after TheRecorder->playbackFile(asciiFilename) returns false. playbackFile() fails for multiple reasons (e.g., invalid header/GameInfo) and doesn’t necessarily set the Win32 last-error to something meaningful, so this can show an unrelated/empty message even when the replay exists. Consider deriving the message from the known failure (e.g., explicitly handle “file not found” via an existence check on the replay path, or have playbackFile/readReplayHeader provide a reason) instead of relying on GetLastError() here.
Prompt To Fix With AI
This is a comment left during a code review.
Path: Generals/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp
Line: 539:542
Comment:
**Wrong error source**
In `reallyLoadReplay`, the failure path uses `GetLastError()` to build the UI message after `TheRecorder->playbackFile(asciiFilename)` returns false. `playbackFile()` fails for multiple reasons (e.g., invalid header/GameInfo) and doesn’t necessarily set the Win32 last-error to something meaningful, so this can show an unrelated/empty message even when the replay exists. Consider deriving the message from the known failure (e.g., explicitly handle “file not found” via an existence check on the replay path, or have `playbackFile`/`readReplayHeader` provide a reason) instead of relying on `GetLastError()` here.
How can I resolve this? If you propose a fix, please make it concise.| if(!TheRecorder->playbackFile(asciiFilename)) | ||
| { | ||
| char buffer[1024]; | ||
| FormatMessage( FORMAT_MESSAGE_FROM_SYSTEM, nullptr, GetLastError(), 0, buffer, sizeof(buffer), nullptr ); |
There was a problem hiding this comment.
Wrong error source
Same issue as vanilla: this failure message is built from GetLastError() after TheRecorder->playbackFile(...) returns false, but the recorder failure isn’t guaranteed to set a relevant Win32 last-error. This can surface an incorrect/empty error message when the file exists but the header/GameInfo parse fails; it should use a recorder-provided reason or an explicit file-not-found check for this UI.
Prompt To Fix With AI
This is a comment left during a code review.
Path: GeneralsMD/Code/GameEngine/Source/GameClient/GUI/GUICallbacks/Menus/ReplayMenu.cpp
Line: 539:542
Comment:
**Wrong error source**
Same issue as vanilla: this failure message is built from `GetLastError()` after `TheRecorder->playbackFile(...)` returns false, but the recorder failure isn’t guaranteed to set a relevant Win32 last-error. This can surface an incorrect/empty error message when the file exists but the header/GameInfo parse fails; it should use a recorder-provided reason or an explicit file-not-found check for this UI.
How can I resolve this? If you propose a fix, please make it concise.c5b68b2 to
cbc36ff
Compare
|
The latest push does this:
|
The latest push uses readReplayMapInfo() to validate the file before playback (like loadReplay), shows the "REPLAY NOT FOUND" message, and refreshes the listbox on failure. Both the message and list refresh should now be consistent with deleteReplay. Ready for re-review when you get a chance. |
Is the latest push actually pushed? Issues still persist:
|
Yes latest was pushed, but you're right. RE Inconsistent messages — I'll switch to using the same FormatMessage/GetLastError pattern that deleteReplay uses, with "GUI:Error" as the title. RE Crash after clicking OK, I think that's something else - I'll investigate. |
6e161cc to
c50a803
Compare
Testing (Done)
Reproduction steps verified: