Skip to content

Commit 13534e0

Browse files
authored
fix(octave): guard isvalid calls so Octave CI passes (#146)
* fix(octave): guard isvalid in refreshActivePageWidgetsAfterResize_ Octave 7+ has no isvalid() for classdef handles, so the three unguarded isvalid(w) / isvalid(w.FastSenseObj) calls in DashboardEngine line 2022 and 2045/2048 broke Octave CI (test_engine_preview_nbuckets_reset). Inline an isOctave flag and short-circuit the check on Octave; behaviour unchanged on MATLAB. * fix(octave): guard isvalid in FastSenseWidget.autoScaleY_ Octave 7+ has no isvalid() for classdef handles, so the unguarded isvalid(obj.FastSenseObj) check in autoScaleY_ broke every test that renders a FastSenseWidget or calls setYLimitMode (testDetectStaleWithFrozenSensor, testRefreshTriggers*, test_set_y_limit_mode_*, test_dashboard_preview_envelope). Inline an isOctave flag and short-circuit on Octave. * fix(octave): guard isvalid in syncYLimitButtonsState_ Octave 7+ has no isvalid() for classdef handles. Once autoScaleY_ is fixed, dashboard tests proceed to addYLimitButtons_ which calls syncYLimitButtonsState_ — the unguarded isvalid(w) on the cached widget handle would then throw. Inline isOctave and short-circuit on Octave.
1 parent c057cbf commit 13534e0

3 files changed

Lines changed: 15 additions & 5 deletions

File tree

libs/Dashboard/DashboardEngine.m

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2016,10 +2016,13 @@ function refreshActivePageWidgetsAfterResize_(obj)
20162016
return;
20172017
end
20182018
ws = obj.activePageWidgets();
2019+
isOctave = exist('OCTAVE_VERSION', 'builtin') ~= 0;
20192020
% --- Pass 1: cheap data re-push ---
20202021
for i = 1:numel(ws)
20212022
w = ws{i};
2022-
if isempty(w) || ~isvalid(w)
2023+
% Octave 7+ has no isvalid() for classdef handles, so treat
2024+
% as valid there and rely on downstream guards / try-catch.
2025+
if isempty(w) || (~isOctave && ~isvalid(w))
20232026
continue;
20242027
end
20252028
if ~w.Realized || isempty(w.hPanel) || ~ishandle(w.hPanel)
@@ -2042,10 +2045,10 @@ function refreshActivePageWidgetsAfterResize_(obj)
20422045
stillWhite = false;
20432046
for i = 1:numel(ws)
20442047
w = ws{i};
2045-
if isempty(w) || ~isvalid(w) || ~isa(w, 'FastSenseWidget')
2048+
if isempty(w) || (~isOctave && ~isvalid(w)) || ~isa(w, 'FastSenseWidget')
20462049
continue;
20472050
end
2048-
if isempty(w.FastSenseObj) || ~isvalid(w.FastSenseObj) || ~w.FastSenseObj.IsRendered
2051+
if isempty(w.FastSenseObj) || (~isOctave && ~isvalid(w.FastSenseObj)) || ~w.FastSenseObj.IsRendered
20492052
continue;
20502053
end
20512054
if ~obj.isWidgetLineWhite_(w)

libs/Dashboard/DashboardLayout.m

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1035,7 +1035,10 @@ function syncYLimitButtonsState_(bar, mode)
10351035
inactiveBg = [];
10361036
if isfield(ud, 'YLimitWidget') && ~isempty(ud.YLimitWidget)
10371037
w = ud.YLimitWidget;
1038-
if isobject(w) && isvalid(w) && ...
1038+
% Octave 7+ has no isvalid() for classdef handles; treat as
1039+
% valid there and rely on the property-access guards below.
1040+
isOctave = exist('OCTAVE_VERSION', 'builtin') ~= 0;
1041+
if isobject(w) && (isOctave || isvalid(w)) && ...
10391042
~isempty(w.ParentTheme) && isstruct(w.ParentTheme) && ...
10401043
isfield(w.ParentTheme, 'ToolbarBackground')
10411044
inactiveBg = w.ParentTheme.ToolbarBackground;

libs/Dashboard/FastSenseWidget.m

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -450,7 +450,11 @@ function autoScaleY_(obj, y)
450450
if obj.UserZoomedY
451451
return;
452452
end
453-
if ~isempty(obj.FastSenseObj) && isvalid(obj.FastSenseObj) && ...
453+
% Octave 7+ has no isvalid() for classdef handles, so treat the
454+
% FastSense handle as valid there and let downstream property
455+
% access surface real failures.
456+
isOctave = exist('OCTAVE_VERSION', 'builtin') ~= 0;
457+
if ~isempty(obj.FastSenseObj) && (isOctave || isvalid(obj.FastSenseObj)) && ...
454458
strcmp(obj.FastSenseObj.LiveViewMode, 'follow')
455459
return;
456460
end

0 commit comments

Comments
 (0)