diff options
author | Matthew Waters <matthew@centricular.com> | 2016-12-07 22:58:29 +1100 |
---|---|---|
committer | Matthew Waters <matthew@centricular.com> | 2016-12-07 23:02:02 +1100 |
commit | 6ce990d24e2de375f6121c2da013d224aef11aa1 (patch) | |
tree | 4a3c3fa2fffc12090157afb773453eb9546d1fe4 /tests/examples | |
parent | 4450152a9e2a6508d99d26816fe05809ecff1669 (diff) | |
download | gstreamer-plugins-good-6ce990d24e2de375f6121c2da013d224aef11aa1.tar.gz |
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
Diffstat (limited to 'tests/examples')
-rw-r--r-- | tests/examples/qt/qmlsink/main.cpp | 51 |
1 files changed, 27 insertions, 24 deletions
diff --git a/tests/examples/qt/qmlsink/main.cpp b/tests/examples/qt/qmlsink/main.cpp index 2317b0541..a5cd5606b 100644 --- a/tests/examples/qt/qmlsink/main.cpp +++ b/tests/examples/qt/qmlsink/main.cpp @@ -39,40 +39,43 @@ int main(int argc, char *argv[]) { int ret; - QGuiApplication app(argc, argv); gst_init (&argc, &argv); - 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); + { + QGuiApplication app(argc, argv); - 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); - gst_element_link_many (src, glupload, sink, NULL); + g_assert (src && glupload && sink); - QQmlApplicationEngine engine; - engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); + gst_bin_add_many (GST_BIN (pipeline), src, glupload, sink, NULL); + gst_element_link_many (src, glupload, sink, NULL); - QQuickItem *videoItem; - QQuickWindow *rootObject; + QQmlApplicationEngine engine; + engine.load(QUrl(QStringLiteral("qrc:/main.qml"))); - /* find and set the videoItem on the sink */ - rootObject = static_cast<QQuickWindow *> (engine.rootObjects().first()); - videoItem = rootObject->findChild<QQuickItem *> ("videoItem"); - g_assert (videoItem); - g_object_set(sink, "widget", videoItem, NULL); + QQuickItem *videoItem; + QQuickWindow *rootObject; - rootObject->scheduleRenderJob (new SetPlaying (pipeline), - QQuickWindow::BeforeSynchronizingStage); + /* find and set the videoItem on the sink */ + 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); - gst_object_unref (pipeline); + ret = app.exec(); + + gst_element_set_state (pipeline, GST_STATE_NULL); + gst_object_unref (pipeline); + } gst_deinit (); |