m2sci: fix m2sci_gui 78/14378/9
Paul Bignier [Tue, 8 Apr 2014 15:23:27 +0000 (17:23 +0200)]
The GUI closed and failed when a non-existing file/directory was entered.

Change-Id: Ife8b47ddcc237c19b32367dff78d1bf32f87baf7

scilab/modules/m2sci/macros/cb_m2sci_gui.sci
scilab/modules/m2sci/macros/m2sci_gui.sci

index 43266ea..cb098cc 100644 (file)
@@ -134,6 +134,10 @@ function cb_m2sci_gui
         //
     elseif get(gcbo, "tag")=="convertbtn" then
         outputdir = get("outedit", "string");
+        if outputdir == [] | ~isdir(outputdir) then
+            set(gcf(), "info_message", _("Please specify an existing output directory."));
+            return
+        end
 
         rec = get("recradioyes", "value") == 1;
 
@@ -153,14 +157,22 @@ function cb_m2sci_gui
 
         if get("fileradio", "value") == 1 then // Single file conversion
             inputfile = get("fileedit", "string");
-            //delete(findobj("tag", "m2scifig"));
-            delete(gcf());
-            mfile2sci(inputfile, outputdir, rec, doub, verb, pp);
+            if inputfile <> [] & isfile(inputfile) then
+                //delete(findobj("tag", "m2scifig"));
+                delete(gcf());
+                mfile2sci(inputfile, outputdir, rec, doub, verb, pp);
+            else
+                set(gcf(), "info_message", _("Please specify an existing input file."));
+            end
         else // Directory conversion
             inputdir = get("diredit", "string");
-            //delete(findobj("tag", "m2scifig"));
-            delete(gcf());
-            translatepaths(inputdir, outputdir);
+            if inputdir <> [] & isdir(inputdir) then
+                //delete(findobj("tag", "m2scifig"));
+                delete(gcf());
+                translatepaths(inputdir, outputdir);
+            else
+                set(gcf(), "info_message", _("Please specify an existing input directory."));
+            end
         end
 
         //
index fd016e2..26b181f 100644 (file)
@@ -18,12 +18,11 @@ function m2sci_gui()
     widgeth = 20;
     btnh = 22;
     btnw = 90;
-    // defaultfont = "arial";
     margin = 18;
 
     // Figure creation
     m2scifig = figure("figure_name", gettext("Matlab to Scilab conversion tool"),...
-    "infobar_visible", "off",...
+    "infobar_visible", "on",...
     "toolbar_visible", "off",...
     "dockable", "off",...
     "menubar", "none",...