Skip to content

Commit

Permalink
Merge pull request #424 from mnoomnoo/issue-423
Browse files Browse the repository at this point in the history
Issue-423: Crash when editing device dataitem in DeviceModel
  • Loading branch information
wsobel authored Mar 20, 2024
2 parents f177492 + 4a5ab8b commit 553da0d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
12 changes: 10 additions & 2 deletions src/mtconnect/buffer/checkpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,9 +174,17 @@ namespace mtconnect::buffer {
/// @param[in] diMap the map of data ids to data item pointers
void updateDataItems(std::unordered_map<std::string, WeakDataItemPtr> &diMap)
{
for (auto &o : m_observations)
auto iter = m_observations.begin();
while( iter != m_observations.end() )
{
o.second->updateDataItem(diMap);
auto item = *iter;
if( item.second->isOrphan() ) {
iter = m_observations.erase(iter);
}
else {
item.second->updateDataItem(diMap);
iter++;
}
}
}

Expand Down
9 changes: 8 additions & 1 deletion src/mtconnect/buffer/circular_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@
#include "mtconnect/config.hpp"
#include "mtconnect/observation/observation.hpp"
#include "mtconnect/utilities.hpp"
#include "mtconnect/logging.hpp"
#include "mtconnect/entity/requirement.hpp"


namespace mtconnect::buffer {
using SequenceNumber_t = uint64_t;
Expand Down Expand Up @@ -84,9 +87,13 @@ namespace mtconnect::buffer {
{
for (auto &o : m_slidingBuffer)
{
o->updateDataItem(diMap);
if( o->isOrphan() ) {
continue;
}
o->updateDataItem(diMap);
}

// checkpoints will remove orphans from its observations
m_first.updateDataItems(diMap);
m_latest.updateDataItems(diMap);

Expand Down

0 comments on commit 553da0d

Please sign in to comment.