Correct way to use (old) JUCER and preserve your code?

I’ve been doing a lot of work on JUCER GUI .cpp and .h files.

I thought I was ultra-careful preserving the metadata…

…but when it came time to put them back into the JUCER, it inevitably threw away most of the code when it rewrote the files - of course, I didn’t lose anything but I need to move past this to continue working.

Unfortunately, it’s really not clear how I can correctly use the JUCER and preserve my custom code - or any custom code.

For example, I open the file juce/extras/juce demo/Source/demos/AudioDemoPlaybackPage.cpp in the JUCER and save it in the same directory as AudioDemoPlaybackPage2.cpp without changing anything else.

This action alone erases all the custom code that used to be in AudioDemoPlaybackPage.cpp.

In fact, I haven’t found any usable workflow that lets me even edit the files in the juce demo, let alone my own files…!

Ideas??

No, it doesn’t lose any data, but I think you’re misunderstanding how it works.

It doesn’t hold any of your custom code in memory while you’re editing the component, it just holds the layout. But when you resave over an existing file, it reads the old file and salvages any existing custom code before overwriting it. If you do a “save-as” somewhere else, it won’t go off and find your old custom code from the original file, it just creates a new, blank file containing the layout.

Ooh, i never knew that. Never had any reason to notice before, but it’s handy to know.

For the new jucer I’m going to do it slightly differently - it’ll load and remember all the custom bits, and will let you edit them. Then when you try to save over the old file, it’ll check whether the file has changed and offer to merge with the new one. Then it’ll put together all the layout and custom bits and save it - so a “save as” will do what you’d expect.

Sorry for the delay in responding - I got caught up in mixing a CD (it came out really well!)

I understand now how it works. It’s a bit scary :-D.

What you’re saying is that the entire state of your project is not stored in memory with the JUCER. When the JUCER saves, it performs a merge with whatever file is sitting there on the disk that it’s saving on top of, preserving the common code.

That sort of means that the Save As command isn’t really - it doesn’t save “what you’re doing” under “some other name” and, er, does seem to violate the Principle of Least Surprise. (Don’t get me wrong, you’re getting a huge amount with the JUCER above and beyond JUCE, I’m not carping, I could always do it by hand! But through constant self-criticism we approach perfection. :twisted: )

So I now know what my real question is :smiley: and I’ll post it on another thread.

Thanks again!