mirror of
https://github.com/olivierkes/manuskript.git
synced 2024-05-10 07:52:35 +12:00
Fixes: Crash when permissions don't allow saving #138
This commit is contained in:
parent
c89dd460da
commit
f2aa9abc85
|
@ -16,9 +16,9 @@ def saveProject(version=None):
|
|||
# return
|
||||
|
||||
if version == 0:
|
||||
v0.saveProject()
|
||||
return v0.saveProject()
|
||||
else:
|
||||
v1.saveProject()
|
||||
return v1.saveProject()
|
||||
|
||||
|
||||
def clearSaveCache():
|
||||
|
|
|
@ -103,7 +103,7 @@ def saveProject(zip=None):
|
|||
collaborative work, versionning, or third-party editing.
|
||||
@param zip: if True, saves as a single file. If False, saves as plain-text. If None, tries to determine based on
|
||||
settings.
|
||||
@return: Nothing
|
||||
@return: True if successful, False otherwise.
|
||||
"""
|
||||
if zip is None:
|
||||
zip = settings.saveToZip
|
||||
|
@ -295,6 +295,10 @@ def saveProject(zip=None):
|
|||
files.append(("settings.txt", settings.save(protocol=0)))
|
||||
|
||||
project = mw.currentProject
|
||||
|
||||
if not os.access(project, os.W_OK):
|
||||
print("Error: you don't have write access to save this project there.")
|
||||
return False
|
||||
|
||||
####################################################################################################################
|
||||
# Save to zip
|
||||
|
@ -311,6 +315,7 @@ def saveProject(zip=None):
|
|||
zf.writestr(filename, content, compress_type=compression)
|
||||
|
||||
zf.close()
|
||||
return True
|
||||
|
||||
####################################################################################################################
|
||||
# Save to plain text
|
||||
|
@ -403,6 +408,8 @@ def saveProject(zip=None):
|
|||
# Write the project file's content
|
||||
with open(project, "w", encoding='utf8') as f:
|
||||
f.write("1") # Format number
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def addWorldItem(root, mdl, parent=QModelIndex()):
|
||||
|
|
|
@ -502,13 +502,17 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
|||
self.currentProject = projectName
|
||||
QSettings().setValue("lastProject", projectName)
|
||||
|
||||
loadSave.saveProject() # version=0
|
||||
r = loadSave.saveProject() # version=0
|
||||
self.saveTimerNoChanges.stop()
|
||||
|
||||
if r:
|
||||
feedback = self.tr("Project {} saved.").format(self.currentProject)
|
||||
else:
|
||||
feedback = self.tr("WARNING: Project {} not saved.").format(self.currentProject)
|
||||
|
||||
# Giving some feedback
|
||||
print(self.tr("Project {} saved.").format(self.currentProject))
|
||||
self.statusBar().showMessage(
|
||||
self.tr("Project {} saved.").format(self.currentProject), 5000)
|
||||
print(feedback)
|
||||
self.statusBar().showMessage(feedback, 5000)
|
||||
|
||||
def loadEmptyDatas(self):
|
||||
self.mdlFlatData = QStandardItemModel(self)
|
||||
|
|
Loading…
Reference in a new issue