debug-viewer: Fix reload file action.
authorPhilippe Normand <philn@igalia.com>
Thu, 14 Jun 2018 17:01:54 +0000 (18:01 +0100)
committerPhilippe Normand <philn@igalia.com>
Thu, 14 Jun 2018 17:01:54 +0000 (18:01 +0100)
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

index 7701ba6..43ed9c0 100644 (file)
@@ -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: