changeset 26394:6323979ee312 stable

Optionally, ignore data loss when saving .m file (bug #55364). * file-editor-tab.cc (check_valid_codec): Return codec if user chooses to ignore data loss due to un-encodable characters.
author Markus Mützel <markus.muetzel@gmx.de>
date Wed, 02 Jan 2019 18:03:09 +0100
parents 1e3c42fbf4d3
children 5daa7fff9c69 70b604e62237
files libgui/src/m-editor/file-editor-tab.cc
diffstat 1 files changed, 14 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Wed Jan 02 16:41:13 2019 +0100
+++ b/libgui/src/m-editor/file-editor-tab.cc	Wed Jan 02 18:03:09 2019 +0100
@@ -2349,14 +2349,20 @@
 
     if (! can_encode)
       {
-        QMessageBox::critical (nullptr,
-                               tr ("Octave Editor"),
-                               tr ("The current editor contents can not be encoded\n"
-                                   "with the selected encoding %1.\n"
-                                   "Using it would result in data loss!\n\n"
-                                   "Please select another one!").arg (_encoding));
-
-        return nullptr;
+        QMessageBox::StandardButton pressed_button
+          = QMessageBox::critical (nullptr,
+                                   tr ("Octave Editor"),
+                                   tr ("The current editor contents can not be encoded\n"
+                                       "with the selected encoding %1.\n"
+                                       "Using it would result in data loss!\n\n"
+                                       "Please select another one!").arg (_encoding),
+                                   QMessageBox::Cancel | QMessageBox::Ignore,
+                                   QMessageBox::Cancel);
+
+        if (pressed_button == QMessageBox::Ignore)
+          return codec;
+        else
+          return nullptr;
       }
 
     return codec;