From 49ed844f79806c3de9457feda4cbd68c08254bcb Mon Sep 17 00:00:00 2001 From: Ales Erjavec Date: Fri, 28 May 2021 14:58:02 +0200 Subject: [PATCH] canvasmain: Always use absolute path for 'basedir' Current working directory could arguably change during a run so this is a good idea. --- orangecanvas/application/canvasmain.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/orangecanvas/application/canvasmain.py b/orangecanvas/application/canvasmain.py index 9ebbcecba..704dc0e3a 100644 --- a/orangecanvas/application/canvasmain.py +++ b/orangecanvas/application/canvasmain.py @@ -1234,7 +1234,8 @@ def new_scheme_from_contents_and_path( workflow: Optional[Scheme] """ new_scheme = config.workflow_constructor(parent=self) - new_scheme.set_runtime_env("basedir", os.path.dirname(path)) + new_scheme.set_runtime_env( + "basedir", os.path.abspath(os.path.dirname(path))) errors = [] # type: List[Exception] try: new_scheme.load_from( @@ -1508,7 +1509,7 @@ def save_scheme_to(self, scheme, filename): # existing scheme file if `scheme.save_to` raises an error. buffer = io.BytesIO() try: - scheme.set_runtime_env("basedir", dirname) + scheme.set_runtime_env("basedir", os.path.abspath(dirname)) scheme.save_to(buffer, pretty=True, pickle_fallback=True) except Exception: log.error("Error saving %r to %r", scheme, filename, exc_info=True)