Commit 74b825dc authored by Jean-Baptiste Mardelle's avatar Jean-Baptiste Mardelle
Browse files

Fix possible crash on rotoscoping edit

parent ffc4e51b
......@@ -67,7 +67,7 @@ void QmlManager::setScene(Kdenlive::MonitorId id, MonitorSceneType type, QSize p
case MonitorSceneRoto:
m_view->setSource(QUrl(QStringLiteral("qrc:/qml/kdenlivemonitorrotoscene.qml")));
root = m_view->rootObject();
QObject::connect(root, SIGNAL(effectPolygonChanged()), this, SLOT(effectRotoChanged()), Qt::UniqueConnection);
QObject::connect(root, SIGNAL(effectPolygonChanged(QVariant,QVariant)), this, SLOT(effectRotoChanged(QVariant,QVariant)), Qt::UniqueConnection);
root->setProperty("profile", QPoint(profile.width(), profile.height()));
root->setProperty("framesize", QRect(0, 0, profile.width(), profile.height()));
root->setProperty("scalex", scalex);
......@@ -133,13 +133,17 @@ void QmlManager::effectPolygonChanged()
emit effectPointsChanged(points);
}
void QmlManager::effectRotoChanged()
void QmlManager::effectRotoChanged(QVariant pts, QVariant centers)
{
if (!m_view->rootObject()) {
return;
}
QVariantList points = m_view->rootObject()->property("centerPoints").toList();
QVariantList controlPoints = m_view->rootObject()->property("centerPointsTypes").toList();
QVariantList points = pts.toList();
QVariantList controlPoints = centers.toList();
if (2 * points.size() != controlPoints.size()) {
// Mismatch, abort
return;
}
// rotoscoping effect needs a list of
QVariantList mix;
mix.reserve(points.count());
......
......@@ -37,7 +37,7 @@ private:
private slots:
void effectRectChanged();
void effectPolygonChanged();
void effectRotoChanged();
void effectRotoChanged(QVariant,QVariant);
signals:
void effectChanged(const QRect &);
......
......@@ -69,7 +69,7 @@ Item {
property string defaultKeyBindInfo: xi18nc("@info:whatsthis", "<shortcut>Double click</shortcut> on center to resize, <shortcut>Double click</shortcut> on line segment to add new point, <shortcut>Double click</shortcut> point to delete it, <shortcut>Double click</shortcut> background to create new keyframe, <shortcut>Hover right</shortcut> for toolbar");
property string resizeKeyBindInfo: xi18nc("@info:whatsthis", "<shortcut>Shift drag handle</shortcut> for center-based resize")
onCenterPointsTypesChanged: checkDefined()
signal effectPolygonChanged()
signal effectPolygonChanged(var points, var centers)
signal seekToKeyframe()
onDurationChanged: {
......@@ -421,7 +421,7 @@ Item {
if (root.centerPoints.length > 3) {
root.centerPoints.splice(root.requestedKeyFrame, 1)
root.centerPointsTypes.splice(2 * root.requestedKeyFrame, 2)
root.effectPolygonChanged()
root.effectPolygonChanged(root.centerPoints, root.centerPointsTypes)
root.requestedKeyFrame = -1
canvas.requestPaint()
}
......@@ -448,7 +448,7 @@ Item {
root.centerPointsTypes.splice(2 * root.addedPointIndex, 0, Qt.point(newPoint.x + ctrl2.x, newPoint.y + ctrl2.y))
root.centerPointsTypes.splice(2 * root.addedPointIndex, 0, Qt.point(newPoint.x + ctrl1.x, newPoint.y + ctrl1.y))
}
root.effectPolygonChanged()
root.effectPolygonChanged(root.centerPoints, root.centerPointsTypes)
canvas.requestPaint()
}
}
......@@ -477,7 +477,7 @@ Item {
root.centerPointsTypes.push(Qt.point(p1.x + ctrl2.x, p1.y + ctrl2.y))
}
root.isDefined = true;
root.effectPolygonChanged()
root.effectPolygonChanged(root.centerPoints, root.centerPointsTypes)
canvas.requestPaint()
} else if (root.requestedKeyFrame < 0) {
var newPoint = Qt.point((mouseX - frame.x) / root.scalex, (mouseY - frame.y) / root.scaley);
......@@ -552,7 +552,7 @@ Item {
}
}
canvas.requestPaint()
root.effectPolygonChanged()
root.effectPolygonChanged(root.centerPoints, root.centerPointsTypes)
return
}
if (centerContainsMouse) {
......@@ -568,7 +568,7 @@ Item {
root.centerPointsTypes[j * 2 + 1].y += yDiff
}
canvas.requestPaint()
root.effectPolygonChanged()
root.effectPolygonChanged(root.centerPoints, root.centerPointsTypes)
return
}
if (root.requestedKeyFrame >= 0) {
......@@ -584,13 +584,13 @@ Item {
}
canvas.requestPaint()
if (root.isDefined) {
root.effectPolygonChanged()
root.effectPolygonChanged(root.centerPoints, root.centerPointsTypes)
}
} else if (root.requestedSubKeyFrame >= 0) {
root.centerPointsTypes[root.requestedSubKeyFrame].x = (mouseX - frame.x) / root.scalex
root.centerPointsTypes[root.requestedSubKeyFrame].y = (mouseY - frame.y) / root.scaley
canvas.requestPaint()
root.effectPolygonChanged()
root.effectPolygonChanged(root.centerPoints, root.centerPointsTypes)
}
} else if ((root.iskeyframe || controller.autoKeyframe) && root.centerPoints.length > 0) {
// Check if we are over a keyframe
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment