Revert "elm_config: fix elm_config_save not to wake idle processes up"

This reverts commit 8b0b9ed281.

There have been issues with this commit, for further informations,
please see https://phab.enlightenment.org/D7354 for more details.
This commit is contained in:
Marcel Hollerbach 2019-02-13 12:30:00 +01:00
parent bad145f313
commit 9ad84605b6
3 changed files with 92 additions and 179 deletions

View File

@ -1488,7 +1488,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;

View 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)
@ -1626,19 +1624,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)
@ -1691,7 +1690,7 @@ _efl_config_obj_del(Eo *obj EINA_UNUSED)
}
static void
_config_load(Eina_Bool on_flush)
_config_load(void)
{
if (_efl_config_obj)
{
@ -1710,7 +1709,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)
@ -1880,13 +1879,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) \
@ -2107,7 +2106,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;
@ -2191,36 +2190,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)
{
@ -2230,50 +2199,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();
len = _elm_config_user_dir_snprintf(buf, sizeof(buf), "config/profile.cfg");
if (len + 1 >= sizeof(buf))
return EINA_FALSE;
if (!_file_profile || strcmp(_elm_profile, _file_profile))
len = _elm_config_user_dir_snprintf(buf2, sizeof(buf2),
"config/profile.cfg.tmp");
if (len + 1 >= sizeof(buf2))
return EINA_FALSE;
ef = eet_open(buf2, EET_FILE_MODE_WRITE);
if (!ef)
return EINA_FALSE;
ok = eet_write(ef, "config", _elm_profile, strlen(_elm_profile), 0);
if (!ok)
goto err;
err = _elm_config_eet_close_error_get(ef, buf2);
if (err)
{
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;
ef = eet_open(buf2, EET_FILE_MODE_WRITE);
if (!ef)
return EINA_FALSE;
ok = eet_write(ef, "config", _elm_profile, strlen(_elm_profile), 0);
if (!ok)
goto err;
err = _elm_config_eet_close_error_get(ef, buf2);
if (err)
{
ERR("%s", err);
free((void *)err);
goto err;
}
ret = ecore_file_cp(buf2, buf);
if (!ret)
{
ERR("Error saving Elementary's configuration profile file");
goto err;
}
ecore_file_unlink(buf2);
ERR("%s", err);
free((void *)err);
goto err;
}
free(_file_profile);
ret = ecore_file_cp(buf2, buf);
if (!ret)
{
ERR("Error saving Elementary's configuration profile file");
goto err;
}
ecore_file_unlink(buf2);
derived = _elm_config_derived_load(profile ? profile : _elm_profile);
if (derived)
@ -2595,10 +2557,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")))
@ -3106,7 +3068,7 @@ elm_config_save(void)
EAPI void
elm_config_reload(void)
{
_elm_config_reload(EINA_FALSE);
_elm_config_reload();
}
EAPI const char *
@ -4245,10 +4207,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))
@ -4280,27 +4241,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;
}
@ -4346,7 +4286,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);
@ -4374,27 +4314,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();
@ -4407,7 +4337,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;
@ -4423,21 +4353,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_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 ((!_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 (!_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);
}
}
}
}
@ -4464,29 +4415,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;
@ -4520,8 +4460,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;
@ -4806,7 +4746,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;
@ -4820,15 +4759,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;
@ -5392,25 +5325,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"

View File

@ -644,7 +644,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);