Skip to content

Commit

Permalink
Keyframe::GetPoint() returns a constant reference now
Browse files Browse the repository at this point in the history
Returning a non constant reference is not possible; this allows
outside code to invalidate internal invariants (sorted order of
points) by modifying the returned point.  To make updates the current
best approach is to remove the point by index, and then add it again.
  • Loading branch information
musteresel committed Nov 21, 2019
1 parent 6bc3428 commit 6d81033
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion include/KeyFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ namespace openshot {
double GetDelta(int64_t index);

/// Get a point at a specific index
Point& GetPoint(int64_t index);
Point const & GetPoint(int64_t index);

/// Get current point (or closest point to the right) from the X coordinate (i.e. the frame number)
Point GetClosestPoint(Point p);
Expand Down
2 changes: 1 addition & 1 deletion src/KeyFrame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -449,7 +449,7 @@ double Keyframe::GetDelta(int64_t index)
}

// Get a point at a specific index
Point& Keyframe::GetPoint(int64_t index) {
Point const & Keyframe::GetPoint(int64_t index) {
// Is index a valid point?
if (index >= 0 && index < Points.size())
return Points[index];
Expand Down

0 comments on commit 6d81033

Please sign in to comment.