save_changes
if $filename
- ios = File.open($filename, "w")
- $xmldoc.write(ios, 0)
- ios.close
+ begin
+ begin
+ ios = File.open($filename, "w")
+ $xmldoc.write(ios, 0)
+ ios.close
+ rescue Iconv::IllegalSequence
+ #- user might have entered text which cannot be encoded in his default encoding. retry in UTF-8.
+ if ! ios.nil? && ! ios.closed?
+ ios.close
+ end
+ $xmldoc.xml_decl.encoding = 'UTF-8'
+ ios = File.open($filename, "w")
+ $xmldoc.write(ios, 0)
+ ios.close
+ end
+ return true
+ rescue Exception
+ return false
+ end
end
end
def save_current_file_user
save_tempfilename = $filename
$filename = $orig_filename
- save_current_file
+ if ! save_current_file
+ show_popup($main_window, utf8(_("Save failed! Try another location/name.")))
+ $filename = save_tempfilename
+ return
+ end
$modified = false
$generated_outofline = false
$filename = save_tempfilename
dialog.run { |response|
dialog.destroy
if response == Gtk::Dialog::RESPONSE_YES
- save_current_file_user
+ if ! save_current_file_user
+ return ask_save_modifications(msg1, msg2, options)
+ end
else
#- if we have generated an album but won't save modifications, we must remove
#- already-generated markers in original file
fc.filename = $orig_filename
if fc.run == Gtk::Dialog::RESPONSE_ACCEPT
$orig_filename = fc.filename
- save_current_file_user
+ if ! save_current_file_user
+ fc.destroy
+ return save_as_do
+ end
$config['last-opens'] ||= []
$config['last-opens'] << $orig_filename
end