Browse Source

Vehicle.cc: avoid weak_ptr::expired() & weak_ptr::lock() call combination

- if used multi-threaded: avoids a race condition
- if not: reduces amount of atomic ops
QGC4.4
Beat Küng 4 years ago committed by Lorenz Meier
parent
commit
8ce3acee83
  1. 5
      src/Vehicle/Vehicle.cc

5
src/Vehicle/Vehicle.cc

@ -2661,11 +2661,10 @@ void Vehicle::_sendMavCommandWorker(bool commandInt, bool requestMessage, bool s @@ -2661,11 +2661,10 @@ void Vehicle::_sendMavCommandWorker(bool commandInt, bool requestMessage, bool s
return;
}
WeakLinkInterfacePtr weakLink = vehicleLinkManager()->primaryLink();
SharedLinkInterfacePtr sharedLink = vehicleLinkManager()->primaryLink().lock();
if (!weakLink.expired()) {
if (sharedLink) {
MavCommandListEntry_t entry;
SharedLinkInterfacePtr sharedLink = weakLink.lock();
entry.useCommandInt = commandInt;
entry.targetCompId = targetCompId;

Loading…
Cancel
Save