Skip to content

Commit 96b5336

Browse files
committed
Merge remote-tracking branch 'origin/issue/18' into develop
2 parents 6e12b32 + 38c49bd commit 96b5336

File tree

1 file changed

+14
-7
lines changed

1 file changed

+14
-7
lines changed

mlapptools.m

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ function fontWeight(uiElement, weight)
177177
% to the provided uifigure control.
178178
% Get a handle to the webwindow
179179
win = mlapptools.getWebWindow(uiElement);
180-
mlapptools.waitTillWebwindowLoaded(win);
180+
mlapptools.waitTillWebwindowLoaded(win, ancestor(uiElement, 'matlab.ui.Figure') );
181181

182182
% Find which element of the DOM we want to edit
183183
switch uiElement.Type
@@ -616,8 +616,12 @@ function unlockUIFig(hUIFig)
616616
end % getWidgetIDFromDijit
617617

618618
function to = getTimeout(hFig)
619-
to = getappdata(hFig, mlapptools.TAG_TIMEOUT);
620-
if isempty(to), to = mlapptools.QUERY_TIMEOUT; end
619+
if isempty(hFig) || ~isa(hFig, 'matlab.ui.Figure')
620+
to = mlapptools.QUERY_TIMEOUT;
621+
else
622+
to = getappdata(hFig, mlapptools.TAG_TIMEOUT);
623+
if isempty(to), to = mlapptools.QUERY_TIMEOUT; end
624+
end
621625
end % getTimeout
622626

623627
function tf = isUIFigure(hList)
@@ -722,11 +726,14 @@ function waitTillFigureLoaded(hFig)
722726

723727
function waitTillWebwindowLoaded(hWebwindow, hFig)
724728
% A blocking method that ensures a certain webwindow has fully loaded.
725-
if nargin < 2
726-
hFig = mlapptools.figFromWebwindow(hWebwindow);
729+
try
730+
if nargin < 2
731+
hFig = mlapptools.figFromWebwindow(hWebwindow);
732+
end
733+
to = mlapptools.getTimeout(hFig);
734+
catch % possible workaround for R2017a:
735+
to = mlapptools.getTimeout([]);
727736
end
728-
729-
to = mlapptools.getTimeout(hFig);
730737
tic
731738
while (toc < to) && ~jsondecode(hWebwindow.executeJS(...
732739
'this.hasOwnProperty("require") && require !== undefined && typeof(require) === "function"'))

0 commit comments

Comments
 (0)