Skip to content

Commit 6d81033

Browse files
committed
Keyframe::GetPoint() returns a constant reference now
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.
1 parent 6bc3428 commit 6d81033

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

include/KeyFrame.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ namespace openshot {
125125
double GetDelta(int64_t index);
126126

127127
/// Get a point at a specific index
128-
Point& GetPoint(int64_t index);
128+
Point const & GetPoint(int64_t index);
129129

130130
/// Get current point (or closest point to the right) from the X coordinate (i.e. the frame number)
131131
Point GetClosestPoint(Point p);

src/KeyFrame.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -449,7 +449,7 @@ double Keyframe::GetDelta(int64_t index)
449449
}
450450

451451
// Get a point at a specific index
452-
Point& Keyframe::GetPoint(int64_t index) {
452+
Point const & Keyframe::GetPoint(int64_t index) {
453453
// Is index a valid point?
454454
if (index >= 0 && index < Points.size())
455455
return Points[index];

0 commit comments

Comments
 (0)