First, I have very little experience with POCO, but I really like what I have used so far.
Forgive me if my question is a little off, as I am still trying to get a handle on how some of the "garbage collection" works in POCO. I'll just give one example with the Poco.Util.Option class.
If I want to add a validator to an option, I do something like this:
Option("testint", "i", "test integer property")
.validator(new IntValidator(-100,100) ));
Looking in UtilincludePocoUtilOption.h, I see the declaration
Option& validator(Validator* pValidator);
/// Sets the validator for the given option.
/// The Option takes ownership of the Validator and
/// deletes it when it's no longer needed.
But, when I look in UtilsrcOption.cpp, I see the implementation
Option& Option::validator(Validator* pValidator)
if (_pValidator) _pValidator->release();
_pValidator = pValidator;
if (_pValidator) _pValidator->duplicate();
I notice that the duplicate() method is being called. Doesn't this increment the refcount to 2? So when the Option destructor is called, or a new validator is assigned, won't the refcount be decremented to 1 and the object won't be deleted?
Sorry if I am missing something very simple.