Minor fix change to copy semantics for const shared_ptr since it has …#104
Merged
alan-george-lk merged 1 commit intolivekit:mainfrom Apr 21, 2026
Merged
Minor fix change to copy semantics for const shared_ptr since it has …#104alan-george-lk merged 1 commit intolivekit:mainfrom
alan-george-lk merged 1 commit intolivekit:mainfrom
Conversation
…2 overloads where copy assignment takes a const shared_ptr and increments ref count, with std:: move this defaults to a copy assignment because of const& shared_ptr
xianshijing-lk
approved these changes
Apr 20, 2026
Collaborator
|
Thanks for fixing it. |
alan-george-lk
approved these changes
Apr 20, 2026
Contributor
alan-george-lk
left a comment
There was a problem hiding this comment.
Thanks for this and great PR body/description of the issue!
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.
Summary
LocalAudioTrack::setPublication() and LocalVideoTrack::setPublication() both called std::move() on a const shared_ptr& parameter.
Because the parameter is const, std::move produces a const shared_ptr&&, which cannot bind to shared_ptr's
move-assignment operator (which requires non-const &&).
The compiler silently falls back to copy assignment — the std::move was a no-op.
This PR removes the std::move and documents why the virtual signature is left as const& rather than changed to
by-value (which would enable a true move but constitutes an API-breaking change).
What changed
local_audio_track.h — Replace std::move(publication) with direct copy assignment
local_video_track.h — Same fix
Added comments explaining the const& constraint from the base Track::setPublication virtual signature
Why not change the signature?
setPublication is declared virtual in Track. Changing the parameter from const shared_ptr& to shared_ptr (by value) would be an ABI/API break for any downstream code overriding this method.
Impact
No behavioral change — the code was already copying. This just removes a misleading std::move that suggests a move is happening when it isn't.