Commit f7be7553 authored by Rémi Denis-Courmont's avatar Rémi Denis-Courmont

Make the config dirty flag global rather than per item

parent 98ade156
...@@ -71,7 +71,6 @@ struct module_config_t ...@@ -71,7 +71,6 @@ struct module_config_t
char i_short; /* Optional short option name */ char i_short; /* Optional short option name */
/* Misc */ /* Misc */
unsigned b_dirty:1; /* Dirty flag to indicate a config change */
unsigned b_advanced:1; /* Flag to indicate an advanced option */ 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_internal:1; /* Flag to indicate option is not to be shown */
unsigned b_unsaveable:1; /* Config should not be saved */ unsigned b_unsaveable:1; /* Config should not be saved */
......
...@@ -51,6 +51,7 @@ void config_UnsortConfig (void); ...@@ -51,6 +51,7 @@ void config_UnsortConfig (void);
((type) == CONFIG_ITEM_FLOAT) ((type) == CONFIG_ITEM_FLOAT)
extern vlc_rwlock_t config_lock; extern vlc_rwlock_t config_lock;
extern bool config_dirty;
bool config_IsSafe (const char *); bool config_IsSafe (const char *);
......
...@@ -38,6 +38,7 @@ ...@@ -38,6 +38,7 @@
#include "modules/modules.h" #include "modules/modules.h"
vlc_rwlock_t config_lock = VLC_STATIC_RWLOCK; vlc_rwlock_t config_lock = VLC_STATIC_RWLOCK;
bool config_dirty = false;
static inline char *strdupnull (const char *src) static inline char *strdupnull (const char *src)
{ {
...@@ -242,7 +243,7 @@ void config_PutPsz( vlc_object_t *p_this, ...@@ -242,7 +243,7 @@ void config_PutPsz( vlc_object_t *p_this,
vlc_rwlock_wrlock (&config_lock); vlc_rwlock_wrlock (&config_lock);
oldstr = (char *)p_config->value.psz; oldstr = (char *)p_config->value.psz;
p_config->value.psz = str; p_config->value.psz = str;
p_config->b_dirty = true; config_dirty = true;
vlc_rwlock_unlock (&config_lock); vlc_rwlock_unlock (&config_lock);
free (oldstr); free (oldstr);
...@@ -283,7 +284,7 @@ void config_PutInt( vlc_object_t *p_this, const char *psz_name, ...@@ -283,7 +284,7 @@ void config_PutInt( vlc_object_t *p_this, const char *psz_name,
vlc_rwlock_wrlock (&config_lock); vlc_rwlock_wrlock (&config_lock);
p_config->value.i = i_value; p_config->value.i = i_value;
p_config->b_dirty = true; config_dirty = true;
vlc_rwlock_unlock (&config_lock); vlc_rwlock_unlock (&config_lock);
} }
...@@ -324,7 +325,7 @@ void config_PutFloat( vlc_object_t *p_this, ...@@ -324,7 +325,7 @@ void config_PutFloat( vlc_object_t *p_this,
vlc_rwlock_wrlock (&config_lock); vlc_rwlock_wrlock (&config_lock);
p_config->value.f = f_value; p_config->value.f = f_value;
p_config->b_dirty = true; config_dirty = true;
vlc_rwlock_unlock (&config_lock); vlc_rwlock_unlock (&config_lock);
} }
......
...@@ -540,7 +540,6 @@ int config_SaveConfigFile (vlc_object_t *p_this) ...@@ -540,7 +540,6 @@ int config_SaveConfigFile (vlc_object_t *p_this)
!modified, p_item->psz_name, "%s", !modified, p_item->psz_name, "%s",
psz_value ? psz_value : ""); psz_value ? psz_value : "");
} }
p_item->b_dirty = false;
} }
} }
vlc_rwlock_unlock (&config_lock); vlc_rwlock_unlock (&config_lock);
...@@ -606,34 +605,18 @@ error: ...@@ -606,34 +605,18 @@ error:
int config_AutoSaveConfigFile( vlc_object_t *p_this ) int config_AutoSaveConfigFile( vlc_object_t *p_this )
{ {
int ret = VLC_SUCCESS; int ret = 0;
bool save = false;
assert( p_this ); assert( p_this );
/* Check if there's anything to save */
module_t **list = module_list_get (NULL);
vlc_rwlock_rdlock (&config_lock); 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. */ /* Note: this will get the read lock recursively. Ok. */
ret = config_SaveConfigFile (p_this); ret = config_SaveConfigFile (p_this);
config_dirty = (ret != 0);
}
vlc_rwlock_unlock (&config_lock); vlc_rwlock_unlock (&config_lock);
module_list_free (list);
return ret; return ret;
} }
...@@ -326,8 +326,6 @@ static int CacheLoadConfig( module_t *p_module, FILE *file ) ...@@ -326,8 +326,6 @@ static int CacheLoadConfig( module_t *p_module, FILE *file )
memcpy (&p_module->p_config[i].value, &p_module->p_config[i].orig, memcpy (&p_module->p_config[i].value, &p_module->p_config[i].orig,
sizeof (p_module->p_config[i].value)); 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].i_list )
{ {
if( p_module->p_config[i].ppsz_list ) if( p_module->p_config[i].ppsz_list )
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment