Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix nondiscard warnings with lock_guard #373

Merged
merged 1 commit into from
Mar 17, 2022
Merged

Conversation

chapulina
Copy link
Contributor

🦟 Bug fix

Summary

Clean up Windows warnings.

I changed to keeping the object instead of discarding it, let's see if that's enough. This pattern is used on other plugins already.

The original line:

std::lock_guard<std::mutex>(this->dataPtr->mutex)

Was creating an object but not holding it. This would be a way to keep it within the function's scope:

auto lock = std::lock_guard<std::mutex>(this->dataPtr->mutex)

I think some compilers may call a constructor, and then a copy operator that way. So I chose to go with the following, which only calls the constructor:

std::lock_guard<std::mutex> lock(this->dataPtr->mutex)

Let me know what you think, @jennuine .

Checklist

  • Signed all commits for DCO
  • Added tests
  • Updated documentation (as needed)
  • Updated migration guide (as needed)
  • codecheck passed (See contributing)
  • All tests passed (See test coverage)
  • While waiting for a review on your PR, please help review another open pull request to support the maintainers

Note to maintainers: Remember to use Squash-Merge and edit the commit message to match the pull request summary while retaining Signed-off-by messages.

🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸🔸

@chapulina chapulina added bug Something isn't working Windows Windows support labels Mar 17, 2022
@chapulina chapulina requested a review from jennuine as a code owner March 17, 2022 17:34
@github-actions github-actions bot added the 🌱 garden Ignition Garden label Mar 17, 2022
@jennuine
Copy link
Contributor

LGTM, is it possible to run on win-beefy to see if changes worked?

@chapulina
Copy link
Contributor Author

Retriggered the Windows build. I think it should run on beefy this time, because that's currently the only node with the win label, see "Label win matches 1 node." here:

https://build.osrfoundation.org/job/ign_gui-pr-win/configure

CC @j-rivero

@chapulina chapulina merged commit 962cf54 into main Mar 17, 2022
@chapulina chapulina deleted the chapulina/7/nondiscard_lock branch March 17, 2022 21:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working 🌱 garden Ignition Garden Windows Windows support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants