fix: some crashes

This commit is contained in:
Alex
2026-02-24 00:49:03 +01:00
parent a32413a74f
commit ef3d55980e
40 changed files with 216 additions and 103 deletions

View File

@@ -117,7 +117,7 @@ Mpris::Mpris(const std::string& id, const Json::Value& config)
}
GError* error = nullptr;
waybar::util::ScopeGuard error_deleter([error]() {
waybar::util::ScopeGuard error_deleter([&error]() {
if (error) {
g_error_free(error);
}
@@ -478,7 +478,7 @@ auto Mpris::getPlayerInfo() -> std::optional<PlayerInfo> {
}
GError* error = nullptr;
waybar::util::ScopeGuard error_deleter([error]() {
waybar::util::ScopeGuard error_deleter([&error]() {
if (error) {
g_error_free(error);
}
@@ -543,6 +543,10 @@ auto Mpris::getPlayerInfo() -> std::optional<PlayerInfo> {
g_object_get(last_active_player_, "status", &player_status, "playback-status",
&player_playback_status, NULL);
if (!player_status) {
spdlog::error("mpris: failed to get player status");
return std::nullopt;
}
// make status lowercase
player_status[0] = std::tolower(player_status[0]);