changeset 21836:2049e123bf7b

uigetdir, uigetfile, uiputfile: Return zeros when user cancels (bug #48171) * octave-link.cc (__octave_link_file_dialog__): Return three zeros for Malab compatibility when the file list starts with an empty string, meaning the dialog was canceled.
author Mike Miller <mtmiller@octave.org>
date Wed, 08 Jun 2016 10:40:39 -0700
parents f250714c629d
children 3ef630a564f8
files libinterp/corefcn/octave-link.cc
diffstat 1 files changed, 13 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/libinterp/corefcn/octave-link.cc	Tue Jun 07 16:00:45 2016 -0700
+++ b/libinterp/corefcn/octave-link.cc	Wed Jun 08 10:40:39 2016 -0700
@@ -231,17 +231,21 @@
   if (nel <= 3)
     {
       int idx = 0;
-      for (std::list<std::string>::iterator it = items_lst.begin ();
-           it != items_lst.end (); it++)
+      if (items_lst.front ().empty ())
         {
-          retval(idx++) = *it;
+          retval(idx++) = 0;
+          retval(idx++) = 0;
+          retval(idx++) = 0;
+        }
+      else
+        for (std::list<std::string>::iterator it = items_lst.begin ();
+             it != items_lst.end (); it++)
+          {
+            retval(idx++) = *it;
 
-          if (idx == 1 && retval(0).string_value ().length () == 0)
-            retval(0) = 0;
-
-          if (idx == 3)
-            retval(2) = atoi (retval(2).string_value ().c_str ());
-        }
+            if (idx == 3)
+              retval(2) = atoi (retval(2).string_value ().c_str ());
+          }
     }
   else
     {