[shotwell] Don't crash when videos are not readable



commit f889faa0cf02b029520446b5b270271df9e8f469
Author: Jens Georg <mail jensge org>
Date:   Sat Jun 26 12:33:22 2021 +0200

    Don't crash when videos are not readable

 src/video-support/VideoReader.vala | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)
---
diff --git a/src/video-support/VideoReader.vala b/src/video-support/VideoReader.vala
index b7e855d7..f6fedd7b 100644
--- a/src/video-support/VideoReader.vala
+++ b/src/video-support/VideoReader.vala
@@ -192,16 +192,25 @@ public class VideoReader {
             });
 
             Bytes stdout_buf = null;
+            Bytes stderr_buf = null;
 
             var process = new GLib.Subprocess(GLib.SubprocessFlags.STDOUT_PIPE, 
AppDirs.get_metadata_helper().get_path(), file.get_uri());
-            process.communicate(null, cancellable, out stdout_buf, null);
-            string[] lines = ((string) stdout_buf.get_data()).split("\n");
-
-            var old = Intl.setlocale(GLib.LocaleCategory.NUMERIC, "C");
-            clip_duration = double.parse(lines[0]);
-            Intl.setlocale(GLib.LocaleCategory.NUMERIC, old);
-            if (lines[1] != "none")
-                timestamp = new DateTime.from_iso8601(lines[1], null);
+            var result = process.communicate(null, cancellable, out stdout_buf, out stderr_buf);
+            if (result && process.get_exit_status () == 0 && stdout_buf != null && stdout_buf.get_size() > 
0) {
+                string[] lines = ((string) stdout_buf.get_data()).split("\n");
+
+                var old = Intl.setlocale(GLib.LocaleCategory.NUMERIC, "C");
+                clip_duration = double.parse(lines[0]);
+                Intl.setlocale(GLib.LocaleCategory.NUMERIC, old);
+                if (lines[1] != "none")
+                    timestamp = new DateTime.from_iso8601(lines[1], null);
+            } else {
+                string message = "";
+                if (stderr != null && stderr_buf.get_size() > 0) {
+                    message = (string) stderr_buf.get_data();
+                }
+                warning ("External Metadata helper failed");
+            }
         } catch (Error e) {
             debug("Video read error: %s", e.message);
             throw new VideoError.CONTENTS("GStreamer couldn't extract clip information: %s"


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]