Hello all, I am having a slight issue with a warning that is popping up when I am deleting a custom control from inside another custom control.
Running 2022b on Win11.
In App Designer, I made a custom control called uiDesignType which looks like this:
and is used in another control uiDesignBuilder which looks like this (left) and when running and 'Add Design' is pushed a uiDesignType is added for each press (right):
This is how I currently have it set up, in uiDesignType I have an Event-Callback set up with an event called DesignOrderChanged and it's public calleback called DesignOrderChangeFcn.
When 'Add Design' is pressed this fires:
function cmdAddDesignButtonPushed(comp, event)
comp.DesignsLayout.RowHeight{end+1} = 25;
design = uiDesignType(comp.DesignsLayout);
design.DesignOrderChangeFcn=@(src,event)updateOrder(comp,design);
design.UserData = length(comp.Designs) + 1;
comp.Designs(end+1) = design;
When the delete button (trash can) is pressed this fires:
function cmdDeletePushed(comp, event)
notify(comp, 'DesignOrderChange');
updateOrder function
function updateOrder(comp,design)
sprintf('%s order change: %i', design.DesignType ,design.DesignOrder)
switch(design.DesignOrder)
Everything runs fine, the control gets deleted when I press the button but I get the warning:
Warning: Error occurred while executing the listener callback for event PostCallbackExecution defined for class
appdesigner.internal.service.AppManagementService:
Invalid or deleted object.
Error in onCleanup/delete (line 23)
obj.task();
Error in
matlab.apps.createCallbackFcn>@(source,event)executeCallback(appdesigner.internal.service.AppManagementService.instance(),obj,callback,requiresEventData,event)
(line 12)
newCallback = @(source, event)executeCallback(appdesigner.internal.service.AppManagementService.instance(), ...
When I debug, I but a breakpoint here design.delete; and as I step through, the delete happens with no issues, comes out of the switch block fine, exits updateOrder fine, and the very next step it jumps to cmdAddDesignButtonPushed at the line:
design.DesignOrderChangeFcn=@(src,event)updateOrder(comp,design);
then into cmdDeletePushed and comes out of the notify function fine then exits out of the cmdDeletePushed function with no issues.
Next step is into this MATLAB code:
function newCallback = createCallbackFcn(obj, callback, requiresEventData)
requiresEventData = false;
newCallback = @(source, event)executeCallback(appdesigner.internal.service.AppManagementService.instance(), ...
obj, callback, requiresEventData, event);
When it tries to fire off the newCallback = @... line, the warning gets thrown.
I have also tried this and I get the same results:
function cmdDeletePushed(comp, event)
Now, like I said, the control delets fine, and I have not noticed any other issues after the warnings, but it doesn't feel right to just leave it like that or worse add warning('off','MATLAB:callback:error') to hide it.
The warning is thrown when I hit 'Play' in App Designer, but if I run uiDB = uiDesignBuilder at the command prompt in MATLAB and then do uiDB.Designs(1).delete I dont get the warning. Designs is a property in uiDesignBuilder that is an array of uiDesignType.
Any thoughts?