temp - bring back temp sesor select and nuke leaks on init

This commit is contained in:
Carsten Haitzler 2020-08-20 15:20:22 +01:00
parent ffbb8464f2
commit beb6041646
3 changed files with 35 additions and 21 deletions

View File

@ -145,9 +145,12 @@ _fill_data_tempget(E_Config_Dialog_Data *cfdata)
EINA_LIST_FREE(l, name) EINA_LIST_FREE(l, name)
{ {
cfdata->sensors = cfdata->sensors =
eina_list_append(cfdata->sensors, name); eina_list_append(cfdata->sensors, name);
if (!strcmp(cfdata->inst->sensor_name, name)) if (cfdata->inst->sensor_name)
cfdata->sensor = n; {
if (!strcmp(cfdata->inst->sensor_name, name))
cfdata->sensor = n;
}
n++; n++;
} }
} }
@ -167,9 +170,12 @@ _fill_data_tempget(E_Config_Dialog_Data *cfdata)
if (!strncmp(name, "thermal", 7)) if (!strncmp(name, "thermal", 7))
{ {
cfdata->sensors = cfdata->sensors =
eina_list_append(cfdata->sensors, name); eina_list_append(cfdata->sensors, name);
if (!strcmp(cfdata->inst->sensor_name, name)) if (cfdata->inst->sensor_name)
cfdata->sensor = n; {
if (!strcmp(cfdata->inst->sensor_name, name))
cfdata->sensor = n;
}
n++; n++;
} }
} }
@ -209,7 +215,10 @@ _fill_sensors(E_Config_Dialog_Data *cfdata, const char *name)
} }
EINA_LIST_FOREACH(cfdata->sensors, l, n) EINA_LIST_FOREACH(cfdata->sensors, l, n)
{ {
if (!strcmp(cfdata->inst->sensor_name, n)) break; if (cfdata->inst->sensor_name)
{
if (!strcmp(cfdata->inst->sensor_name, n)) break;
}
cfdata->sensor++; cfdata->sensor++;
} }
} }

View File

@ -123,7 +123,7 @@ _gc_init(E_Gadcon *gc, const char *name, const char *id, const char *style)
inst->poll_interval = 128; inst->poll_interval = 128;
inst->low = 30; inst->low = 30;
inst->high = 80; inst->high = 80;
inst->sensor_type = SENSOR_TYPE_NONE; inst->sensor_type = SENSOR_TYPE_LINUX_SYS;
inst->sensor_name = NULL; inst->sensor_name = NULL;
inst->temp = -900; inst->temp = -900;
inst->units = CELSIUS; inst->units = CELSIUS;
@ -207,7 +207,7 @@ _gc_id_new(const E_Gadcon_Client_Class *client_class EINA_UNUSED)
inst->poll_interval = 128; inst->poll_interval = 128;
inst->low = 30; inst->low = 30;
inst->high = 80; inst->high = 80;
inst->sensor_type = SENSOR_TYPE_NONE; inst->sensor_type = SENSOR_TYPE_LINUX_SYS;
inst->sensor_name = NULL; inst->sensor_name = NULL;
inst->units = CELSIUS; inst->units = CELSIUS;
if (!temperature_config->faces) if (!temperature_config->faces)
@ -271,16 +271,22 @@ _temperature_face_shutdown(const Eina_Hash *hash EINA_UNUSED, const void *key EI
} }
static Eina_Bool static Eina_Bool
_temperature_face_id_max(const Eina_Hash *hash EINA_UNUSED, const void *key, void *hdata EINA_UNUSED, void *fdata) _temperature_face_id_max(const Eina_Hash *hash EINA_UNUSED, const void *key, void *hdata, void *fdata)
{ {
const char *p; const char *p;
int *max; int *max;
int num = -1; int num = -1;
Config_Face *cf = hdata;
max = fdata; max = fdata;
p = strrchr(key, '.'); p = strrchr(key, '.');
if (p) num = atoi(p + 1); if (p) num = atoi(p + 1);
if (num > *max) *max = num; if (num > *max) *max = num;
#if defined (__FreeBSD__) || defined(__DragonFly__) || defined (__OpenBSD__)
cf->sensor_type = SENSOR_TYPE_FREEBSD;
#else
cf->sensor_type = SENSOR_TYPE_LINUX_SYS;
#endif
return EINA_TRUE; return EINA_TRUE;
} }

View File

@ -8,11 +8,11 @@
#endif #endif
#ifdef __OpenBSD__ #ifdef __OpenBSD__
#include <sys/param.h> # include <sys/param.h>
#include <sys/sysctl.h> # include <sys/sysctl.h>
#include <sys/sensors.h> # include <sys/sensors.h>
#include <errno.h> # include <errno.h>
#include <err.h> # include <err.h>
#endif #endif
typedef struct typedef struct
@ -163,11 +163,10 @@ init(Tempthread *tth)
name = eina_list_data_get(therms); name = eina_list_data_get(therms);
tth->sensor_type = SENSOR_TYPE_LINUX_ACPI; tth->sensor_type = SENSOR_TYPE_LINUX_ACPI;
tth->sensor_name = eina_stringshare_add(name); tth->sensor_name = eina_stringshare_add(name);
eina_list_free(therms); EINA_LIST_FREE(therms, name) free(name);
} }
else else
{ {
eina_list_free(therms);
therms = ecore_file_ls("/sys/class/thermal"); therms = ecore_file_ls("/sys/class/thermal");
if (therms) if (therms)
{ {
@ -185,9 +184,9 @@ init(Tempthread *tth)
break; break;
} }
} }
if (therms) eina_list_free(therms); EINA_LIST_FREE(therms, name) free(name);
} }
if (therms) else
{ {
if (ecore_file_exists("/proc/omnibook/temperature")) if (ecore_file_exists("/proc/omnibook/temperature"))
{ {
@ -237,7 +236,7 @@ init(Tempthread *tth)
tth->sensor_name = eina_stringshare_add(path); tth->sensor_name = eina_stringshare_add(path);
} }
} }
eina_list_free(therms); EINA_LIST_FREE(therms, name) free(name);
} }
if (!tth->sensor_path) if (!tth->sensor_path)
{ {
@ -263,7 +262,7 @@ init(Tempthread *tth)
tth->sensor_name = eina_stringshare_add(path); tth->sensor_name = eina_stringshare_add(path);
} }
} }
eina_list_free(therms); EINA_LIST_FREE(therms, name) free(name);
} }
} }
} }