DevSpecp.yy: Fix mirror list use of std::move()d objects
We were building a list of mirrored items filled with the memory pointed to by unique_ptrs which had already been std::move()d into other unique_ptrs.
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
#include <stdexcept>
|
||||
#include <memory>
|
||||
#include <functional>
|
||||
#include <user/senseDeviceSpec.h>
|
||||
#include <deviceManager/deviceManager.h>
|
||||
|
||||
#ifndef yylex
|
||||
@@ -33,6 +34,32 @@ void yyerror(const char *message)
|
||||
+ std::string(message));
|
||||
}
|
||||
|
||||
void mirrorDeviceSpecs() {
|
||||
for (const auto& interoSpec : DeviceManager::interoceptorDeviceSpecs) {
|
||||
auto it = std::find_if(
|
||||
DeviceManager::senseDeviceSpecs.begin(),
|
||||
DeviceManager::senseDeviceSpecs.end(),
|
||||
[&interoSpec](const SenseDeviceSpec& spec) {
|
||||
return spec == *interoSpec;
|
||||
});
|
||||
if (it == DeviceManager::senseDeviceSpecs.end()) {
|
||||
DeviceManager::senseDeviceSpecs.push_back(*interoSpec);
|
||||
}
|
||||
}
|
||||
|
||||
for (const auto& extroSpec : DeviceManager::extrospectorDeviceSpecs) {
|
||||
auto it = std::find_if(
|
||||
DeviceManager::senseDeviceSpecs.begin(),
|
||||
DeviceManager::senseDeviceSpecs.end(),
|
||||
[&extroSpec](const SenseDeviceSpec& spec) {
|
||||
return spec == *extroSpec;
|
||||
});
|
||||
if (it == DeviceManager::senseDeviceSpecs.end()) {
|
||||
DeviceManager::senseDeviceSpecs.push_back(*extroSpec);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
%}
|
||||
|
||||
%union {
|
||||
@@ -57,7 +84,7 @@ void yyerror(const char *message)
|
||||
%%
|
||||
|
||||
file: /* NOTHING */
|
||||
| sensor_specs
|
||||
| sensor_specs { mirrorDeviceSpecs(); }
|
||||
;
|
||||
|
||||
sensor_specs:
|
||||
@@ -77,7 +104,6 @@ interoceptor_spec:
|
||||
|
||||
spec->sensorType = $1;
|
||||
DeviceManager::interoceptorDeviceSpecs.push_back(std::move(spec));
|
||||
DeviceManager::senseDeviceSpecs.push_back(*spec);
|
||||
delete $3;
|
||||
}
|
||||
;
|
||||
@@ -89,7 +115,6 @@ extrospector_spec:
|
||||
|
||||
spec->sensorType = $1;
|
||||
DeviceManager::extrospectorDeviceSpecs.push_back(std::move(spec));
|
||||
DeviceManager::senseDeviceSpecs.push_back(*spec);
|
||||
delete $3;
|
||||
}
|
||||
;
|
||||
|
||||
Reference in New Issue
Block a user