LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Saving a file marks it for re-compilation

Solved!
Go to solution

Hello,

 

the following scenario: In CVI2013, open a project, edit the source code, build and run the project, and then quit the executable such that you're back in the IDE. Click the green triangle again and the executable will be run 'immediately'. Now, save the file and press the green triangle again - CVI starts compiling and building the project...

 

I don't think that this should be necessary, leaving some room for improvement Smiley Wink

0 Kudos
Message 1 of 7
(3,895 Views)

Hi Wolfgang,

 

This is an interesting scenario. Unfortunately, I don't think it's possible to avoid this recompile in 2013, without other undesirable side effects.

 

In CVI 2012 and earlier, CVI always compiled files from memory. So, when you saved the file after building and running, that did not trigger the need to recompile after the save.

 

In CVI 2013, all compilation needs to be done from disk instead. You can still compile files without saving them first only because CVI makes a temporary copy of those files (you can see these copies in the UnsavedChanges folder under the project's configuration folder).

 

The reason the recompile happens after the save is because when you save the file after running, the timestamp of the saved file is later than the timestamp of the object file that was created from the temporary copy from UnsavedChanges.

 

To avoid this problem, when you save the file CVI could instead copy the temporary file from the UnsavedChanges to its regular location, if and only if you save it without making any additional changes. The problem, however, is that the timestamp of the regular file would be older than the time when the user explicitly chose to save the file, and I don't think that it's a good idea to have this discrepancy.

 

If you'd like to work around this issue, you could choose to copy the file yourself from the UnsavedChanges folder, instead of saving it (and then discard the changes in the editor). You could even use some script that you add to the Tools menu, to make it faster. But you'd have to be very careful to only do this when you know that you have not made any new changes to the file.

 

Luis

0 Kudos
Message 2 of 7
(3,883 Views)

Hi Luis,

 

thanks for the explanation! As you may understand, due to the achingly slow compilation of CVI 2013, I am not really satisfied with this status...

 

Why does CVI care about the timestamp of the saved file if it uses the temporary file anyway? Shouldn't it be enough to look at the timestamp of the temporary file?

0 Kudos
Message 3 of 7
(3,876 Views)
Solution
Accepted by topic author Wolfgang

It only uses the temporary file while you have unsaved changes. The moment you save the file, the temporary file is thrown away and the regular file is used instead.

 

Managing these temporary files is a fairly complicated task, as relates to precompiled header files, source code browsing, include paths, and lots of other things. Given this, keeping them around indefinitely is unfortunately not an option. Dealing with this complexity was necessary given that CVI was previously able to compile unsaved files and needed to continue doing it. But this is somewhat unconventional and typically is not allowed by traditional ADEs. So, another way that you have of avoiding this problem is to turn CVI into a more traditional compiler by enabling the "Save changes before compiling" option. Having this option enabled might not be as convenient at times, but at least in the scenario that you described at the top, there would have only been one build instead of two.

 

By the way, the achingly slow compilation is also not acceptable to us, and it will be addressed. For that matter, I also don't think it's typical, but of course that's probably not of great consolation to you right now.

0 Kudos
Message 4 of 7
(3,868 Views)

Luis,

 

thanks again! The reason I don't like saving the file per default is that this prevents undoing changes - so usually I keep the file unsaved until the run proves that the change was successful. In practice, the run doesn't prove this for the first few times, of course... Smiley Wink

 

Fortunately the auto-backup option does not affect the compilation soI am going to rely on this option...

0 Kudos
Message 5 of 7
(3,858 Views)

Ah, but you can undo past the point when you saved the file! Try it. You should be able to undo up until the point when you run out of undo buffer, regardless of how many times you've saved in the meanwhile.

 

By the way, I strongly recommend enabling the "record only file modification changes" option in the editor preferences. It's one of the first things I change in a new CVI installation (since it's not on by default, for backwards compatibility reasons) but I find it pretty useful and it also has the added benefit of conserving your undo buffer, in case you need to go back pretty far.

Message 6 of 7
(3,854 Views)

OK, so this was my fault, again - I had used the checkmark Purge undo actions when saving file...

0 Kudos
Message 7 of 7
(3,851 Views)