From 7e2200d8891050f2f54e5a8b2c5c43a938a67010 Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Thu, 14 Jun 2018 18:01:54 +0100 Subject: [PATCH] debug-viewer: Fix reload file action. Copy the log file only we're loading a file different from the previous file. The previous version of this code was broken because the existing tmpfile was removed from disk before being copied to a new temporary file. --- debug-viewer/GstDebugViewer/GUI/window.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/debug-viewer/GstDebugViewer/GUI/window.py b/debug-viewer/GstDebugViewer/GUI/window.py index 7701ba6418..43ed9c0810 100644 --- a/debug-viewer/GstDebugViewer/GUI/window.py +++ b/debug-viewer/GstDebugViewer/GUI/window.py @@ -941,18 +941,19 @@ 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: self.dispatcher.cancel() self.dispatcher = None self.log_file = None + self.tmpfile = None self.actions.groups["RowActions"].props.sensitive = False else: - self.tmpfile = tempfile.NamedTemporaryFile() - shutil.copyfile(filename, self.tmpfile.name) - filename = self.tmpfile.name + if self.tmpfile and filename != self.tmpfile.name: + self.tmpfile = tempfile.NamedTemporaryFile() + shutil.copyfile(filename, self.tmpfile.name) + filename = self.tmpfile.name self.logger.debug("setting log file %r", filename) try: