fix move semantics for data loaded from .tbl and .tbm files#7608
Open
Goober5000 wants to merge 3 commits into
Open
fix move semantics for data loaded from .tbl and .tbm files#7608Goober5000 wants to merge 3 commits into
Goober5000 wants to merge 3 commits into
Conversation
The defaulted moves copied the conditionally-owned name and its ownership flag without clearing the source, so reallocation of Builtin_messages (mods append custom types via #Message Types) freed every strdup'd name out from under the surviving elements. Hand-write the moves to reset the source and free the destination's old name. Also fix copy-assignment, which leaked the old name and was unsafe under self-assignment. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The hand-written ~350-line memberwise move existed only to manage the one raw owning pointer, and silently left any member it didn't mention uninitialized in the destination. With subsystems as a unique_ptr, the defaulted moves and destructor are correct by composition. Copies become explicitly deleted (use clone()). n_subsystems stays a plain int because it is passed to varargs functions. The moves are not declared noexcept because libstdc++ computes a potentially-throwing implicit specification; NOLINT suppresses clang-tidy accordingly. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
glowpoint_bank_override_map stored raw pointers into the growable global glowpoint_bank_overrides vector. Store indices instead, which survive vector reallocation. The readers also lose a redundant second map lookup (they previously called find() and then operator[] on the same key), and prop_info's parallel map gets the same conversion. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fortunately, most types implemented move semantics correctly (usually because the moves were defaulted), but there were three that needed work:
This PR fixes all three.