1
0
Fork 0

Fix crashes when loading with cameras active

This commit is contained in:
Hamish Milne 2020-04-10 14:02:18 +01:00
parent e74b44042b
commit 3278a4d7ef
2 changed files with 21 additions and 2 deletions

View File

@ -30,6 +30,19 @@ void Module::serialize(Archive& ar, const unsigned int) {
ar& cameras;
ar& ports;
ar& is_camera_reload_pending;
if (Archive::is_loading::value) {
for (int i = 0; i < NumCameras; i++) {
LoadCameraImplementation(cameras[i], i);
}
for (std::size_t i = 0; i < ports.size(); i++) {
if (ports[i].is_busy) {
cameras[ports[i].camera_id].impl->StartCapture();
}
if (ports[i].is_receiving) {
StartReceiving(static_cast<int>(i));
}
}
}
}
SERIALIZE_IMPL(Module)

View File

@ -13,6 +13,7 @@
#include <boost/serialization/deque.hpp>
#include <boost/serialization/shared_ptr.hpp>
#include <boost/serialization/unique_ptr.hpp>
#include <boost/serialization/version.hpp>
#include "common/common_types.h"
#include "common/swap.h"
#include "core/global.h"
@ -792,8 +793,12 @@ private:
private:
template <class Archive>
void serialize(Archive& ar, const unsigned int) {
ar& impl;
void serialize(Archive& ar, const unsigned int file_version) {
// For compatibility: put a nullptr here
if (file_version == 0) {
std::unique_ptr<Camera::CameraInterface> x;
ar& x;
}
ar& contexts;
ar& current_context;
ar& frame_rate;
@ -883,3 +888,4 @@ void InstallInterfaces(Core::System& system);
} // namespace Service::CAM
SERVICE_CONSTRUCT(Service::CAM::Module)
BOOST_CLASS_VERSION(Service::CAM::Module::CameraConfig, 1)