#3507: Reference counting for bound configuration in Util::Option is broken

This commit is contained in:
Günter Obiltschnig 2022-02-19 10:35:30 +01:00
parent 3b1484ca50
commit 010cf8b7d0
2 changed files with 45 additions and 53 deletions

View File

@ -126,7 +126,7 @@ public:
/// ///
/// The configuration will automatically receive the option's argument. /// The configuration will automatically receive the option's argument.
Option& binding(const std::string& propertyName, AbstractConfiguration* pConfig); Option& binding(const std::string& propertyName, AbstractConfiguration::Ptr pConfig);
/// Binds the option to the configuration property with the given name, /// Binds the option to the configuration property with the given name,
/// using the given AbstractConfiguration. /// using the given AbstractConfiguration.
/// ///

View File

@ -32,8 +32,7 @@ Option::Option():
_repeatable(false), _repeatable(false),
_argRequired(false), _argRequired(false),
_pValidator(0), _pValidator(0),
_pCallback(0), _pCallback(0)
_pConfig(0)
{ {
} }
@ -54,7 +53,6 @@ Option::Option(const Option& option):
{ {
if (_pValidator) _pValidator->duplicate(); if (_pValidator) _pValidator->duplicate();
if (_pCallback) _pCallback = _pCallback->clone(); if (_pCallback) _pCallback = _pCallback->clone();
if (_pConfig) _pConfig->duplicate();
} }
@ -65,8 +63,7 @@ Option::Option(const std::string& fullName, const std::string& shortName):
_repeatable(false), _repeatable(false),
_argRequired(false), _argRequired(false),
_pValidator(0), _pValidator(0),
_pCallback(0), _pCallback(0)
_pConfig(0)
{ {
} }
@ -79,8 +76,7 @@ Option::Option(const std::string& fullName, const std::string& shortName, const
_repeatable(false), _repeatable(false),
_argRequired(false), _argRequired(false),
_pValidator(0), _pValidator(0),
_pCallback(0), _pCallback(0)
_pConfig(0)
{ {
} }
@ -94,8 +90,7 @@ Option::Option(const std::string& fullName, const std::string& shortName, const
_argName(argName), _argName(argName),
_argRequired(argRequired), _argRequired(argRequired),
_pValidator(0), _pValidator(0),
_pCallback(0), _pCallback(0)
_pConfig(0)
{ {
} }
@ -103,7 +98,6 @@ Option::Option(const std::string& fullName, const std::string& shortName, const
Option::~Option() Option::~Option()
{ {
if (_pValidator) _pValidator->release(); if (_pValidator) _pValidator->release();
if (_pConfig) _pConfig->release();
delete _pCallback; delete _pCallback;
} }
@ -200,12 +194,10 @@ Option& Option::binding(const std::string& propertyName)
} }
Option& Option::binding(const std::string& propertyName, AbstractConfiguration* pConfig) Option& Option::binding(const std::string& propertyName, AbstractConfiguration::Ptr pConfig)
{ {
_binding = propertyName; _binding = propertyName;
if (_pConfig) _pConfig->release();
_pConfig = pConfig; _pConfig = pConfig;
if (_pConfig) _pConfig->duplicate();
return *this; return *this;
} }