diff options
author | RĂ©mi Verschelde <rverschelde@gmail.com> | 2017-07-27 08:53:27 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-27 08:53:27 +0200 |
commit | 411f09a512d5847fc9c6270439308d1e3093f211 (patch) | |
tree | cb8dcdba0642670d676ab00f78f223a50a93539e /platform/x11 | |
parent | 6645c7cc180274c9c9b23cbe6271ce5f04df20a9 (diff) | |
parent | 71dcb7fcc4b10e956668485b7ac1f9a5c1735dfb (diff) |
Merge pull request #9887 from StraToN/power-fix-x11
Fix power management on x11 platform and removes explicit NULL pointer dereference
Diffstat (limited to 'platform/x11')
-rw-r--r-- | platform/x11/os_x11.cpp | 2 | ||||
-rw-r--r-- | platform/x11/power_x11.cpp | 11 |
2 files changed, 4 insertions, 9 deletions
diff --git a/platform/x11/os_x11.cpp b/platform/x11/os_x11.cpp index 5bfe31b8c2..1dde328eda 100644 --- a/platform/x11/os_x11.cpp +++ b/platform/x11/os_x11.cpp @@ -497,6 +497,8 @@ void OS_X11::initialize(const VideoMode &p_desired, int p_video_driver, int p_au joypad = memnew(JoypadLinux(input)); #endif _ensure_data_dir(); + + power_manager = memnew(PowerX11); } void OS_X11::xim_destroy_callback(::XIM im, ::XPointer client_data, diff --git a/platform/x11/power_x11.cpp b/platform/x11/power_x11.cpp index 093d24f406..8e69a2223f 100644 --- a/platform/x11/power_x11.cpp +++ b/platform/x11/power_x11.cpp @@ -171,25 +171,18 @@ void PowerX11::check_proc_acpi_battery(const char *node, bool *have_battery, boo charge = true; } } else if (String(key) == "remaining capacity") { - char *endptr = NULL; - //const int cvt = (int) strtol(val, &endptr, 10); String sval = val; const int cvt = sval.to_int(); - if (*endptr == ' ') { - remaining = cvt; - } + remaining = cvt; } } ptr = &info[0]; while (make_proc_acpi_key_val(&ptr, &key, &val)) { if (String(key) == "design capacity") { - char *endptr = NULL; String sval = val; const int cvt = sval.to_int(); - if (*endptr == ' ') { - maximum = cvt; - } + maximum = cvt; } } |