Skip to content

Correct ways to gather messages form different dbc files into common map #95

Answered by xR3b0rn
baruchli asked this question in Q&A
Discussion options

You must be logged in to vote

The ownership of the dbcppp::IMessage object still lays in the hand of the dbcppp::INetwork-instance. So once the dbcppp::INetwork-instances destructor is called, your stored pointer in line 10 gets invalidated.

The correct way is to not let the dbcppp::INetwork-instances run out of scope by e.g. storing them in a std::vector:

std::string dbcsDir(argv[2]);
std::vector<std::unique_ptr<dbcppp::INetwork>> net;
for (const auto & entry : fs::directory_iterator(dbcsDir)){
      std::ifstream idbc(entry.path());
      // After this line msg(s) inserted from previous dbc file are cleared from memory
      // and messages holds invalid pointers. 
      net.emplace_back(dbcppp::INetwork::LoadDBCFromIs

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Answer selected by xR3b0rn
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@baruchli
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants