mirror of
https://github.com/Orama-Interactive/Pixelorama.git
synced 2025-01-31 07:29:49 +00:00
If "Save & Exit" is pressed while quitting, don't close the software if the project failed to save (#920)
* Dont quit if project failed to save * Formatting * spell Formatting
This commit is contained in:
parent
fd5adef1d9
commit
90dd325b08
|
@ -208,7 +208,7 @@ func open_pxo_file(path: String, untitled_backup := false, replace_empty := true
|
||||||
|
|
||||||
func save_pxo_file(
|
func save_pxo_file(
|
||||||
path: String, autosave: bool, use_zstd := true, project := Global.current_project
|
path: String, autosave: bool, use_zstd := true, project := Global.current_project
|
||||||
) -> void:
|
) -> bool:
|
||||||
if !autosave:
|
if !autosave:
|
||||||
project.name = path.get_file()
|
project.name = path.get_file()
|
||||||
var serialized_data := project.serialize()
|
var serialized_data := project.serialize()
|
||||||
|
@ -218,7 +218,7 @@ func save_pxo_file(
|
||||||
)
|
)
|
||||||
Global.error_dialog.popup_centered()
|
Global.error_dialog.popup_centered()
|
||||||
Global.dialog_open(true)
|
Global.dialog_open(true)
|
||||||
return
|
return false
|
||||||
var to_save := JSON.stringify(serialized_data)
|
var to_save := JSON.stringify(serialized_data)
|
||||||
if !to_save:
|
if !to_save:
|
||||||
Global.error_dialog.set_text(
|
Global.error_dialog.set_text(
|
||||||
|
@ -226,7 +226,7 @@ func save_pxo_file(
|
||||||
)
|
)
|
||||||
Global.error_dialog.popup_centered()
|
Global.error_dialog.popup_centered()
|
||||||
Global.dialog_open(true)
|
Global.dialog_open(true)
|
||||||
return
|
return false
|
||||||
|
|
||||||
# Check if a file with the same name exists. If it does, rename the new file temporarily.
|
# Check if a file with the same name exists. If it does, rename the new file temporarily.
|
||||||
# Needed in case of a crash, so that the old file won't be replaced with an empty one.
|
# Needed in case of a crash, so that the old file won't be replaced with an empty one.
|
||||||
|
@ -244,14 +244,15 @@ func save_pxo_file(
|
||||||
var err := FileAccess.get_open_error()
|
var err := FileAccess.get_open_error()
|
||||||
if err != OK:
|
if err != OK:
|
||||||
if temp_path.is_valid_filename():
|
if temp_path.is_valid_filename():
|
||||||
return
|
return false
|
||||||
Global.error_dialog.set_text(
|
Global.error_dialog.set_text(
|
||||||
tr("File failed to save. Error code %s (%s)") % [err, error_string(err)]
|
tr("File failed to save. Error code %s (%s)") % [err, error_string(err)]
|
||||||
)
|
)
|
||||||
Global.error_dialog.popup_centered()
|
Global.error_dialog.popup_centered()
|
||||||
Global.dialog_open(true)
|
Global.dialog_open(true)
|
||||||
|
if file: # this would be null if we attempt to save filenames such as "//\\||.pxo"
|
||||||
file.close()
|
file.close()
|
||||||
return
|
return false
|
||||||
|
|
||||||
if !autosave:
|
if !autosave:
|
||||||
current_save_paths[Global.current_project_index] = path
|
current_save_paths[Global.current_project_index] = path
|
||||||
|
@ -302,6 +303,7 @@ func save_pxo_file(
|
||||||
)
|
)
|
||||||
|
|
||||||
save_project_to_recent_list(path)
|
save_project_to_recent_list(path)
|
||||||
|
return true
|
||||||
|
|
||||||
|
|
||||||
func open_image_as_new_tab(path: String, image: Image) -> void:
|
func open_image_as_new_tab(path: String, image: Image) -> void:
|
||||||
|
|
|
@ -284,7 +284,8 @@ func save_project(path: String) -> void:
|
||||||
var zstd: bool = (
|
var zstd: bool = (
|
||||||
Global.save_sprites_dialog.get_vbox().get_node("ZSTDCompression").button_pressed
|
Global.save_sprites_dialog.get_vbox().get_node("ZSTDCompression").button_pressed
|
||||||
)
|
)
|
||||||
OpenSave.save_pxo_file(path, false, zstd)
|
var success = OpenSave.save_pxo_file(path, false, zstd)
|
||||||
|
if success:
|
||||||
Global.open_sprites_dialog.current_dir = path.get_base_dir()
|
Global.open_sprites_dialog.current_dir = path.get_base_dir()
|
||||||
Global.config_cache.set_value("data", "current_dir", path.get_base_dir())
|
Global.config_cache.set_value("data", "current_dir", path.get_base_dir())
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue