summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSebastian Koslowski <koslowski@kit.edu>2016-07-26 11:30:29 +0200
committerSebastian Koslowski <koslowski@kit.edu>2016-07-26 11:30:29 +0200
commit14bee91d2e3123703c48172d35f36e1d37a1d9d9 (patch)
tree2a81748ea66f0127109e78cdc4da0f58bd7d52d2
parent2dedafd6df9ed0d73003fe9faa57d227b9a4cbb6 (diff)
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)
-rw-r--r--grc/core/generator/Generator.py3
-rw-r--r--grc/gui/ActionHandler.py13
2 files changed, 7 insertions, 9 deletions
diff --git a/grc/core/generator/Generator.py b/grc/core/generator/Generator.py
index fb7a3afb99..3062440814 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 11e81c4613..f18fcea3e1 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