changeset 24647:41a87a2a8d38

check current codec if it is valid before trying to use it (bug #52985) * file-editor-tab.cc (check_valid_codec): check for valdi codec pointer before trying to encode the current text with it.
author Torsten <mttl@mailbox.org>
date Sun, 28 Jan 2018 10:05:45 +0100
parents d36e1f768bfa
children 1f1ac73910ab
files libgui/src/m-editor/file-editor-tab.cc
diffstat 1 files changed, 11 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/m-editor/file-editor-tab.cc	Sat Jan 27 13:51:31 2018 -0500
+++ b/libgui/src/m-editor/file-editor-tab.cc	Sun Jan 28 10:05:45 2018 +0100
@@ -2292,6 +2292,17 @@
 bool
 file_editor_tab::check_valid_codec (QTextCodec *codec)
 {
+  if (! codec)
+    {
+      int ans = QMessageBox::critical (nullptr,
+            tr ("Octave Editor"),
+            tr ("The current codec %1\n"
+                "can not be applied.\n\n"
+                "Please select another one or cancel saving!").arg (_encoding));
+
+      return true;
+    }
+
   if (! codec->canEncode (_edit_area->text ()))
     {
       int ans = QMessageBox::warning (nullptr,