]> git.sesse.net Git - vlc/commitdiff
Make the config dirty flag global rather than per item
authorRémi Denis-Courmont <remi@remlab.net>
Sun, 1 Apr 2012 09:54:24 +0000 (12:54 +0300)
committerRémi Denis-Courmont <remi@remlab.net>
Sun, 1 Apr 2012 09:54:24 +0000 (12:54 +0300)
include/vlc_configuration.h
src/config/configuration.h
src/config/core.c
src/config/file.c
src/modules/cache.c

index aa8748628673d3f260026304b1c90ea9782fa207..fa045938d3cd5e50d8588b2c035faeeb310ebe81 100644 (file)
@@ -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 */
index f20d0291488b7993a160099797133a0c763ae52e..dd02c7f4af2f267fe6788cb718397454030c7cf9 100644 (file)
@@ -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 *);
 
index ddc688a025e5b161028a50ac4e3b01d202beacaa..e4f30b40a16f95549de675d952db6cd16df74f95 100644 (file)
@@ -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);
 }
 
index 10f7cd882296f70bd27ec6a506efb553194fa1b6..81d5faa5ccc718a25c34b26e7d23f8f97fc11025 100644 (file)
@@ -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;
 }
index 808f0faa1658b714ff26183563c2ab3010512fbb..3c5107d9a21d52cdfed450823fef7f88c5f0ce7d 100644 (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,
                     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 )