Why does UIaxes handle is deleted when calling a function and taking inputs as UIaxes handle in MATLAB webapp ?
11 次查看(过去 30 天)
显示 更早的评论
Hello All,
I am facing one issue with taking UIaxes handle as input to the function.
I have created a Matlab WebApp where I plot about 20 different UIaxes plots and that I take these UiAxes to a report generator function and create a report of the same.
Issue is that when I call a report generator function it generates an error saying that
>> Error using matlab.ui.internal.preventMultiFigureAppsInWebAppServer/handleMultiWindowAttempt (line 27)
>> Web Apps does not support multiwindow apps.
>> Error using axes
>> Cannot set property to a deleted object.
>> Error in copyUIAxes (line 147)
>> Error in GenerateReport/checkaxistype (line 768)
>> Error in GenerateReport (line 99)
>> Error in App_GUI/GenerateReportButtonPushed (line 1490)
>> Error in appdesigner.internal.service.AppManagementService/tryCallback (line 189)
>> Error in matlab.apps.AppBase>@(source,event)tryCallback(appdesigner.internal.service.AppManagementService.instance(),app,callback,requiresEventData,event) (line 37)
>> Error using matlab.ui.control.internal.controller.ComponentController/executeUserCallback (line 427)
>> Error while evaluating Button PrivateButtonPushedFcn.
I tried to check the properties of the Axes which is being deleted just before calling this function. And it shows the properties which means those handles are not being deleted before calling the function. The properties are shown below.
>> UIAxes (Effort curve) with properties:
>> XLim: [0 137]
>> YLim: [0 9512]
>> XScale: 'linear'
>> YScale: 'linear'
>> GridLineStyle: '-'
>> Position: [153 245 509 434]
>> Units: 'pixels'
Use GET to show all properties
Any idea where I am going wrong. I have tried to copy obj to another object but same thing happens as above when calling a function.
To recreate this error I ahve attached the zip file which has the trail version of app and one report generating function and copyUIAxes fucntion. I have added the webapp file as well but this is for 2021b version only. The above error is from my actual code and the error you might get will a bit diffrent in terms of functions but main error is the same. "Web Apps does not support multiwindow apps." & "Cannot set property to a deleted object."
I am using matlab 2021b version.
Thankyou in advance!!
0 个评论
回答(3 个)
chicken vector
2023-11-28
It would be easier if you share your .mlapp file, but according to this line of error:
>> Web Apps does not support multiwindow apps.
The error may be that you are initialising multiple uifigure objects, which is not supported by AppDesigner.
The workaround is to initialise multiple apps.
Alternatively you can add two bottons to swiped across teh various uiaxes.
3 个评论
chicken vector
2023-11-28
I find it very difficult to help you in this by only looking at error.
Could you try to replicate the app behaviour with a different .mlapp file?
Something simpler that you can share here, otherwise I can't do much.
Voss
2023-12-1
copyUIAxes called with one input creates a new figure, as the comment near the top of copyUIAxes.m states:
% COPYUIAXES(uiax) creates a new figure and axis in default positions
% and copies the content of the UI axes onto the new axes.
However, creating a new figure is not supported by Web App Server, so you get the error, "Web Apps does not support multiwindow apps."
Try using the second input to copyUIAxes to specify the destination.
% COPYUIAXES(uiax,destination) copies the content of the UI axis to
% destination object which can either be a figure or axes handle. If
% the handle is a figure the axes will be created within the figure.
For example, you can try creating a new uiaxes to use as the destination to which your original uiaxes and its properties will be copied:
new_axes = uiaxes(app.RightPanel);
copyUIAxes(app.PoweratWheelsCurve, new_axes);
and then send the new uiaxes to the report generator function:
TrailApp_reportGenerate(app.PoweratWheelsCurve, new_axes)
I'm not sure about what the best parent is to create the new uiaxes in. Above I've used app.RightPanel because that's where the original uiaxes is.
Also, I'm not familiar with Report Generator, so I don't know what TrailApp_reportGenerate is supposed to do, but I suspect you'll run into the same error again on its line 45:
ax1 = copyUIAxes(axh);
2 个评论
Voss
2023-12-1
"I did not understand your answer as why we are plotting new axis as "app.RightPanel"."
As I said, "Above I've used app.RightPanel because that's where the original uiaxes is."
Choose whatever parent for the new uiaxes that makes sense.
What happens when you run the adjusted code, i.e., call copyUIaxes with two inputs, the second one being a uiaxes you created directly?
Walter Roberson
2023-12-1
You are constructing your report by copying existing graphics object into a new uifigure that will act as the report holder.
When you use webapps you are limited to one uifigure -- so you cannot create a second uifigure to copy the graphics objects into.
You will need to create your report as a traditional figure (instead of as a uifigure) -- or else you will need to move things around and delete objects within your one single uifigure to create the report.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Specifying Target for Graphics Output 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!