mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-06 06:44:57 +01:00
Only save modified configuration variable to user config
This allows to change default values when necessary.
This commit is contained in:
parent
4e71a78bc7
commit
52bd416845
3 changed files with 19 additions and 1 deletions
|
|
@ -239,8 +239,10 @@ RCConfiguration::get_variables (std::string const & node_name) const
|
||||||
|
|
||||||
#undef CONFIG_VARIABLE
|
#undef CONFIG_VARIABLE
|
||||||
#undef CONFIG_VARIABLE_SPECIAL
|
#undef CONFIG_VARIABLE_SPECIAL
|
||||||
|
/* due to special case of PBD::ConfigVariable<std::string> we cannot use PBD::to_string<type> (value),
|
||||||
|
* but have to construct a ConfigVariable */
|
||||||
#define CONFIG_VARIABLE(type,var,Name,value) \
|
#define CONFIG_VARIABLE(type,var,Name,value) \
|
||||||
var.add_to_node (*node);
|
var.add_to_node_if_modified (*node, ConfigVariable<type> (Name, value).get_as_string ());
|
||||||
#define CONFIG_VARIABLE_SPECIAL(type,var,Name,value,mutator) \
|
#define CONFIG_VARIABLE_SPECIAL(type,var,Name,value,mutator) \
|
||||||
var.add_to_node (*node);
|
var.add_to_node (*node);
|
||||||
#include "ardour/rc_configuration_vars.inc.h"
|
#include "ardour/rc_configuration_vars.inc.h"
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,21 @@ ConfigVariableBase::add_to_node (XMLNode& node) const
|
||||||
node.add_child_nocopy (*child);
|
node.add_child_nocopy (*child);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
ConfigVariableBase::add_to_node_if_modified (XMLNode& node, std::string const& dflt) const
|
||||||
|
{
|
||||||
|
const std::string v = get_as_string ();
|
||||||
|
if (v == dflt) {
|
||||||
|
DEBUG_TRACE (DEBUG::Configuration, string_compose ("Config variable '%1' used default, not saved\n", _name));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
DEBUG_TRACE (DEBUG::Configuration, string_compose ("Config variable '%1' stored as [%2]\n", _name, v));
|
||||||
|
XMLNode* child = new XMLNode ("Option");
|
||||||
|
child->set_property ("name", _name);
|
||||||
|
child->set_property ("value", v);
|
||||||
|
node.add_child_nocopy (*child);
|
||||||
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
ConfigVariableBase::set_from_node (XMLNode const & node)
|
ConfigVariableBase::set_from_node (XMLNode const & node)
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -34,6 +34,7 @@ class LIBPBD_API ConfigVariableBase {
|
||||||
|
|
||||||
std::string name () const { return _name; }
|
std::string name () const { return _name; }
|
||||||
void add_to_node (XMLNode&) const;
|
void add_to_node (XMLNode&) const;
|
||||||
|
void add_to_node_if_modified (XMLNode&, std::string const&) const;
|
||||||
bool set_from_node (XMLNode const &);
|
bool set_from_node (XMLNode const &);
|
||||||
|
|
||||||
virtual std::string get_as_string () const = 0;
|
virtual std::string get_as_string () const = 0;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue