Matlab 2025 and newer stalls in uigetfile
Show older comments
I have a long script that calls uigetfile twice to select files to operate on. The original script was written in 2011 and used a bunch of javascript calls to address Guide figures. I've removed these and replaced them with modern code, but there's probably still some legacy issues to be resolved.
In 2024a, the script runs just fine. However in 2025a or 2026a the script will run the first time after I load Matlab, but then will it stall the second time I run the script. It appears that this is a Matlab problem, rather than a script problem.
Here is the relevant section of the code:
% Get initial and final scans
[filename1,pathname1,~] = uigetfile({'*.ctw; *.itw'},'Pick Initial Scans',startdir,'MultiSelect','on');
[filename2,pathname2,filterindex2] = uigetfile({'*.ctw; *.itw'},'Pick Final Scans',pathname1,'MultiSelect','on');
When I run the script the second time, Matlab shows the first get window, but then it seems to go into an endless loop before the second window is shown. If I manually click "Stop" I get this error stack:
obj.blockMATLAB();
^^^^^^^^^^^^^^^^^
ufd.showDialog(dialog_filter, uigetputtype);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[filename, pathname, filterindex] = uigetputfile_helper(0, varargin{:});
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[filename1,pathname1,~] = uigetfile({'*.ctw; *.itw'},'Pick Initial Scans',startdir,'MultiSelect','on');
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
What is going on here? Why is this new to 2025 or newer, and what can I do about it?
After I ran the script the first time, I created a separate script with only the following two lines:
startdir ='C:\';
[filename1,pathname1,~] = uigetfile({'*.ctw; *.itw'},'Pick Initial Scans',startdir,'MultiSelect','on');
That script also stalls, and gives the same error stack. So apparently there is something in my code that's causing uigetfile to blow up. What could I possibly have done that would cause this?
9 Comments
Torsten
on 28 Jul 2026
Contact support:
dpb
on 28 Jul 2026
Which OS?
As @Torsten, suggests, it's an official support request, probably to resolve, but just out of curiosity, what if you cut back to just the single
[filename1,pathname1,~] = uigetfile();
plain vanilla first, and then add parameters one at a time? Can you then isolate where it breaks, assuming even the first doesn't?
Does seem peculiar that such a basic UI function could have slipped by release and not have been flagged immediately if it were ubiquitous in the distribution and not something system specific.
Jim McIntyre
on 28 Jul 2026
Edited: Jim McIntyre
on 28 Jul 2026
Jim McIntyre
on 28 Jul 2026
dpb
on 28 Jul 2026
But if you just restart MATLAB in a new session, does it still error, or only after trying the previous script/function?
Jim McIntyre
on 29 Jul 2026
Edited: Jim McIntyre
on 29 Jul 2026
dpb
on 29 Jul 2026
Gotcha'.....just checking to make sure. MathWorks support will then need the other script as part of the support request to be able to reproduce the issue.
Jim McIntyre
on 3 Aug 2026
That it hung is probably owing to the classic UIxxx tools being wrappers around Java Swing components and they end up with a deadlock condition with the internal Java execution thread and Matlab's execution thread.
It still works before R2025a because it was in R2025a that MathWorks removed the support for Java SWING components entirely.
Your fix certainly is the correct solution to move to post R2025a environment; you'll still have the issue if need to keep supporting it on earlier releases.
Accepted Answer
More Answers (0)
Categories
Find more on Data Type Identification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!