tests/examples/qmlsink: scope QApplication/Engine

So they are destroyed before gst_deinit() is run and the leaks tracer
doesn't show false-positives.

https://bugzilla.gnome.org/show_bug.cgi?id=775746
This commit is contained in:
Matthew Waters 2016-12-07 22:58:29 +11:00
parent 7400a57043
commit de41d74e6f

View file

@ -39,40 +39,43 @@ int main(int argc, char *argv[])
{ {
int ret; int ret;
QGuiApplication app(argc, argv);
gst_init (&argc, &argv); gst_init (&argc, &argv);
GstElement *pipeline = gst_pipeline_new (NULL); {
GstElement *src = gst_element_factory_make ("videotestsrc", NULL); QGuiApplication app(argc, argv);
GstElement *glupload = gst_element_factory_make ("glupload", NULL);
/* the plugin must be loaded before loading the qml file to register the
* GstGLVideoItem qml item */
GstElement *sink = gst_element_factory_make ("qmlglsink", NULL);
g_assert (src && glupload && sink); GstElement *pipeline = gst_pipeline_new (NULL);
GstElement *src = gst_element_factory_make ("videotestsrc", NULL);
GstElement *glupload = gst_element_factory_make ("glupload", NULL);
/* the plugin must be loaded before loading the qml file to register the
* GstGLVideoItem qml item */
GstElement *sink = gst_element_factory_make ("qmlglsink", NULL);
gst_bin_add_many (GST_BIN (pipeline), src, glupload, sink, NULL); g_assert (src && glupload && sink);
gst_element_link_many (src, glupload, sink, NULL);
QQmlApplicationEngine engine; gst_bin_add_many (GST_BIN (pipeline), src, glupload, sink, NULL);
engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); gst_element_link_many (src, glupload, sink, NULL);
QQuickItem *videoItem; QQmlApplicationEngine engine;
QQuickWindow *rootObject; engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
/* find and set the videoItem on the sink */ QQuickItem *videoItem;
rootObject = static_cast<QQuickWindow *> (engine.rootObjects().first()); QQuickWindow *rootObject;
videoItem = rootObject->findChild<QQuickItem *> ("videoItem");
g_assert (videoItem);
g_object_set(sink, "widget", videoItem, NULL);
rootObject->scheduleRenderJob (new SetPlaying (pipeline), /* find and set the videoItem on the sink */
QQuickWindow::BeforeSynchronizingStage); rootObject = static_cast<QQuickWindow *> (engine.rootObjects().first());
videoItem = rootObject->findChild<QQuickItem *> ("videoItem");
g_assert (videoItem);
g_object_set(sink, "widget", videoItem, NULL);
ret = app.exec(); rootObject->scheduleRenderJob (new SetPlaying (pipeline),
QQuickWindow::BeforeSynchronizingStage);
gst_element_set_state (pipeline, GST_STATE_NULL); ret = app.exec();
gst_object_unref (pipeline);
gst_element_set_state (pipeline, GST_STATE_NULL);
gst_object_unref (pipeline);
}
gst_deinit (); gst_deinit ();