Merge pull request #9887 from StraToN/power-fix-x11
Fix power management on x11 platform and removes explicit NULL pointer dereference
This commit is contained in:
commit
411f09a512
2 changed files with 4 additions and 9 deletions
|
@ -497,6 +497,8 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au
|
||||||
joypad = memnew(JoypadLinux(input));
|
joypad = memnew(JoypadLinux(input));
|
||||||
#endif
|
#endif
|
||||||
_ensure_data_dir();
|
_ensure_data_dir();
|
||||||
|
|
||||||
|
power_manager = memnew(PowerX11);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OS_X11::xim_destroy_callback(::XIM im, ::XPointer client_data,
|
void OS_X11::xim_destroy_callback(::XIM im, ::XPointer client_data,
|
||||||
|
|
|
@ -171,27 +171,20 @@ void PowerX11::check_proc_acpi_battery(const char *node, bool *have_battery, boo
|
||||||
charge = true;
|
charge = true;
|
||||||
}
|
}
|
||||||
} else if (String(key) == "remaining capacity") {
|
} else if (String(key) == "remaining capacity") {
|
||||||
char *endptr = NULL;
|
|
||||||
//const int cvt = (int) strtol(val, &endptr, 10);
|
|
||||||
String sval = val;
|
String sval = val;
|
||||||
const int cvt = sval.to_int();
|
const int cvt = sval.to_int();
|
||||||
if (*endptr == ' ') {
|
|
||||||
remaining = cvt;
|
remaining = cvt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ptr = &info[0];
|
ptr = &info[0];
|
||||||
while (make_proc_acpi_key_val(&ptr, &key, &val)) {
|
while (make_proc_acpi_key_val(&ptr, &key, &val)) {
|
||||||
if (String(key) == "design capacity") {
|
if (String(key) == "design capacity") {
|
||||||
char *endptr = NULL;
|
|
||||||
String sval = val;
|
String sval = val;
|
||||||
const int cvt = sval.to_int();
|
const int cvt = sval.to_int();
|
||||||
if (*endptr == ' ') {
|
|
||||||
maximum = cvt;
|
maximum = cvt;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if ((maximum >= 0) && (remaining >= 0)) {
|
if ((maximum >= 0) && (remaining >= 0)) {
|
||||||
pct = (int)((((float)remaining) / ((float)maximum)) * 100.0f);
|
pct = (int)((((float)remaining) / ((float)maximum)) * 100.0f);
|
||||||
|
|
Loading…
Reference in a new issue