diff --git a/src/modules/upower/upower.cpp b/src/modules/upower/upower.cpp index 00b69aaf..30326790 100644 --- a/src/modules/upower/upower.cpp +++ b/src/modules/upower/upower.cpp @@ -347,7 +347,7 @@ auto UPower::update() -> void { label_.set_markup(onlySpaces ? "" : label_format); // 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_.set_from_icon_name(icon_name, Gtk::ICON_SIZE_INVALID); diff --git a/src/modules/upower/upower_tooltip.cpp b/src/modules/upower/upower_tooltip.cpp index 644b8e08..8aaba924 100644 --- a/src/modules/upower/upower_tooltip.cpp +++ b/src/modules/upower/upower_tooltip.cpp @@ -62,7 +62,9 @@ uint UPowerTooltip::updateTooltip(Devices& devices) { NULL); // 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); box->add(*modelBox); @@ -77,6 +79,7 @@ uint UPowerTooltip::updateTooltip(Devices& devices) { modelBox->add(*deviceIcon); // Set model + if (model == NULL) model = (gchar*)""; Gtk::Label* modelLabel = new Gtk::Label(model); modelBox->add(*modelLabel); @@ -86,7 +89,7 @@ uint UPowerTooltip::updateTooltip(Devices& devices) { // Set icon Gtk::Image* icon = new Gtk::Image(); 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->set_from_icon_name(icon_name, Gtk::ICON_SIZE_INVALID);