Why App Designer wants to always save changes even if nothing is changed?

This is not a serious problem but it is quite annoying:
Every time when I open mlapp file in App Designer it immediately shows the file has changed and wants to save it after closing, although I have not even clicked anything on the editor. And, especially if I have had a longer session with several files open, I cannot remember which ones I have actually changed and then have to save all to be sure.
This causes extra trouble when using version control, because the saved mlapp is always different, even if there is no changes. So, I end up updating mlapp files to version control all the time even there is no need to. I know that if I would convert mlapp to m-file then version control could detect if there is actually any change, but after conversion to m-file it cannot be edited in App Designer anymore, so it is not a practical option.
Does anybody know why this is happening and is there any fix for it?
I wonder if Mathworks staff is aware of this and going to do anything for it.

9 Comments

I haven't seen this happening ever on my side. Once this happens, try to compare the change with the ancestor.
Firstly, this happens always, I mean, every time I open file in App Designer. And it does not matter how I open it, either in App Designer or command line "edit xxxx.mlapp".
Secondly, I have compared the changes after saving, and there are no changes in the actual content. I have done this so that I convert both old and new mlapp to m-files, and compare them, and there are no changes. However, mlapp binary files are still different. I have compared the binary files too, and it seems there are a lot of differences, so it is not just different date, for example. But still, when converting to m-files there are no changes. So, it seems mlapp either includes a lot of extra data, that has nothing to do with the content, or mlapp coding somehow depends on the time, but that would be strange.
And thirdly, this happens EVEN IF I DO NOT DO ANYTHING IN APP DESIGNER!!!! I have tried so that I save the file in App, close the file, and then open it again, and App Designer immediately shows the file is changed, and wants to save it after closing. So, there is really some problem in the App Designer.
I have tried using 2019b and 2020b and it behaves the same. I am using Windows 10.
You don't need to convert to .m, just go to your project, right click on the app and compare it to the ancestor.
You can always create a new project and a demo app and check whether this happens or not, to me, this seems very weird behaviour of App Designer.
I have compared it in different ways. If I do it like you said, it shows no difference. Just like when converting to m-file, there is no difference. But still, mlapp binaries are different after saving.
I do not believe that it depends on the app project. The problem is with App Designer itself. I made a very simple app for you to check. Attached app1 and app2 have no difference if you compare m-files, or by right-click and compare. However, if you compare the binaries (for example with free WinMerge), the files show a lot of differencies. So, mlapp includes some strange extra data, that changes in every save. AND I DID NOTHING IN APP DESIGNER BETWEEN APP1 AND APP2!!! I just first saved app1, and copied it to app2 and then opened app1 again and saved it.
This is a support case I believe, It's either something in your app code, project settings or something wrong with App Designer.
I am not believing this, actually same thing happens to me. Maybe I saved it every time so I didn't notice. I think I know what could be the issue, the asterisks appears at the time when UI table component is fully initialised in the App Designer.
Also, if I don't save it, I get a warning/error.
I also didn't observed this on my system. I am using R2020b on MacOS. Maybe this has something to do with your file system. Can you try saving the file on some other drive, or if possible, try it on some other PC.
Ameer Hamza, I tried on another PC, that is also Win 10. It has the same behaviour.
And did you notice earlier comment from Mario Malic, he had eventually seen the same behaviour too, so it is not just my problem. Maybe there is no problem with MacOS. I have only Windows PCs.
Ok, I didn't notice it earlier. I tried the two apps you shared. The first time I open it, I get the same behavior (i.e., an asterisk appears to save the file). However, once I save the file and close it, then on the subsequent opening of the files, it does not show an asterisk. I got the same behavior on both windows 10 and macOS.
Also, the first time the asterisk appears is not without reason. It appears after showing the message "app name updated to match the file name". This message appears if you initially created your app with one name and then rename the mlapp file. For example, initially, I named my app as myApp.mlapp; the first line in code view is
classdef myApp < matlab.apps.AppBase
but If I rename the file to myApp2.mlapp and then open the file, the MATLAB will automatically change the first line to
classdef myApp2 < matlab.apps.AppBase
and consequently the asterik appears.
Ameer Hamza, yes of course app2 has different classdef name because I was simply copying it with different name just for comparison purposes. That was not the problem.
The problem is that if I open app1 and save it, close App Designer, and open app1 again (for example using command line "edit app1", then App Designer shows it has been changed.
For some reason, there is a difference between this small demo app and my big project app:
With app1 the problem occurs only when I close App Designer and open it again. However, with my big project app the problem occurs also without closing App Designer. But anyway, with both apps the problem occurs if I close App Designer and open it again. And do not ask me to post that big project app, it is confidential.

Sign in to comment.

 Accepted Answer

I am answering myself, because I found out what is causing the bug.
Yes, it is a bug in Matlab. It is happening when using tab size other than default 4 (in preferences). When I create an app using the default tab size of 4, there is no problem. But when I use other than 4 (tried 2 and 6), and create for example just an empty app (create a blank app and save it), then it wants to save it every time after opening the App Desiger (however, you have to close the App Designer in between).

2 Comments

Nice find!
However, TMW won't notice the bug if it's not submitted to bug reports or if staff sees this question.
Thanks Mario! I have made a bug report and it is being processed already.

Sign in to comment.

More Answers (0)

Asked:

on 3 Nov 2020

Commented:

on 11 Nov 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!