Unverified Commit 407c8648 authored by Don Gagne's avatar Don Gagne Committed by GitHub

Merge pull request #7584 from DonLakeFlyer/VideoItemCrash

Video item crash
parents 6ac5ddba bd8590de
......@@ -9,6 +9,7 @@ Note: This file only contains high level features or important fixes.
* Major rewrite and bug fix pass through Structure Scan. Previous version had such bad problems that it can no longer be supported. Plans with Structure Scan will need to be recreated. New QGC will not load old Structure Scan plans.
### 3.5.4 - Not yet released
* Guard against null geometry coming from gstreamer which can cause crashes
* Add .apj file selection support to custom firmware flash
### 3.5.3 - Stable
......
......@@ -78,6 +78,17 @@ void VideoItem::setSurface(VideoSurface *surface)
}
#if defined(QGC_GST_STREAMING)
QSGGeometry* VideoItem::_createDefaultGeometry(QRectF& rectBound)
{
QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 4);
geometry->vertexDataAsPoint2D()[0].set(rectBound.x(), rectBound.y());
geometry->vertexDataAsPoint2D()[1].set(rectBound.x(), rectBound.height());
geometry->vertexDataAsPoint2D()[2].set(rectBound.width(), rectBound.y());
geometry->vertexDataAsPoint2D()[3].set(rectBound.width(), rectBound.height());
return geometry;
}
QSGNode* VideoItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData*)
{
QRectF r = boundingRect();
......@@ -103,19 +114,22 @@ QSGNode* VideoItem::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData*)
newNode = oldNode;
}
if (r != _data->targetArea) {
QSGGeometry *geometry = new QSGGeometry(QSGGeometry::defaultAttributes_Point2D(), 4);
geometry->vertexDataAsPoint2D()[0].set(r.x(), r.y());
geometry->vertexDataAsPoint2D()[1].set(r.x(), r.height());
geometry->vertexDataAsPoint2D()[2].set(r.width(), r.y());
geometry->vertexDataAsPoint2D()[3].set(r.width(), r.height());
QSGGeometryNode *node = static_cast<QSGGeometryNode*>(newNode);
node->setGeometry(geometry);
node->setGeometry(_createDefaultGeometry(r));
_data->targetArea = r;
}
} else {
g_signal_emit_by_name(_data->surface.data()->_data->videoSink, "update-node", (void*)oldNode, r.x(), r.y(), r.width(), r.height(), (void**)&newNode);
}
// Sometimes we can still end up here with no geometry when gstreamer fails to create it for whatever reason. If that happens it can
// cause crashes.
QSGGeometryNode *node = static_cast<QSGGeometryNode*>(newNode);
if (node->geometry() == nullptr) {
qDebug() << "Creating default geom";
node->setGeometry(_createDefaultGeometry(r));
}
return newNode;
}
#endif
......@@ -19,6 +19,8 @@
#include <QtQuick/QQuickItem>
#include "VideoSurface.h"
class QSGGeometry;
class VideoItem : public QQuickItem
{
Q_OBJECT
......@@ -40,6 +42,8 @@ protected:
private:
#if defined(QGC_GST_STREAMING)
QSGGeometry* _createDefaultGeometry(QRectF& rectBound);
struct Private;
Private* const _data;
#endif
......
Markdown is supported
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