changeset 24757:3897b81979d5

avoid variable editor error when the user enters an empty data cell * variable-editor-model.cc (variable_editor_model::setData): Return early if user input is empty and we are not editing a character string.
author John W. Eaton <jwe@octave.org>
date Wed, 14 Feb 2018 16:21:53 -0500
parents ad518267c0fd
children 09364b41ddb6
files libgui/src/variable-editor-model.cc
diffstat 1 files changed, 8 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/libgui/src/variable-editor-model.cc	Wed Feb 14 19:59:19 2018 +0100
+++ b/libgui/src/variable-editor-model.cc	Wed Feb 14 16:21:53 2018 -0500
@@ -948,6 +948,14 @@
 
   QString user_input = v_user_input.toString ();
 
+  char qc = quote_char (idx);
+
+  // FIXME: maybe we need a better way to ask whether empty input is
+  // valid than to rely on whether there is a quote character (meaning
+  // we are editing a character string)?
+  if (user_input.isEmpty () && ! qc)
+    return false;
+
   set_update_pending (idx, user_input);
 
   std::ostringstream os;
@@ -958,7 +966,6 @@
   QString tmp = subscript_expression (idx);
   os << tmp.toStdString () << "=";
 
-  char qc = quote_char (idx);
   if (qc)
     os << qc;