[gnome-media] Avoid crashing when switching profiles quickly
- From: Bastien Nocera <hadess src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [gnome-media] Avoid crashing when switching profiles quickly
- Date: Thu, 17 Sep 2009 13:04:24 +0000 (UTC)
commit 1c7dbbecaeaef26d6228fc841ce142bdcafec961
Author: Bastien Nocera <hadess hadess net>
Date: Wed Sep 16 16:36:58 2009 +0100
Avoid crashing when switching profiles quickly
When switching profiles quickly, we were getting callbacks
about old operations which we're not interested in, because
they don't match the latest requested profile.
So keep track of the last requested change, and cancel already
running operations when asking for a new profile.
https://bugzilla.gnome.org/show_bug.cgi?id=595438
gnome-volume-control/src/gvc-mixer-card.c | 25 +++++++++++++++----------
1 files changed, 15 insertions(+), 10 deletions(-)
---
diff --git a/gnome-volume-control/src/gvc-mixer-card.c b/gnome-volume-control/src/gvc-mixer-card.c
index 9037ff2..dc4ccca 100644
--- a/gnome-volume-control/src/gvc-mixer-card.c
+++ b/gnome-volume-control/src/gvc-mixer-card.c
@@ -47,6 +47,7 @@ struct GvcMixerCardPrivate
char *target_profile;
char *human_profile;
GList *profiles;
+ pa_operation *profile_op;
};
enum
@@ -209,6 +210,9 @@ _pa_context_set_card_profile_by_index_cb (pa_context *cont
}
g_free (card->priv->target_profile);
card->priv->target_profile = NULL;
+
+ pa_operation_unref (card->priv->profile_op);
+ card->priv->profile_op = NULL;
}
gboolean
@@ -223,25 +227,26 @@ gvc_mixer_card_change_profile (GvcMixerCard *card,
return TRUE;
if (g_strcmp0 (profile, card->priv->target_profile) == 0)
return TRUE;
+ if (card->priv->profile_op != NULL) {
+ pa_operation_cancel (card->priv->profile_op);
+ pa_operation_unref (card->priv->profile_op);
+ card->priv->profile_op = NULL;
+ }
if (card->priv->profile != NULL) {
- pa_operation *o;
-
g_free (card->priv->target_profile);
card->priv->target_profile = g_strdup (profile);
- o = pa_context_set_card_profile_by_index (card->priv->pa_context,
- card->priv->index,
- card->priv->target_profile,
- _pa_context_set_card_profile_by_index_cb,
- card);
+ card->priv->profile_op = pa_context_set_card_profile_by_index (card->priv->pa_context,
+ card->priv->index,
+ card->priv->target_profile,
+ _pa_context_set_card_profile_by_index_cb,
+ card);
- if (o == NULL) {
+ if (card->priv->profile_op == NULL) {
g_warning ("pa_context_set_card_profile_by_index() failed");
return FALSE;
}
-
- pa_operation_unref (o);
} else {
g_assert (card->priv->human_profile == NULL);
card->priv->profile = g_strdup (profile);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]