How to troubleshoot "Warning: Unable to save App Designer app object. Save not supported for matlab.apps.AppBase objects." Issue in App Designer?
이전 댓글 표시
I was working on a MATLAB App that saves the app properties to a mat file in UIFigureCloseRequest callback, and loads the saved properties from the mat file in startUpFcn. This was working until I made some changes to the app.
Since then, everytime I close the app, I get
"Warning: Unable to save App Designer app object. Save not supported for matlab.apps.AppBase objects." ,
Also, everytime I repen the app, I get
"Error using startupFcn Unable to load App Designer app object. Load not supported for matlab.apps.AppBase objects."
When I remove the mat file, then I don't get the error when I open the app, but I get the warning when I close the app.
Here is the app properties
properties (Access = private)
Bot
Messages
end
Here is how the properties are initialized
sfun = @(x)streamTokens(app,x);
app.Bot = openAIChat("You are an AI assistant.",StreamFun=sfun);
app.Messages = openAIMessages;
This is the used to save the properties in UITree.
s = struct('bot',app.Bot,'messages',app.Messages);
uitreenode(app.Tree,NodeData=s,Text="My Chat");
Here is the starupFcn, which restore the data into UITree.
function startupFcn(app)
if isempty(app.Tree.Children)
uitreenode(app.Tree,"Text","New Chat")
end
if isfile("ChatData.mat")
% this line triggers the error
load("ChatData.mat","PreviousChats");
for ii = 1:height(PreviousChats)
topic = PreviousChats.topic(ii);
s = PreviousChats.chat_history(ii);
uitreenode(app.Tree,NodeData=s,Text=topic)
end
end
end
Here is the UIFigureCloseRequest, which saves the text and Node Data from UITree to a mat file.
function UIFigureCloseRequest(app, event)
chats = app.Tree.Children(2:end);
PreviousChats = table;
PreviousChats.topic = arrayfun(@(x) string(x.Text), chats);
PreviousChats.chat_history = arrayfun(@(x) x.NodeData, chats);
isValid = arrayfun(@(x) numel(x.messages.Messages), PreviousChats.chat_history) >= 2;
PreviousChats(~isValid,:) = [];
if numel(PreviousChats.topic) > 0
% this line triggers the warning
save("ChatData.mat","PreviousChats")
else
if isfile("ChatData.mat")
delete("ChatData.mat");
end
end
delete(app)
end
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 National Instruments Frame Grabbers에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!