That book has been very helpful. I would have been lost without it. Sure there is the demo and it seems feature rich, but having something that you can read that leads you along the way is hugly benificial as well. I'm hoping the guy who wrote that one writes another book. And like yesterday cuz I just finished this one.
I would have to see where your code is in the class and see your scope and object lifetime to see what you're trying to do.... Otherwise I'm just making an educated guess.
Paulo, when you ask questions involving code, please show us the surrounding function and class where (1) each of your variables are defined and (2) the code you've shown is written. In C++, it is so important to understand the scope of your variables.
Suggestion #1: Make appProperties a class member variable. This variable must exist as long as you want to access the PropertiesFile* that it manages. Once appProperties falls out of scope, you can't use the PropertiesFile pointer that getUserSettings() returned. Which brings me to....
Suggestion #2: Don't save the pointer returned from getUserSettings() for very long. The problem with storing it is that (1) once appProperties goes out of scope, it is no longer valid (this is a correctness issue), and (2) now you have two things to keep track of instead of just one (this is a maintenance issue).
If you need to access a lot of settings, you could do this:
void MyClass::resetToDefaultProperties()
{
PropertiesFile* const props = appProperties.getUserSettings();
props->setValue("TerminalType", var(0));
props->setValue(...);
props->setValue(...);
props->setValue(...);
...
} // <- at this point, props falls safely out of scope,
// but appProperties is still valid so you can still call
// getUserSettings() and it will return a valid pointer
In other words, don't save props in a class member variable, but it's okay to use it as a local variable for easy access.
Hopefully you can see how important it is to understand the scope of your variables. This is why we need to see where your code is in the class, just as Rail mentioned.
No, not for appProperties. I've tested my technique and it works without leaks.
Do yourself a favor and spend 15 minutes and create a new project using Introjucer. Make a component with a few buttons and a TextEditor to test reading/saving a single value using the ApplicationProperties class. Follow the example I've given above.
If after those 15 minutes you haven't figured it out, post more code. You are doing something else that you are not showing us.
I know that the leak is on this function and related with props.
Finding memory leaks can be tricky. It might not be where you are assuming it is.
you are totally right, it worked well and smoothly. My mistake is that i had a function to check the licence of the software and this was using two String variables that were not used.
I deleted both and now it as no leaks.
Indeed to solve the leaks problem is demanding and i need to learn more about this and how to solve them.
You help was great and very important.
Also hope that your solution can be helpfull to others that may find the same problem (hope i am not the only rookie here ! hehe).
New problem -> new thread. It is good forum etiquette to make sure you don't post new problems on an old thread (even if you are the original poster). If you have a new problem, please start a new thread (which I see you have already done). Since you have already started a thread for this new problem, there is no need to bring it up here.