From 4c2d221759a505587a4c7fe302d32b44e2dc9abf Mon Sep 17 00:00:00 2001
From: Nicola Vigano <nicola.vigano@esrf.fr>
Date: Mon, 22 Sep 2014 12:06:17 +0200
Subject: [PATCH] initialise_gt: temporay fix for error in case MTex is no
 installed.

Signed-off-by: Nicola Vigano <nicola.vigano@esrf.fr>
---
 initialise_gt.m | 19 ++++++++++++-------
 1 file changed, 12 insertions(+), 7 deletions(-)

diff --git a/initialise_gt.m b/initialise_gt.m
index b43669ee..f1e19f02 100644
--- a/initialise_gt.m
+++ b/initialise_gt.m
@@ -226,7 +226,7 @@ function initialise_gt(ignore_id19)
     disp('Finished adding.');
 
     disp('Checking compiled functions...');
-    currentDir = pwd;
+    current_dir = pwd;
     cd(fullfile(GT_MATLAB_HOME, 'bin', 'scripts'));
     mFiles = compile(false, false);
     funcNames = fieldnames(mFiles);
@@ -247,11 +247,11 @@ function initialise_gt(ignore_id19)
             fprintf(msg);
         end
     end
-    cd(currentDir);
+    cd(current_dir);
     disp('Finished checking.');
 	
 	% Warning when launched on a Windows PC
-	if ispc
+	if (ispc())
 		% Rendering: the default renderer may have to be changed
 		disp('If you are running the code on a Windows PC and experiencing')
 		disp('problems with colormaps or graphics resolution, you may have to')
@@ -264,14 +264,19 @@ function initialise_gt(ignore_id19)
     disp(' ')
     cd(fullfile(GT_MATLAB_HOME, 'matGeom'));
     setupMatGeom();
-    cd(currentDir);
+    cd(current_dir);
     disp(' ')
     % load MTex toolbox if logged on rnice6-0101
     % it has been installed only on this host
     % to be generalized
-    cd('/sware/com/matlab-tbx/mtex-3.4.2/');
-    startup_mtex();
-    cd(currentDir);
+    mtex_dir = '/sware/com/matlab-tbx/mtex-3.4.2/';
+    if (exist(mtex_dir, 'dir'))
+        cd(mtex_dir);
+        startup_mtex();
+        cd(current_dir);
+    else
+        warning('MTex:not_installed', 'MTex toolbox is not installed')
+    end
     disp([boldColor 'To report a bug, create a ticket at https://sourceforge.net/p/dct/tickets' defaultColor]);
 end
 
-- 
GitLab