Fix gstreamer camera when env var QT_NO_GLIB is set
It would fall into the glib code path because it was only checking if QT_NO_GLIB was defined, but ignoring the env variable. gst_bus_add_watch_full only works with a glib event loop running. Task-Id: QTBUG-51607 Change-Id: I726afd5d6e114eacea6e5bc71e7a6e2d1c5bbd74 Reviewed-by: Yoann Lopes <yoann.lopes@theqtcompany.com>
This commit is contained in:
committed by
Yoann Lopes
parent
176179fb32
commit
d2d0d93f76
@@ -35,6 +35,8 @@
|
|||||||
#include <QtCore/qtimer.h>
|
#include <QtCore/qtimer.h>
|
||||||
#include <QtCore/qmutex.h>
|
#include <QtCore/qmutex.h>
|
||||||
#include <QtCore/qlist.h>
|
#include <QtCore/qlist.h>
|
||||||
|
#include <QtCore/qabstracteventdispatcher.h>
|
||||||
|
#include <QtCore/qcoreapplication.h>
|
||||||
|
|
||||||
#include "qgstreamerbushelper_p.h"
|
#include "qgstreamerbushelper_p.h"
|
||||||
|
|
||||||
@@ -47,31 +49,31 @@ class QGstreamerBusHelperPrivate : public QObject
|
|||||||
public:
|
public:
|
||||||
QGstreamerBusHelperPrivate(QGstreamerBusHelper *parent, GstBus* bus) :
|
QGstreamerBusHelperPrivate(QGstreamerBusHelper *parent, GstBus* bus) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
|
m_tag(0),
|
||||||
m_bus(bus),
|
m_bus(bus),
|
||||||
m_helper(parent)
|
m_helper(parent),
|
||||||
|
m_intervalTimer(nullptr)
|
||||||
{
|
{
|
||||||
#ifdef QT_NO_GLIB
|
// glib event loop can be disabled either by env variable or QT_NO_GLIB define, so check the dispacher
|
||||||
Q_UNUSED(bus);
|
QAbstractEventDispatcher *dispatcher = QCoreApplication::eventDispatcher();
|
||||||
|
const bool hasGlib = dispatcher && dispatcher->inherits("QEventDispatcherGlib");
|
||||||
m_intervalTimer = new QTimer(this);
|
if (!hasGlib) {
|
||||||
m_intervalTimer->setInterval(250);
|
m_intervalTimer = new QTimer(this);
|
||||||
|
m_intervalTimer->setInterval(250);
|
||||||
connect(m_intervalTimer, SIGNAL(timeout()), SLOT(interval()));
|
connect(m_intervalTimer, SIGNAL(timeout()), SLOT(interval()));
|
||||||
m_intervalTimer->start();
|
m_intervalTimer->start();
|
||||||
#else
|
} else {
|
||||||
m_tag = gst_bus_add_watch_full(bus, 0, busCallback, this, NULL);
|
m_tag = gst_bus_add_watch_full(bus, G_PRIORITY_DEFAULT, busCallback, this, NULL);
|
||||||
#endif
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
~QGstreamerBusHelperPrivate()
|
~QGstreamerBusHelperPrivate()
|
||||||
{
|
{
|
||||||
m_helper = 0;
|
m_helper = 0;
|
||||||
#ifdef QT_NO_GLIB
|
delete m_intervalTimer;
|
||||||
m_intervalTimer->stop();
|
|
||||||
#else
|
if (m_tag)
|
||||||
g_source_remove(m_tag);
|
g_source_remove(m_tag);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
GstBus* bus() const { return m_bus; }
|
GstBus* bus() const { return m_bus; }
|
||||||
@@ -110,9 +112,7 @@ private:
|
|||||||
guint m_tag;
|
guint m_tag;
|
||||||
GstBus* m_bus;
|
GstBus* m_bus;
|
||||||
QGstreamerBusHelper* m_helper;
|
QGstreamerBusHelper* m_helper;
|
||||||
#ifdef QT_NO_GLIB
|
|
||||||
QTimer* m_intervalTimer;
|
QTimer* m_intervalTimer;
|
||||||
#endif
|
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void doProcessMessage(const QGstreamerMessage& msg)
|
void doProcessMessage(const QGstreamerMessage& msg)
|
||||||
|
|||||||
Reference in New Issue
Block a user