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:
@@ -491,7 +491,13 @@ auto Mpris::getPlayerInfo() -> std::optional<PlayerInfo> {
|
||||
continue;
|
||||
}
|
||||
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) {
|
||||
first_valid_player = tmp;
|
||||
first_valid_name = name;
|
||||
|
||||
Reference in New Issue
Block a user