Fixed segfault on upower service restart
This commit is contained in:
parent
d1d73b5003
commit
0140606226
|
@ -347,7 +347,7 @@ auto UPower::update() -> void {
|
||||||
label_.set_markup(onlySpaces ? "" : label_format);
|
label_.set_markup(onlySpaces ? "" : label_format);
|
||||||
|
|
||||||
// Set icon
|
// Set icon
|
||||||
if (!Gtk::IconTheme::get_default()->has_icon(icon_name)) {
|
if (icon_name == NULL || !Gtk::IconTheme::get_default()->has_icon(icon_name)) {
|
||||||
icon_name = (char*)"battery-missing-symbolic";
|
icon_name = (char*)"battery-missing-symbolic";
|
||||||
}
|
}
|
||||||
icon_.set_from_icon_name(icon_name, Gtk::ICON_SIZE_INVALID);
|
icon_.set_from_icon_name(icon_name, Gtk::ICON_SIZE_INVALID);
|
||||||
|
|
|
@ -62,7 +62,9 @@ uint UPowerTooltip::updateTooltip(Devices& devices) {
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
// Skip Line_Power and BAT0 devices
|
// Skip Line_Power and BAT0 devices
|
||||||
if (kind == UP_DEVICE_KIND_LINE_POWER || strcmp(native_path, "BAT0") == 0) continue;
|
if (kind == UP_DEVICE_KIND_LINE_POWER || native_path == NULL || strlen(native_path) == 0 ||
|
||||||
|
strcmp(native_path, "BAT0") == 0)
|
||||||
|
continue;
|
||||||
|
|
||||||
Gtk::Box* modelBox = new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL);
|
Gtk::Box* modelBox = new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL);
|
||||||
box->add(*modelBox);
|
box->add(*modelBox);
|
||||||
|
@ -77,6 +79,7 @@ uint UPowerTooltip::updateTooltip(Devices& devices) {
|
||||||
modelBox->add(*deviceIcon);
|
modelBox->add(*deviceIcon);
|
||||||
|
|
||||||
// Set model
|
// Set model
|
||||||
|
if (model == NULL) model = (gchar*)"";
|
||||||
Gtk::Label* modelLabel = new Gtk::Label(model);
|
Gtk::Label* modelLabel = new Gtk::Label(model);
|
||||||
modelBox->add(*modelLabel);
|
modelBox->add(*modelLabel);
|
||||||
|
|
||||||
|
@ -86,7 +89,7 @@ uint UPowerTooltip::updateTooltip(Devices& devices) {
|
||||||
// Set icon
|
// Set icon
|
||||||
Gtk::Image* icon = new Gtk::Image();
|
Gtk::Image* icon = new Gtk::Image();
|
||||||
icon->set_pixel_size(iconSize);
|
icon->set_pixel_size(iconSize);
|
||||||
if (!Gtk::IconTheme::get_default()->has_icon(icon_name)) {
|
if (icon_name == NULL || !Gtk::IconTheme::get_default()->has_icon(icon_name)) {
|
||||||
icon_name = (char*)"battery-missing-symbolic";
|
icon_name = (char*)"battery-missing-symbolic";
|
||||||
}
|
}
|
||||||
icon->set_from_icon_name(icon_name, Gtk::ICON_SIZE_INVALID);
|
icon->set_from_icon_name(icon_name, Gtk::ICON_SIZE_INVALID);
|
||||||
|
|
Loading…
Reference in New Issue