Skip to content

Commit

Permalink
Merge pull request OpenShot#2864 from ferdnyc/check-null-paths
Browse files Browse the repository at this point in the history
Check for empty/null path strings
  • Loading branch information
DylanC authored Jul 18, 2019
2 parents 490e7ce + 77a3a68 commit 42311aa
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/windows/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,12 @@ def __init__(self):
self.timeline.Open()

# Default export path
recommended_path = recommended_path = os.path.join(info.HOME_PATH)
recommended_path = os.path.join(info.HOME_PATH)
if app.project.current_filepath:
recommended_path = os.path.dirname(app.project.current_filepath)

export_path = get_app().project.get(["export_path"])
if os.path.exists(export_path):
if export_path and os.path.exists(export_path):
# Use last selected export path
self.txtExportFolder.setText(export_path)
else:
Expand Down
26 changes: 13 additions & 13 deletions src/windows/main_window.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,11 @@ def open_project(self, file_path, clear_thumbnails=True):
app = get_app()
_ = app._tr # Get translation function

# First check for empty file_path (probably user cancellation)
if not file_path:
# Ignore the request
return

# Do we have unsaved changes?
if get_app().project.needs_save():
ret = QMessageBox.question(self, _("Unsaved Changes"), _("Save changes to project first?"), QMessageBox.Cancel | QMessageBox.No | QMessageBox.Yes)
Expand Down Expand Up @@ -505,19 +510,14 @@ def open_project(self, file_path, clear_thumbnails=True):

log.info("Loaded project {}".format(file_path))
else:
# If statement is required, as if the user hits "Cancel"
# on the "load file" dialog, it is interpreted as trying
# to open a file with a blank name. This could use some
# improvement.
if file_path != "":
# Prepare to use status bar
self.statusBar = QStatusBar()
self.setStatusBar(self.statusBar)

log.info("File not found at {}".format(file_path))
self.statusBar.showMessage(_("Project {} is missing (it may have been moved or deleted). It has been removed from the Recent Projects menu.".format(file_path)), 5000)
self.remove_recent_project(file_path)
self.load_recent_menu()
# Prepare to use status bar
self.statusBar = QStatusBar()
self.setStatusBar(self.statusBar)

log.info("File not found at {}".format(file_path))
self.statusBar.showMessage(_("Project {} is missing (it may have been moved or deleted). It has been removed from the Recent Projects menu.".format(file_path)), 5000)
self.remove_recent_project(file_path)
self.load_recent_menu()

except Exception as ex:
log.error("Couldn't open project {}".format(file_path))
Expand Down

0 comments on commit 42311aa

Please sign in to comment.