From c00429a91714b6930e6c43ae5d80eeb0b0af42b9 Mon Sep 17 00:00:00 2001 From: Thibault Saunier Date: Wed, 13 Nov 2024 18:18:30 -0300 Subject: [PATCH] ges: launch: Fix usage of save-only after loading a project We need to wait for the project to be loaded before saving the file and quit Fixes https://gitlab.freedesktop.org/gstreamer/gstreamer/-/issues/4003 Part-of: --- .../gst-editing-services/tools/ges-launcher.c | 19 +++++++++++++++---- .../gst-editing-services/tools/ges-validate.c | 14 ++++++++++---- 2 files changed, 25 insertions(+), 8 deletions(-) diff --git a/subprojects/gst-editing-services/tools/ges-launcher.c b/subprojects/gst-editing-services/tools/ges-launcher.c index 9dfa8d802e..7a7e5fef79 100644 --- a/subprojects/gst-editing-services/tools/ges-launcher.c +++ b/subprojects/gst-editing-services/tools/ges-launcher.c @@ -880,14 +880,15 @@ _project_loaded_cb (GESProject * project, GESTimeline * timeline, GESLauncherParsedOptions *opts = &self->priv->parsed_options; GST_INFO ("Project loaded, playing it"); - if (opts->save_path) { + if (opts->save_path || opts->save_only_path) { gchar *uri; GError *error = NULL; + gchar *save_path = opts->save_path ? opts->save_path : opts->save_only_path; if (g_strcmp0 (opts->save_path, "+r") == 0) { uri = ges_project_get_uri (project); - } else if (!(uri = ensure_uri (opts->save_path))) { - g_error ("couldn't create uri for '%s", opts->save_path); + } else if (!(uri = ensure_uri (save_path))) { + g_error ("couldn't create uri for '%s", save_path); self->priv->seenerrors = TRUE; g_application_quit (G_APPLICATION (self)); @@ -903,6 +904,12 @@ _project_loaded_cb (GESProject * project, GESTimeline * timeline, g_error_free (error); g_application_quit (G_APPLICATION (self)); } + + if (opts->save_only_path) { + g_application_quit (G_APPLICATION (self)); + + return; + } } project_uri = ges_project_get_uri (project); @@ -1715,8 +1722,12 @@ _startup (GApplication * application) if (!_create_pipeline (self, opts->sanitized_timeline)) goto failure; - if (opts->save_only_path) + if (opts->save_only_path) { + if (opts->load_path) { + g_application_hold (G_APPLICATION (self)); + } goto done; + } if (!_set_playback_details (self)) goto failure; diff --git a/subprojects/gst-editing-services/tools/ges-validate.c b/subprojects/gst-editing-services/tools/ges-validate.c index 692c9cf438..fac76c8c23 100644 --- a/subprojects/gst-editing-services/tools/ges-validate.c +++ b/subprojects/gst-editing-services/tools/ges-validate.c @@ -130,6 +130,7 @@ ges_validate_activate (GstPipeline * pipeline, GESLauncher * launcher, g_object_set_data (G_OBJECT (pipeline), "pposition-id", GUINT_TO_POINTER (g_timeout_add (200, (GSourceFunc) _print_position, pipeline))); + return TRUE; } @@ -214,11 +215,16 @@ ges_validate_clean (GstPipeline * pipeline) GstValidateRunner *runner = g_object_get_data (G_OBJECT (pipeline), RUNNER_ON_PIPELINE); - if (runner) + if (runner) { res = gst_validate_runner_exit (runner, TRUE); - else - g_source_remove (GPOINTER_TO_INT (g_object_get_data (G_OBJECT (pipeline), - "pposition-id"))); + } else { + gpointer pposition = + g_object_get_data (G_OBJECT (pipeline), "pposition-id"); + + if (pposition) { + g_source_remove (GPOINTER_TO_INT (pposition)); + } + } gst_object_unref (pipeline); if (runner)