Skip to content

Commit

Permalink
Fix Client move constructor bug
Browse files Browse the repository at this point in the history
Signed-off-by: Rob Walworth <[email protected]>
  • Loading branch information
rwalworth committed Sep 21, 2023
1 parent 26e9f76 commit ef47943
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions sdk/main/src/Client.cc
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ Client::~Client()

//-----
Client::Client(Client&& other) noexcept
: mImpl(std::make_unique<ClientImpl>())
{
moveClient(std::move(other));

Expand Down Expand Up @@ -436,16 +437,14 @@ void Client::cancelScheduledNetworkUpdate()
//-----
void Client::moveClient(Client&& other)
{
// Cancel this Client's network update if one exists.
cancelScheduledNetworkUpdate();

// If there's a network update thread running in the moved-from Client, it can't be simply moved. Since it still holds
// a reference to the moved-from Client, the thread must be stopped and restarted in this Client with the remaining
// time so that the Client reference can be updated to this Client and no longer be pointing to a moved-from Client.
if (other.mImpl->mNetworkUpdateThread)
{
// Cancel this Client's network update if one exists.
cancelScheduledNetworkUpdate();

// Cancel the update.
other.cancelScheduledNetworkUpdate();

Expand Down

0 comments on commit ef47943

Please sign in to comment.