fix(mpris): clear stale GError in playerctld selection loop

When playerctl_player_new_from_name() fails for a candidate player, the
loop continued without clearing the GError. The stale non-NULL error then
leaked into the next GLib call (GLib-CRITICAL assertion) and made the
post-loop 'if (error) goto errorexit' fire even when a valid playing
player had been selected, blanking the whole module. Clear the error at
the discard point with g_clear_error().
This commit is contained in:
Alex
2026-07-05 10:13:24 +02:00
parent b17743ff6a
commit 88064137ca
+7 -1
View File
@@ -491,7 +491,13 @@ auto Mpris::getPlayerInfo() -> std::optional<PlayerInfo> {
continue; continue;
} }
auto* tmp = playerctl_player_new_from_name(pn, &error); auto* tmp = playerctl_player_new_from_name(pn, &error);
if (error || !tmp) continue; if (error || !tmp) {
// Discard any error from this candidate so it doesn't leak into the next
// playerctl_player_new_from_name() call or the post-loop metadata calls, which
// assert that the passed GError is NULL (otherwise: GLib-CRITICAL / spurious errorexit).
g_clear_error(&error);
continue;
}
if (!first_valid_player) { if (!first_valid_player) {
first_valid_player = tmp; first_valid_player = tmp;
first_valid_name = name; first_valid_name = name;