Commit 4d1964590e0372cf69cbea6f3a649b9572b10ad2

Authored by Scott Klum
1 parent c773e100

Check that template contains at least the indices specified by from and to

Showing 1 changed file with 3 additions and 1 deletions
openbr/plugins/template.cpp
1 #include <QtCore> 1 #include <QtCore>
2 2
3 #include "openbr_internal.h" 3 #include "openbr_internal.h"
  4 +#include "openbr/core/common.h"
4 5
5 namespace br 6 namespace br
6 { 7 {
@@ -229,7 +230,8 @@ class ReorderPointsTransform : public UntrainableMetadataTransform @@ -229,7 +230,8 @@ class ReorderPointsTransform : public UntrainableMetadataTransform
229 { 230 {
230 if (from.size() == to.size()) { 231 if (from.size() == to.size()) {
231 QList<QPointF> points = src.points(); 232 QList<QPointF> points = src.points();
232 - if (!points.contains(QPointF(-1,-1))) { 233 + int size = src.points().size();
  234 + if (!points.contains(QPointF(-1,-1)) && Common::Max(from) < size && Common::Max(to) < size) {
233 for (int i=0; i<from.size(); i++) { 235 for (int i=0; i<from.size(); i++) {
234 std::swap(points[from[i]],points[to[i]]); 236 std::swap(points[from[i]],points[to[i]]);
235 } 237 }