Skip to content

AddTimeData will never update nTimeOffset past 199 samples #4521

@jprupp

Description

@jprupp

Reading the function AddTimeData, I came to notice two things:

  • The structure vTimeOffsets contains up to 200 elements, after which any new element added to it will not increase its size, replacing the oldest element.
  • The condition to update nTimeOffset includes checking whether the number of elements in vTimeOffsets is odd, which will never happen after there are 200 elements.

This will lead to nTimeOffset not updating past 199 calls to AddTimeData, remaining forever stuck in whatever value it had then. I don't believe this is the inteded behaviour. I would suggest removing the oddness check, since vTimeOffsets is capable of returning the median value of an even list according to the median method of the CMedianFilter type.

In current master, the offending code is in src/timedata.cpp, line 52, columns 34-64:

if (vTimeOffsets.size() >= 5 && vTimeOffsets.size() % 2 == 1)

This should better be:

if (vTimeOffsets.size() >= 5)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions