Browse Source

Merge pull request #7584 from DonLakeFlyer/VideoItemCrash

Video item crash
QGC4.4
Don Gagne 6 years ago committed by GitHub
parent
commit
407c86487c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      ChangeLog.md
  2. 26
      src/VideoStreaming/VideoItem.cc
  3. 4
      src/VideoStreaming/VideoItem.h

1
ChangeLog.md

@ -9,6 +9,7 @@ Note: This file only contains high level features or important fixes. @@ -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

26
src/VideoStreaming/VideoItem.cc

@ -78,6 +78,17 @@ void VideoItem::setSurface(VideoSurface *surface) @@ -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*) @@ -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

4
src/VideoStreaming/VideoItem.h

@ -19,6 +19,8 @@ @@ -19,6 +19,8 @@
#include <QtQuick/QQuickItem>
#include "VideoSurface.h"
class QSGGeometry;
class VideoItem : public QQuickItem
{
Q_OBJECT
@ -40,6 +42,8 @@ protected: @@ -40,6 +42,8 @@ protected:
private:
#if defined(QGC_GST_STREAMING)
QSGGeometry* _createDefaultGeometry(QRectF& rectBound);
struct Private;
Private* const _data;
#endif

Loading…
Cancel
Save