Revert "elm_config: fix elm_config_save not to wake idle processes up" 27/199727/1
authorMarcel Hollerbach <mail@marcel-hollerbach.de>
Wed, 13 Feb 2019 11:30:00 +0000 (12:30 +0100)
committerWonki Kim <wonki_.kim@samsung.com>
Thu, 14 Feb 2019 08:53:06 +0000 (17:53 +0900)
This reverts commit 8b0b9ed2819588fbf81299b784a600c6ac7ccd13.

There have been issues with this commit, for further informations,
please see https://phab.enlightenment.org/D7354 for more details.

Change-Id: Ia70a1eb5f06e178bd3c28ddef13eeab4d20dee01

src/lib/elementary/efl_ui_win.c
src/lib/elementary/elm_config.c
src/lib/elementary/elm_priv.h

index b189a87..2e042f9 100644 (file)
@@ -1761,7 +1761,6 @@ _elm_win_profile_update(Efl_Ui_Win_Data *sd)
 
    _config_profile_lock = EINA_TRUE;
    _elm_config_profile_set(sd->profile.name);
-   _config_profile_lock = EINA_FALSE;
 
    /* update sub ee */
    Ecore_Evas *ee2;
index 97f95d2..a36fcd5 100644 (file)
@@ -5,8 +5,6 @@
 #include <Elementary.h>
 #include "elm_priv.h"
 #include <pwd.h>
-#include <fcntl.h>
-
 
 #include "efl_config_global.eo.h"
 
@@ -36,7 +34,8 @@ static void _elm_config_key_binding_hash(void);
 Eina_Bool _config_profile_lock = EINA_FALSE;
 static Ecore_Timer *_config_change_delay_timer = NULL;
 static Ecore_Timer *_config_profile_change_delay_timer = NULL;
-static Ecore_Event_Handler *_monitor_file_modified_handler = NULL;
+static Ecore_Event_Handler *_monitor_file_created_handler = NULL;
+static Ecore_Event_Handler *_monitor_directory_created_handler = NULL;
 static Eio_Monitor *_eio_config_monitor = NULL;
 static Eio_Monitor *_eio_profile_monitor = NULL;
 
@@ -190,7 +189,6 @@ static void        _config_sub_apply(void);
 static void        _config_update(void);
 static void        _env_get(void);
 static void        _color_overlays_cancel(void);
-static Eina_Bool   _file_touch(const char *file);
 
 #define ELM_CONFIG_VAL(edd, type, member, dtype) \
   EET_DATA_DESCRIPTOR_ADD_BASIC(edd, type, #member, member, dtype)
@@ -1728,19 +1726,20 @@ _elm_recache(void)
 }
 
 static Elm_Config *
-_config_user_load(Eina_Bool on_flush)
+_config_user_load(void)
 {
    Elm_Config *cfg = NULL;
    Eet_File *ef;
    char buf[PATH_MAX];
 
-   if (on_flush)
-     _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s/.base.flush.cfg",
-                            _elm_profile);
+   _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s",
+                          _elm_profile);
+   ecore_file_mkpath(buf);
+   if (_eio_config_monitor) eio_monitor_del(_eio_config_monitor);
+   _eio_config_monitor = eio_monitor_add(buf);
 
-   if ((on_flush && !ecore_file_exists(buf)) || !on_flush)
-     _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg",
-                            _elm_profile);
+   _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg",
+                                 _elm_profile);
 
    ef = eet_open(buf, EET_FILE_MODE_READ);
    if (ef)
@@ -1793,7 +1792,7 @@ _efl_config_obj_del(Eo *obj EINA_UNUSED)
 }
 
 static void
-_config_load(Eina_Bool on_flush)
+_config_load(void)
 {
    if (_efl_config_obj)
      {
@@ -1812,7 +1811,7 @@ _config_load(Eina_Bool on_flush)
    efl_del_intercept_set(_efl_config_obj, _efl_config_obj_del);
    if (!_use_build_config)
      {
-        _elm_config = _config_user_load(on_flush);
+        _elm_config = _config_user_load();
         if (_elm_config)
           {
              if ((_elm_config->config_version >> ELM_CONFIG_VERSION_EPOCH_OFFSET) < ELM_CONFIG_EPOCH)
@@ -1992,13 +1991,13 @@ _config_load(Eina_Bool on_flush)
 }
 
 static void
-_elm_config_reload_do(Eina_Bool on_flush)
+_elm_config_reload_do(void)
 {
    Elm_Config *prev_config;
 
    prev_config = _elm_config;
    _elm_config = NULL;
-   _config_load(on_flush);
+   _config_load();
    if ((prev_config) && (_elm_config))
      {
 #define KEEP_VAL(xxx) \
@@ -2219,7 +2218,7 @@ _config_flush_get(void)
    _elm_config_font_overlays_cancel();
    _color_overlays_cancel();
 
-   _elm_config_reload_do(EINA_TRUE);
+   _elm_config_reload_do();
 
    /* restore prev value which is not part of the EET file */
    _elm_config->is_mirrored = is_mirrored;
@@ -2306,36 +2305,6 @@ _elm_config_eet_close_error_get(Eet_File *ef,
    return NULL;
 }
 
-static char *
-_elm_config_profile_name_get()
-{
-   char buf[PATH_MAX], *p;
-   Eet_File *ef = NULL;
-   int len = 0;
-   char *rst = NULL;
-
-   _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
-
-   ef = eet_open(buf, EET_FILE_MODE_READ);
-   if (ef)
-     {
-        p = eet_read(ef, "config", &len);
-        if (p)
-          {
-             rst = calloc(1, len+1);
-             memcpy(rst, p, len);
-             rst[len] = '\0';
-             free(p);
-          }
-        eet_close(ef);
-     }
-
-   if (rst)
-     return rst;
-   else
-     return strdup("default");
-}
-
 static Eina_Bool
 _elm_config_profile_save(const char *profile)
 {
@@ -2345,50 +2314,43 @@ _elm_config_profile_save(const char *profile)
    const char *err, *s;
    Eet_File *ef;
    size_t len;
-   char *_file_profile = NULL;
 
    if ((s = getenv("ELM_PROFILE_NOSAVE")) && atoi(s))
      return EINA_TRUE;
 
-   _file_profile = _elm_config_profile_name_get();
-
-   if (!_file_profile || strcmp(_elm_profile, _file_profile))
-     {
-        len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
-        if (len + 1 >= sizeof(buf))
-          return EINA_FALSE;
-
-        len = _elm_config_user_dir_snprintf(buf2, sizeof(buf2),
-                                          "config/profile.cfg.tmp");
-        if (len + 1 >= sizeof(buf2))
-          return EINA_FALSE;
+   len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
+   if (len + 1 >= sizeof(buf))
+     return EINA_FALSE;
 
-        ef = eet_open(buf2, EET_FILE_MODE_WRITE);
-        if (!ef)
-          return EINA_FALSE;
+   len = _elm_config_user_dir_snprintf(buf2, sizeof(buf2),
+                                       "config/profile.cfg.tmp");
+   if (len + 1 >= sizeof(buf2))
+     return EINA_FALSE;
 
-        ok = eet_write(ef, "config", _elm_profile, strlen(_elm_profile), 0);
-        if (!ok)
-          goto err;
+   ef = eet_open(buf2, EET_FILE_MODE_WRITE);
+   if (!ef)
+     return EINA_FALSE;
 
-        err = _elm_config_eet_close_error_get(ef, buf2);
-        if (err)
-          {
-             ERR("%s", err);
-             free((void *)err);
-             goto err;
-          }
+   ok = eet_write(ef, "config", _elm_profile, strlen(_elm_profile), 0);
+   if (!ok)
+     goto err;
 
-        ret = ecore_file_cp(buf2, buf);
-        if (!ret)
-          {
-             ERR("Error saving Elementary's configuration profile file");
-             goto err;
-          }
+   err = _elm_config_eet_close_error_get(ef, buf2);
+   if (err)
+     {
+        ERR("%s", err);
+        free((void *)err);
+        goto err;
+     }
 
-        ecore_file_unlink(buf2);
+   ret = ecore_file_cp(buf2, buf);
+   if (!ret)
+     {
+        ERR("Error saving Elementary's configuration profile file");
+        goto err;
      }
-   free(_file_profile);
+
+   ecore_file_unlink(buf2);
 
    derived = _elm_config_derived_load(profile ? profile : _elm_profile);
    if (derived)
@@ -2753,10 +2715,10 @@ _env_get(void)
           eina_stringshare_replace(&_elm_config->engine, s);
         else if ((!strcasecmp(s, "ews")))
           eina_stringshare_replace(&_elm_config->engine, ELM_EWS);
-        else if ((!strcasecmp(s, "wayland_shm")) || 
+        else if ((!strcasecmp(s, "wayland_shm")) ||
                  (!strcasecmp(s, "wayland-shm")))
           eina_stringshare_replace(&_elm_config->engine, ELM_WAYLAND_SHM);
-        else if ((!strcasecmp(s, "wayland_egl")) || 
+        else if ((!strcasecmp(s, "wayland_egl")) ||
                  (!strcasecmp(s, "wayland-egl")))
           eina_stringshare_replace(&_elm_config->engine, ELM_WAYLAND_EGL);
         else if ((!strcasecmp(s, "drm")))
@@ -3281,7 +3243,7 @@ elm_config_save(void)
 EAPI void
 elm_config_reload(void)
 {
-   _elm_config_reload(EINA_FALSE);
+   _elm_config_reload();
 }
 
 EAPI const char *
@@ -4460,10 +4422,9 @@ elm_config_popup_scrollable_set(Eina_Bool scrollable)
 EAPI void
 elm_config_all_flush(void)
 {
-   char buf[PATH_MAX], buf2[PATH_MAX];
+   char buf[PATH_MAX];
    int ok = 0;
    size_t len;
-   Eet_File *ef = NULL;
 
    len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "themes/");
    if (len + 1 >= sizeof(buf))
@@ -4495,27 +4456,6 @@ elm_config_all_flush(void)
         return;
      }
 
-  _elm_config_user_dir_snprintf(buf, sizeof(buf),
-                                          "config/%s/.base.flush.cfg.tmp", _elm_profile);
-
-  _elm_config_user_dir_snprintf(buf2, sizeof(buf2),
-                                          "config/%s/.base.flush.cfg", _elm_profile);
-
-   ef = eet_open(buf, EET_FILE_MODE_WRITE);
-   if (ef)
-     {
-        ok = eet_data_write(ef, _config_edd, "config", _elm_config, 1);
-        if (!ok)
-          {
-             eet_close(ef);
-             ERR("Failed to save config");
-             return;
-          }
-        eet_close(ef);
-        ecore_file_cp(buf, buf2);
-     }
-   ecore_file_unlink(buf);
-
    elm_config_save();
    return;
 }
@@ -4561,7 +4501,7 @@ _elm_config_init(void)
    _desc_init();
    _elm_config_profile_derived_init();
    _profile_fetch_from_conf();
-   _config_load(EINA_FALSE);
+   _config_load();
    if (_elm_config) _env_get();
    ELM_SAFE_FREE(_elm_accel_preference, eina_stringshare_del);
    ELM_SAFE_FREE(_elm_gl_preference, eina_stringshare_del);
@@ -4589,27 +4529,17 @@ _elm_config_sub_shutdown(void)
    ELM_SAFE_FREE(_eio_profile_monitor, eio_monitor_del);
    ELM_SAFE_FREE(_config_change_delay_timer, ecore_timer_del);
    ELM_SAFE_FREE(_config_profile_change_delay_timer, ecore_timer_del);
-   ELM_SAFE_FREE(_monitor_file_modified_handler, ecore_event_handler_del);
+   ELM_SAFE_FREE(_monitor_file_created_handler, ecore_event_handler_del);
+   ELM_SAFE_FREE(_monitor_directory_created_handler, ecore_event_handler_del);
 }
 
 static Eina_Bool
 _config_profile_change_delay_cb(void *data EINA_UNUSED)
 {
    char *pprof = NULL;
-   char buf[PATH_MAX];
 
    if (_elm_profile) pprof = strdup(_elm_profile);
    _profile_fetch_from_conf();
-
-   _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg", _elm_profile);
-   if(!ecore_file_exists(buf)) _file_touch(buf);
-
-   _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s/.base.flush.cfg", _elm_profile);
-   if(!ecore_file_exists(buf)) _file_touch(buf);
-
-   ELM_SAFE_FREE(_eio_config_monitor, eio_monitor_del);
-   _eio_config_monitor = eio_monitor_add(buf);
-
    if ((!pprof) || (!(!strcmp(pprof, _elm_profile))))
      {
         _config_flush_get();
@@ -4622,7 +4552,7 @@ _config_profile_change_delay_cb(void *data EINA_UNUSED)
 static Eina_Bool
 _config_change_delay_cb(void *data EINA_UNUSED)
 {
-   _elm_config_reload(EINA_TRUE);
+   _elm_config_reload();
 
    _config_change_delay_timer = NULL;
    return ECORE_CALLBACK_CANCEL;
@@ -4638,21 +4568,42 @@ _elm_config_file_monitor_cb(void *data EINA_UNUSED,
 
    if (ev->monitor == _eio_config_monitor)
      {
-        if (!strcmp(file, ".base.flush.cfg"))
+        if (type == EIO_MONITOR_FILE_CREATED)
           {
-             if (_config_change_delay_timer)
-               ecore_timer_del(_config_change_delay_timer);
-             _config_change_delay_timer = ecore_timer_add(0.1, _config_change_delay_cb, NULL);
+             if (!strcmp(file, "base.cfg"))
+               {
+                  if (_config_change_delay_timer)
+                    ecore_timer_del(_config_change_delay_timer);
+                  _config_change_delay_timer = ecore_timer_add(0.1, _config_change_delay_cb, NULL);
+               }
           }
      }
-
    if (ev->monitor == _eio_profile_monitor)
      {
-        if (!strcmp(file, "profile.cfg"))
+        if (type == EIO_MONITOR_FILE_CREATED)
+          {
+             if ((!_config_profile_lock) && (!strcmp(file, "profile.cfg")))
+               {
+                  if (_config_profile_change_delay_timer)
+                    ecore_timer_del(_config_profile_change_delay_timer);
+                  _config_profile_change_delay_timer = ecore_timer_add(0.1, _config_profile_change_delay_cb, NULL);
+               }
+          }
+        else if (type == EIO_MONITOR_DIRECTORY_CREATED)
           {
-             if (_config_profile_change_delay_timer)
-               ecore_timer_del(_config_profile_change_delay_timer);
-             _config_profile_change_delay_timer = ecore_timer_add(0.1, _config_profile_change_delay_cb, NULL);
+             if (!_eio_config_monitor)
+               {
+                  char buf[PATH_MAX];
+
+                  _eio_config_monitor = eio_monitor_add(ev->filename);
+                  snprintf(buf, sizeof(buf), "%s/base.cfg", ev->filename);
+                  if (ecore_file_exists(buf))
+                    {
+                       if (_config_change_delay_timer)
+                         ecore_timer_del(_config_change_delay_timer);
+                       _config_change_delay_timer = ecore_timer_add(0.1, _config_change_delay_cb, NULL);
+                    }
+               }
           }
      }
 
@@ -4679,29 +4630,18 @@ _elm_config_sub_init(void)
             buf);
         goto end;
      }
-
-   _elm_config_profile_save(NULL);
-
-   _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
-   if(!ecore_file_exists(buf)) _file_touch(buf);
    _eio_profile_monitor = eio_monitor_add(buf);
-
-   _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg", _elm_profile);
-   if(!ecore_file_exists(buf)) _file_touch(buf);
-
-   _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s/.base.flush.cfg", _elm_profile);
-   if(!ecore_file_exists(buf)) _file_touch(buf);
-   _eio_config_monitor = eio_monitor_add(buf);
-
-   _monitor_file_modified_handler = ecore_event_handler_add
-     (EIO_MONITOR_FILE_MODIFIED, _elm_config_file_monitor_cb, NULL);
+   _monitor_file_created_handler = ecore_event_handler_add
+     (EIO_MONITOR_FILE_CREATED, _elm_config_file_monitor_cb, NULL);
+   _monitor_directory_created_handler = ecore_event_handler_add
+     (EIO_MONITOR_DIRECTORY_CREATED, _elm_config_file_monitor_cb, NULL);
 
 end:
    _config_sub_apply();
 }
 
 void
-_elm_config_reload(Eina_Bool on_flush)
+_elm_config_reload(void)
 {
    Eina_Bool is_mirrored;
    Eina_Bool translate;
@@ -4735,8 +4675,8 @@ _elm_config_reload(Eina_Bool on_flush)
    is_mirrored = _elm_config->is_mirrored;
    translate = _elm_config->translate;
 
-   _elm_config_reload_do(on_flush);
-   
+   _elm_config_reload_do();
+
    /* restore prev value which is not part of the EET file */
    _elm_config->is_mirrored = is_mirrored;
    _elm_config->translate = translate;
@@ -5047,7 +4987,6 @@ _elm_config_profile_set(const char *profile)
    Eina_Bool translate;
    is_mirrored = _elm_config->is_mirrored;
    translate = _elm_config->translate;
-   char buf[PATH_MAX];
 
    if (!profile) return;
 
@@ -5061,15 +5000,9 @@ _elm_config_profile_set(const char *profile)
 
    _elm_profile = strdup(profile);
 
-   _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s/base.cfg", _elm_profile);
-   if(!ecore_file_exists(buf)) _file_touch(buf);
-
-   _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/%s/.base.flush.cfg", _elm_profile);
-   if(!ecore_file_exists(buf)) _file_touch(buf);
-
    _color_overlays_cancel();
 
-   _elm_config_reload_do(EINA_FALSE);
+   _elm_config_reload_do();
 
    /* restore prev value which is not part of the EET file */
    _elm_config->is_mirrored = is_mirrored;
@@ -5662,25 +5595,6 @@ EOLIAN static void
 _efl_config_global_profile_derived_del(Eo *obj EINA_UNUSED, void *_pd EINA_UNUSED, const char *profile)
 {
    elm_config_profile_derived_del(profile);
-
-}
-static Eina_Bool
-_file_touch(const char *file)
-{
-   if (!file) return EINA_FALSE;
-
-   const char *dir = ecore_file_dir_get(file);
-   if(!dir) return EINA_FALSE;
-   if(!ecore_file_mkpath(dir)) return EINA_FALSE;
-
-   Eo *f = efl_add_ref(EFL_IO_FILE_CLASS, NULL,
-                    efl_file_set(efl_added, file, NULL),
-                    efl_io_file_flags_set(efl_added, O_CREAT|O_RDWR),
-                    efl_io_file_mode_set(efl_added, 0644));
-   if (!f) return EINA_FALSE;
-   efl_unref(f);
-
-   return EINA_TRUE;
 }
 
 #include "efl_config_global.eo.c"
index 4cca834..d208db9 100644 (file)
@@ -660,7 +660,7 @@ void                 _elm_config_sub_init(void);
 void                 _elm_config_shutdown(void);
 void                 _elm_config_sub_shutdown(void);
 Eina_Bool            _elm_config_save(Elm_Config *cfg, const char *profile);
-void                 _elm_config_reload(Eina_Bool on_flush);
+void                 _elm_config_reload(void);
 size_t               _elm_config_user_dir_snprintf(char *dst, size_t size,
                                                    const char *fmt, ...)
                                                    EINA_PRINTF(3, 4);