summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThibault Saunier <tsaunier@igalia.com>2018-04-18 09:34:57 -0300
committerThibault Saunier <tsaunier@igalia.com>2018-04-18 09:34:59 -0300
commitad886c288c9e352000bcb3485360921b4d567108 (patch)
tree4edad6a05de64a3d20d8a9e88f64aab4a68e9061
parent771f27b44b0cce9793227c3b27a0298bb5e310a3 (diff)
debug-viewer: Copy log files in temporaries before using them
They are mmap'ed and it gets wrong if the file is changed. There is high probablility the user will generate new logs while inspecting some logs in the same file
-rw-r--r--debug-viewer/GstDebugViewer/GUI/window.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/debug-viewer/GstDebugViewer/GUI/window.py b/debug-viewer/GstDebugViewer/GUI/window.py
index e439823..6f67de6 100644
--- a/debug-viewer/GstDebugViewer/GUI/window.py
+++ b/debug-viewer/GstDebugViewer/GUI/window.py
@@ -20,6 +20,9 @@
"""GStreamer Debug Viewer GUI module."""
import os.path
+import tempfile
+import shutil
+
from bisect import bisect_right, bisect_left
import logging
@@ -231,6 +234,7 @@ class Window (object):
self.logger = logging.getLogger("ui.window")
self.app = app
+ self.tmpfile = None
self.dispatcher = None
self.info_widget = None
self.progress_dialog = None
@@ -937,6 +941,7 @@ class Window (object):
if self.log_file is not None:
for feature in self.features:
feature.handle_detach_log_file(self, self.log_file)
+ self.tmpfile = None
if filename is None:
if self.dispatcher is not None:
@@ -945,6 +950,9 @@ class Window (object):
self.log_file = None
self.actions.groups["RowActions"].props.sensitive = False
else:
+ self.tmpfile = tempfile.NamedTemporaryFile()
+ shutil.copyfile(filename, self.tmpfile.name)
+ filename = self.tmpfile.name
self.logger.debug("setting log file %r", filename)
try: