-
-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
battstat: fix deprecated up_client_get_devices #487
Conversation
The previous code would have leaked all the UpDevice objects because no free function was set on the returned GPtrArray. With depending on upower-glib 0.99.8 get_devices() was deprecated and get_devices2() was introduced, we can simply switch to get_devices2() which does set a free function on the returned GPtrArray, stopping the leak.
I think that we can also bump upower to 0.99.8 and remove legacy code. Line 21 in 01e8f8a
|
You're right, done. |
e203325
to
60e6dd1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Test:
$ CFLAGS="-fsanitize=leak -fno-omit-frame-pointer -g -ggdb3 -O0" LDFLAGS="-fsanitize=leak -ggdb3" ./autogen.sh --prefix=/usr && make && sudo make install
Origin comment was taken from mate-desktop/mate-power-manager@9d5b257 I think it is more a leak in upower itself. |
Using a global variable makes more sense like in #443, since the list of devices is updated dynamically and specific events are triggered. |
I only wanted to fix the deprecation. Any improvements can be done in another PR. |
The previous code would have leaked all the UpDevice objects because no
free function was set on the returned GPtrArray.
With depending on upower-glib 0.99.8 get_devices() was deprecated and get_devices2() was introduced, we
can simply switch to get_devices2() which does set a free function on
the returned GPtrArray, stopping the leak.