char i_short; /* Optional short option name */
/* Misc */
- unsigned b_dirty:1; /* Dirty flag to indicate a config change */
unsigned b_advanced:1; /* Flag to indicate an advanced option */
unsigned b_internal:1; /* Flag to indicate option is not to be shown */
unsigned b_unsaveable:1; /* Config should not be saved */
((type) == CONFIG_ITEM_FLOAT)
extern vlc_rwlock_t config_lock;
+extern bool config_dirty;
bool config_IsSafe (const char *);
#include "modules/modules.h"
vlc_rwlock_t config_lock = VLC_STATIC_RWLOCK;
+bool config_dirty = false;
static inline char *strdupnull (const char *src)
{
vlc_rwlock_wrlock (&config_lock);
oldstr = (char *)p_config->value.psz;
p_config->value.psz = str;
- p_config->b_dirty = true;
+ config_dirty = true;
vlc_rwlock_unlock (&config_lock);
free (oldstr);
vlc_rwlock_wrlock (&config_lock);
p_config->value.i = i_value;
- p_config->b_dirty = true;
+ config_dirty = true;
vlc_rwlock_unlock (&config_lock);
}
vlc_rwlock_wrlock (&config_lock);
p_config->value.f = f_value;
- p_config->b_dirty = true;
+ config_dirty = true;
vlc_rwlock_unlock (&config_lock);
}
!modified, p_item->psz_name, "%s",
psz_value ? psz_value : "");
}
- p_item->b_dirty = false;
}
}
vlc_rwlock_unlock (&config_lock);
int config_AutoSaveConfigFile( vlc_object_t *p_this )
{
- int ret = VLC_SUCCESS;
- bool save = false;
+ int ret = 0;
assert( p_this );
- /* Check if there's anything to save */
- module_t **list = module_list_get (NULL);
vlc_rwlock_rdlock (&config_lock);
- for (size_t i_index = 0; list[i_index] && !save; i_index++)
+ if (config_dirty)
{
- module_t *p_parser = list[i_index];
- module_config_t *p_item, *p_end;
-
- if( !p_parser->i_config_items ) continue;
-
- for( p_item = p_parser->p_config, p_end = p_item + p_parser->confsize;
- p_item < p_end && !save;
- p_item++ )
- {
- save = p_item->b_dirty;
- }
- }
-
- if (save)
/* Note: this will get the read lock recursively. Ok. */
ret = config_SaveConfigFile (p_this);
+ config_dirty = (ret != 0);
+ }
vlc_rwlock_unlock (&config_lock);
- module_list_free (list);
return ret;
}
memcpy (&p_module->p_config[i].value, &p_module->p_config[i].orig,
sizeof (p_module->p_config[i].value));
- p_module->p_config[i].b_dirty = false;
-
if( p_module->p_config[i].i_list )
{
if( p_module->p_config[i].ppsz_list )