[vlc-commits] Make the config dirty flag global rather than per item
Rémi Denis-Courmont
git at videolan.org
Sun Apr 1 11:55:48 CEST 2012
vlc | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Sun Apr 1 12:54:24 2012 +0300| [f7be75539b208c0a4879df805dd54c059f5f660f] | committer: Rémi Denis-Courmont
Make the config dirty flag global rather than per item
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=f7be75539b208c0a4879df805dd54c059f5f660f
---
include/vlc_configuration.h | 1 -
src/config/configuration.h | 1 +
src/config/core.c | 7 ++++---
src/config/file.c | 25 ++++---------------------
src/modules/cache.c | 2 --
5 files changed, 9 insertions(+), 27 deletions(-)
diff --git a/include/vlc_configuration.h b/include/vlc_configuration.h
index aa87486..fa045938 100644
--- a/include/vlc_configuration.h
+++ b/include/vlc_configuration.h
@@ -71,7 +71,6 @@ struct module_config_t
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 */
diff --git a/src/config/configuration.h b/src/config/configuration.h
index f20d029..dd02c7f 100644
--- a/src/config/configuration.h
+++ b/src/config/configuration.h
@@ -51,6 +51,7 @@ void config_UnsortConfig (void);
((type) == CONFIG_ITEM_FLOAT)
extern vlc_rwlock_t config_lock;
+extern bool config_dirty;
bool config_IsSafe (const char *);
diff --git a/src/config/core.c b/src/config/core.c
index ddc688a..e4f30b4 100644
--- a/src/config/core.c
+++ b/src/config/core.c
@@ -38,6 +38,7 @@
#include "modules/modules.h"
vlc_rwlock_t config_lock = VLC_STATIC_RWLOCK;
+bool config_dirty = false;
static inline char *strdupnull (const char *src)
{
@@ -242,7 +243,7 @@ void config_PutPsz( vlc_object_t *p_this,
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);
@@ -283,7 +284,7 @@ void config_PutInt( vlc_object_t *p_this, const char *psz_name,
vlc_rwlock_wrlock (&config_lock);
p_config->value.i = i_value;
- p_config->b_dirty = true;
+ config_dirty = true;
vlc_rwlock_unlock (&config_lock);
}
@@ -324,7 +325,7 @@ void config_PutFloat( vlc_object_t *p_this,
vlc_rwlock_wrlock (&config_lock);
p_config->value.f = f_value;
- p_config->b_dirty = true;
+ config_dirty = true;
vlc_rwlock_unlock (&config_lock);
}
diff --git a/src/config/file.c b/src/config/file.c
index 10f7cd8..81d5faa 100644
--- a/src/config/file.c
+++ b/src/config/file.c
@@ -540,7 +540,6 @@ int config_SaveConfigFile (vlc_object_t *p_this)
!modified, p_item->psz_name, "%s",
psz_value ? psz_value : "");
}
- p_item->b_dirty = false;
}
}
vlc_rwlock_unlock (&config_lock);
@@ -606,34 +605,18 @@ error:
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;
}
diff --git a/src/modules/cache.c b/src/modules/cache.c
index 808f0fa..3c5107d 100644
--- a/src/modules/cache.c
+++ b/src/modules/cache.c
@@ -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,
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 )
More information about the vlc-commits
mailing list