The close(gcf) command awaiting the return key

1 Ansicht (letzte 30 Tage)
Eric Condamine
Eric Condamine am 9 Sep. 2016
Kommentiert: Walter Roberson am 13 Sep. 2016
In a script [exactly: the art.m from Artifact Detection Tools @ NITRC], there is a close(gcf) command which wait a press of the "return" key to actually close the desired window (if not, matlab stay in a busy state !)....
Due to this, it is not possible to use this script in a batch process ...
Any help will be very appreciate.
EDIT 1: By running the same script on a Mac OS X (Matlab 2015b) I have not observed this problem .... (I use Fedora 22 and Matlab 2013a). I don't see why the OS could be important in this case .... Is it a bug in Matlab 2013a ? ...
EDIT 2: I just installed the 2016a version on my station. I observe the same problem ...

Antworten (1)

Eric Condamine
Eric Condamine am 13 Sep. 2016
Bearbeitet: Eric Condamine am 13 Sep. 2016
The problem comes from the closerequestfcn property of the graphic object. The currently distributed art.m script contains this line:
set(handles.figure1,'closerequestfcn',['try,if isunix,txt=''rm ''; else txt=''del ''; end; [nill,ok]=system([txt,''',fullfile(output_dir,art_mask_temporalfile),''']);catch;end;close(gcbf);']);
This is a very elegant way to remove temporary files when the ART window is closed, but on my linux station, I have an alias for interactively remove the files or the directories (alias rm 'rm -i') ... So when the Art tool is running on an linux station with this configuration, the close(gcf) command awaits for an interactive action ... So, If you encounter this symptom, changing the previous line by the following should fix:
set(handles.figure1,'closerequestfcn',['try,if isunix,txt=''rm -f ''; else txt=''del ''; end; [nill,ok]=system([txt,''',fullfile(output_dir,art_mask_temporalfile),''']);catch;end;close(gcbf);']);
It could be a good idea that the next version of ART tool include this very minor change ...
  3 Kommentare
Eric Condamine
Eric Condamine am 13 Sep. 2016
This is very true, BUT, to be very robust, a code should run in all conditions, all configurations of a station (impossible in the real life !) and I think that the very little change I propose makes the script more robust.
Walter Roberson
Walter Roberson am 13 Sep. 2016
Well, you can always propose it to NITRC; the Answers forum doesn't have any connection to them.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Startup and Shutdown finden Sie in Help Center und File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by