Skip to content

Commit

Permalink
remove automatic clearing of matRad_cfg in matRad_rc and better handl…
Browse files Browse the repository at this point in the history
…e calling matRad_rc from wrong folder
  • Loading branch information
wahln committed Jun 15, 2022
1 parent 2446784 commit 9a1e071
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
10 changes: 7 additions & 3 deletions MatRad_Config.m
Original file line number Diff line number Diff line change
Expand Up @@ -60,12 +60,11 @@
% For instantiation, use the static MatRad_Config.instance();

obj.matRadRoot = fileparts(mfilename('fullpath'));
addpath(genpath(obj.matRadRoot));

%Set Version
obj.getEnvironment();
obj.matRad_version = matRad_version();

obj.matRadRoot = fileparts(mfilename('fullpath'));
obj.matRad_version = matRad_version();

%Just to catch people messing with the properties in the file
if ~isempty(obj.writeLog) && obj.writeLog
Expand All @@ -76,6 +75,11 @@
%Call the reset function for remaining inatialization
obj.reset();
end

function delete(~)
%might not be desired by users
%rmpath(genpath(matRad_cfg.matRadRoot));
end

function displayToConsole(obj,type,formatSpec,varargin)
%displayToConsole lowest-level logging function for matRad.
Expand Down
10 changes: 7 additions & 3 deletions matRad_rc.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,14 @@
%
% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% set search path and clear other instances of matRad
clear matRad_cfg MatRad_Config persistent global;
% Initialize matRad
matRad_cfg = MatRad_Config.instance();
addpath(genpath(matRad_cfg.matRadRoot));
if ~strcmp(matRad_cfg.matRadRoot,fileparts(mfilename("fullpath")))
matRad_cfg.dispWarning('Called matRad_rc in folder %s but matRad initialized in folder %s!\n Removing old matRad from path and using new installation!',fileparts(mfilename("fullpath")),matRad_cfg.matRadRoot);
rmpath(genpath(matRad_cfg.matRadRoot));
clear matRad_cfg MatRad_Config;
matRad_cfg = MatRad_Config.instance();
end

%clear command window and close all figures
clc;
Expand Down

0 comments on commit 9a1e071

Please sign in to comment.