Fix some surface assignment errors.
On destruction and changing sources, make sure we don't clobber the surface property if it's been changed. Change-Id: I3080b98a547911543a391c8bc040792d260782fd Reviewed-by: Dmytro Poplavskiy <dmytro.poplavskiy@nokia.com>
This commit is contained in:
committed by
Qt by Nokia
parent
bad94a5329
commit
88431b2841
@@ -178,6 +178,11 @@ QDeclarativeVideoOutput::QDeclarativeVideoOutput(QQuickItem *parent) :
|
|||||||
|
|
||||||
QDeclarativeVideoOutput::~QDeclarativeVideoOutput()
|
QDeclarativeVideoOutput::~QDeclarativeVideoOutput()
|
||||||
{
|
{
|
||||||
|
if (m_source && m_sourceType == VideoSurfaceSource) {
|
||||||
|
if (m_source.data()->property("videoSurface").value<QAbstractVideoSurface*>() == m_surface)
|
||||||
|
m_source.data()->setProperty("videoSurface", QVariant::fromValue<QAbstractVideoSurface*>(0));
|
||||||
|
}
|
||||||
|
|
||||||
m_source.clear();
|
m_source.clear();
|
||||||
_q_updateMediaObject();
|
_q_updateMediaObject();
|
||||||
delete m_surface;
|
delete m_surface;
|
||||||
@@ -209,8 +214,10 @@ void QDeclarativeVideoOutput::setSource(QObject *source)
|
|||||||
if (m_source && m_sourceType == MediaObjectSource)
|
if (m_source && m_sourceType == MediaObjectSource)
|
||||||
disconnect(0, m_source.data(), SLOT(_q_updateMediaObject()));
|
disconnect(0, m_source.data(), SLOT(_q_updateMediaObject()));
|
||||||
|
|
||||||
if (m_source && m_sourceType == VideoSurfaceSource)
|
if (m_source && m_sourceType == VideoSurfaceSource) {
|
||||||
m_source.data()->setProperty("videoSurface", QVariant::fromValue<QAbstractVideoSurface*>(0));
|
if (m_source.data()->property("videoSurface").value<QAbstractVideoSurface*>() == m_surface)
|
||||||
|
m_source.data()->setProperty("videoSurface", QVariant::fromValue<QAbstractVideoSurface*>(0));
|
||||||
|
}
|
||||||
|
|
||||||
m_surface->stop();
|
m_surface->stop();
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,9 @@ public:
|
|||||||
}
|
}
|
||||||
void setVideoSurface(QAbstractVideoSurface *surface)
|
void setVideoSurface(QAbstractVideoSurface *surface)
|
||||||
{
|
{
|
||||||
|
if (m_surface != surface && m_surface && m_surface->isActive()) {
|
||||||
|
m_surface->stop();
|
||||||
|
}
|
||||||
m_surface = surface;
|
m_surface = surface;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -133,6 +136,9 @@ private slots:
|
|||||||
void mappingRect();
|
void mappingRect();
|
||||||
void mappingRect_data();
|
void mappingRect_data();
|
||||||
|
|
||||||
|
// XXX May be worth adding tests that the surface activeChanged signals are sent appropriately
|
||||||
|
// to holder?
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QDeclarativeEngine m_engine;
|
QDeclarativeEngine m_engine;
|
||||||
QByteArray m_plainQML;
|
QByteArray m_plainQML;
|
||||||
@@ -293,7 +299,6 @@ void tst_QDeclarativeVideoOutput::surfaceSource()
|
|||||||
delete videoOutput;
|
delete videoOutput;
|
||||||
|
|
||||||
// This should clear the surface
|
// This should clear the surface
|
||||||
QEXPECT_FAIL("", "Surface not cleared on destruction", Continue);
|
|
||||||
QCOMPARE(holder.videoSurface(), static_cast<QAbstractVideoSurface*>(0));
|
QCOMPARE(holder.videoSurface(), static_cast<QAbstractVideoSurface*>(0));
|
||||||
|
|
||||||
// Also, creating two sources, setting them in order, and destroying the first
|
// Also, creating two sources, setting them in order, and destroying the first
|
||||||
@@ -324,9 +329,22 @@ void tst_QDeclarativeVideoOutput::surfaceSource()
|
|||||||
QCOMPARE(holder.videoSurface(), static_cast<QAbstractVideoSurface*>(0));
|
QCOMPARE(holder.videoSurface(), static_cast<QAbstractVideoSurface*>(0));
|
||||||
QVERIFY(holder2.videoSurface() != 0);
|
QVERIFY(holder2.videoSurface() != 0);
|
||||||
|
|
||||||
// XXX May be worth adding tests that the surface activeChanged signals are sent appropriately
|
// Finally a combination - set the same source to two things, then assign a new source
|
||||||
// to holder?
|
// to the first output - should not reset the first source
|
||||||
|
videoOutput = component.create();
|
||||||
|
videoOutput->setProperty("source", QVariant::fromValue(static_cast<QObject*>(&holder2)));
|
||||||
|
|
||||||
|
// Both vo and vo2 were pointed to holder2 - setting vo2 should not clear holder2
|
||||||
|
QVERIFY(holder2.videoSurface() != 0);
|
||||||
|
QVERIFY(holder.videoSurface() == 0);
|
||||||
|
videoOutput2->setProperty("source", QVariant::fromValue(static_cast<QObject*>(&holder)));
|
||||||
|
QVERIFY(holder2.videoSurface() != 0);
|
||||||
|
QVERIFY(holder.videoSurface() != 0);
|
||||||
|
|
||||||
|
// They should also be independent
|
||||||
|
QVERIFY(holder.videoSurface() != holder2.videoSurface());
|
||||||
|
|
||||||
|
delete videoOutput;
|
||||||
delete videoOutput2;
|
delete videoOutput2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user