Commit 079333b3d7332a3e943da7219e8d2ac9b412b731
1 parent
ce4b93a1
Exists in
master
Showing error message when trying to save project inside a folder without write permission
Showing
1 changed file
with
16 additions
and
7 deletions
Show diff stats
invesalius/control.py
... | ... | @@ -256,10 +256,7 @@ class Controller(): |
256 | 256 | if saveas or session.temp_item: |
257 | 257 | proj = prj.Project() |
258 | 258 | filepath, compress = dialog.ShowSaveAsProjectDialog(proj.name) |
259 | - if filepath: | |
260 | - #session.RemoveTemp() | |
261 | - session.OpenProject(filepath) | |
262 | - else: | |
259 | + if not filepath: | |
263 | 260 | return |
264 | 261 | else: |
265 | 262 | proj = prj.Project() |
... | ... | @@ -364,7 +361,6 @@ class Controller(): |
364 | 361 | session = ses.Session() |
365 | 362 | if path: |
366 | 363 | dirpath, filename = os.path.split(path) |
367 | - session.SaveProject((dirpath, filename)) | |
368 | 364 | else: |
369 | 365 | dirpath, filename = session.project_path |
370 | 366 | |
... | ... | @@ -372,9 +368,22 @@ class Controller(): |
372 | 368 | filename = utils.decode(filename, const.FS_ENCODE) |
373 | 369 | |
374 | 370 | proj = prj.Project() |
375 | - prj.Project().SavePlistProject(dirpath, filename, compress) | |
371 | + try: | |
372 | + prj.Project().SavePlistProject(dirpath, filename, compress) | |
373 | + except PermissionError as err: | |
374 | + if wx.GetApp() is None: | |
375 | + print("Error: Permission denied, you don't have permission to write at {}".format(dirpath)) | |
376 | + else: | |
377 | + dlg = dialogs.ErrorMessageBox( | |
378 | + None, | |
379 | + "Save project error", | |
380 | + "It was not possible to save because you don't have permission to write at {}\n{}".format(dirpath, err) | |
381 | + ) | |
382 | + dlg.ShowModal() | |
383 | + dlg.Destroy() | |
384 | + else: | |
385 | + session.SaveProject((dirpath, filename)) | |
376 | 386 | |
377 | - session.SaveProject() | |
378 | 387 | Publisher.sendMessage('End busy cursor') |
379 | 388 | |
380 | 389 | def CloseProject(self): | ... | ... |