commit-gnuradio
[Top][All Lists]
Advanced

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

[Commit-gnuradio] [gnuradio] 06/09: grc: fix handling of initially opene


From: git
Subject: [Commit-gnuradio] [gnuradio] 06/09: grc: fix handling of initially opened files
Date: Thu, 28 Jul 2016 21:44:00 +0000 (UTC)

This is an automated email from the git hooks/post-receive script.

jcorgan pushed a commit to branch maint
in repository gnuradio.

commit 14bee91d2e3123703c48172d35f36e1d37a1d9d9
Author: Sebastian Koslowski <address@hidden>
Date:   Tue Jul 26 11:30:29 2016 +0200

    grc: fix handling of initially opened files
    
    File paths passed as argument were never converted to absolute paths.
    So the generator defaulted to /tmp since the directory write check failed 
(empty dirname)
---
 grc/core/generator/Generator.py |  3 ++-
 grc/gui/ActionHandler.py        | 13 +++++--------
 2 files changed, 7 insertions(+), 9 deletions(-)

diff --git a/grc/core/generator/Generator.py b/grc/core/generator/Generator.py
index fb7a3af..3062440 100644
--- a/grc/core/generator/Generator.py
+++ b/grc/core/generator/Generator.py
@@ -74,13 +74,14 @@ class TopBlockGenerator(object):
         self._flow_graph = FlowGraphProxy(flow_graph)
         self._generate_options = 
self._flow_graph.get_option('generate_options')
         self._mode = TOP_BLOCK_FILE_MODE
-        dirname = self._dirname = os.path.dirname(file_path)
+        dirname = os.path.dirname(file_path)
         # Handle the case where the directory is read-only
         # In this case, use the system's temp directory
         if not os.access(dirname, os.W_OK):
             dirname = tempfile.gettempdir()
         filename = self._flow_graph.get_option('id') + '.py'
         self.file_path = os.path.join(dirname, filename)
+        self._dirname = dirname
 
     def get_file_path(self):
         return self.file_path
diff --git a/grc/gui/ActionHandler.py b/grc/gui/ActionHandler.py
index 11e81c4..f18fcea 100644
--- a/grc/gui/ActionHandler.py
+++ b/grc/gui/ActionHandler.py
@@ -66,7 +66,7 @@ class ActionHandler:
         Messages.register_messenger(self.main_window.add_console_line)
         Messages.send_init(platform)
         #initialize
-        self.init_file_paths = file_paths
+        self.init_file_paths = [os.path.abspath(file_path) for file_path in 
file_paths]
         self.init = False
         Actions.APPLICATION_INITIALIZE()
 
@@ -116,13 +116,10 @@ class ActionHandler:
         # Initialize/Quit
         ##################################################
         if action == Actions.APPLICATION_INITIALIZE:
-            if not self.init_file_paths:
-                self.init_file_paths = filter(os.path.exists, 
Preferences.get_open_files())
-            if not self.init_file_paths: self.init_file_paths = ['']
-            for file_path in self.init_file_paths:
-                if file_path: main.new_page(file_path) #load pages from file 
paths
-            if Preferences.file_open() in self.init_file_paths:
-                main.new_page(Preferences.file_open(), show=True)
+            file_path_to_show = Preferences.file_open()
+            for file_path in (self.init_file_paths or 
Preferences.get_open_files()):
+                if os.path.exists(file_path):
+                    main.new_page(file_path, show=file_path_to_show == 
file_path)
             if not self.get_page():
                 main.new_page()  # ensure that at least a blank page exists
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]