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 crash under LTO #46

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 7 additions & 3 deletions src/ipa/raspberrypi/cam_helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,19 @@ namespace libcamera {
LOG_DECLARE_CATEGORY(IPARPI)
}

static std::map<std::string, CamHelperCreateFunc> camHelpers;
static std::map<std::string, CamHelperCreateFunc>& camHelpers() {
static std::map<std::string, CamHelperCreateFunc>* obj =
new std::map<std::string, CamHelperCreateFunc>();
return *obj;
}

CamHelper *CamHelper::create(std::string const &camName)
{
/*
* CamHelpers get registered by static RegisterCamHelper
* initialisers.
*/
for (auto &p : camHelpers) {
for (auto &p : camHelpers()) {
if (camName.find(p.first) != std::string::npos)
return p.second();
}
Expand Down Expand Up @@ -253,5 +257,5 @@ void CamHelper::populateMetadata([[maybe_unused]] const MdParser::RegisterMap &r
RegisterCamHelper::RegisterCamHelper(char const *camName,
CamHelperCreateFunc createFunc)
{
camHelpers[std::string(camName)] = createFunc;
camHelpers()[std::string(camName)] = createFunc;
}
11 changes: 8 additions & 3 deletions src/ipa/raspberrypi/controller/algorithm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,14 +34,19 @@ void Algorithm::process([[maybe_unused]] StatisticsPtr &stats,

/* For registering algorithms with the system: */

static std::map<std::string, AlgoCreateFunc> algorithms;
static std::map<std::string, AlgoCreateFunc>& algorithms() {
static std::map<std::string, AlgoCreateFunc>* obj =
new std::map<std::string, AlgoCreateFunc>();
return *obj;
}

std::map<std::string, AlgoCreateFunc> const &RPiController::getAlgorithms()
{
return algorithms;
return algorithms();
}

RegisterAlgorithm::RegisterAlgorithm(char const *name,
AlgoCreateFunc createFunc)
{
algorithms[std::string(name)] = createFunc;
algorithms()[std::string(name)] = createFunc;
}