From 6dd34b1e790a62108481067b7ba5908f07a75344 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Fri, 7 Nov 2025 12:54:06 +0100 Subject: [PATCH 1/2] Update PropertyValueChangedEventData.m --- .../+internal/+event/PropertyValueChangedEventData.m | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/code/internal/+openminds/+internal/+event/PropertyValueChangedEventData.m b/code/internal/+openminds/+internal/+event/PropertyValueChangedEventData.m index 9440947f5..a3c4f4e24 100644 --- a/code/internal/+openminds/+internal/+event/PropertyValueChangedEventData.m +++ b/code/internal/+openminds/+internal/+event/PropertyValueChangedEventData.m @@ -5,16 +5,18 @@ NewValue OldValue IsLinkedProperty = false + IsPropertyOf end methods - function obj = PropertyValueChangedEventData(newValue, oldValue, isLinkedProperty) + function obj = PropertyValueChangedEventData(newValue, oldValue, isLinkedProperty, isPropertyOf) if nargin < 3 || isempty(isLinkedProperty) isLinkedProperty = false; end obj.NewValue = newValue; obj.OldValue = oldValue; obj.IsLinkedProperty = isLinkedProperty; + obj.IsPropertyOf = isPropertyOf; end end end From 2a8980a0a86e55b797500d6210266edf7ba18df4 Mon Sep 17 00:00:00 2001 From: ehennestad Date: Fri, 7 Nov 2025 12:54:27 +0100 Subject: [PATCH 2/2] Improve event notification and subsref handling in Schema Pass the object instance to PropertyValueChangedEventData for more accurate event source tracking. Enhance isSubsForPublicPropertyValue to correctly handle subsref indexing into object arrays and improve public property detection logic. --- code/internal/+openminds/+abstract/Schema.m | 37 +++++++++++++++++---- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/code/internal/+openminds/+abstract/Schema.m b/code/internal/+openminds/+abstract/Schema.m index f365c8549..24755424e 100644 --- a/code/internal/+openminds/+abstract/Schema.m +++ b/code/internal/+openminds/+abstract/Schema.m @@ -339,7 +339,7 @@ obj = builtin('subsasgn', obj, subs, value); % Assign new value and trigger event - evtData = PropertyValueChangedEventData(value, oldValue, true); % true for linked prop + evtData = PropertyValueChangedEventData(value, oldValue, true, obj); % true for linked prop obj.notify('PropertyWithLinkedInstanceChanged', evtData) elseif numel(subs) > 1 && strcmp(subs(2).type, '.') @@ -360,7 +360,7 @@ % Assign new value and trigger event linkedObj.subsasgn(subs(2:end), value); - evtData = PropertyValueChangedEventData(value, oldValue, true); % true for linked prop + evtData = PropertyValueChangedEventData(value, oldValue, true, obj); % true for linked prop obj.notify('PropertyWithLinkedInstanceChanged', evtData) elseif numel(subs) > 1 && strcmp(subs(2).type, '()') @@ -436,10 +436,19 @@ obj = builtin('subsasgn', obj, subs, value); - if numel(obj) >= 1 + if ~isempty(obj) if obj.isSubsForPublicPropertyValue(subs) - evtData = PropertyValueChangedEventData(value, oldValue, false); % false for property which is not embedded or linked - obj.notify('InstanceChanged', evtData) + if isscalar(obj) + evtSource = obj; + else + if strcmp(subs(1).type, '()') + evtSource = builtin('subsref', obj, subs(1)); + else + error('Unexpected error. Please report') + end + end + evtData = PropertyValueChangedEventData(value, oldValue, false, evtSource); % false for property which is not embedded or linked + evtSource.notify('InstanceChanged', evtData) % fprintf('Set "primitive" property type of %s\n', class(obj)) end end @@ -701,10 +710,24 @@ % Return true if subs represent dot-indexing on a public property tf = false; + + tempSubs = subs; + + % If we are indexing into a subset of the objects, lets strip + % of the first subs element. + if strcmp( tempSubs(1).type, '()' ) + if isscalar(tempSubs) % i.e instance() or instance(2) + return + else + tempSubs = tempSubs(2:end); + end + end - if strcmp( subs(1).type, '.' ) + % If subs represent dot-indexing, check if it is for a public + % property + if strcmp( tempSubs(1).type, '.' ) propNames = properties(obj); - tf = any( strcmp(subs(1).subs, propNames) ); + tf = any( strcmp(tempSubs.subs, propNames) ); end end