From 4e73145363499f8e33d7a96902023f2785d44a21 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 17 Jun 2009 02:34:22 +0200 Subject: make sure that two card profiles with the same priority don't collide with each other --- src/mainwindow.cc | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/mainwindow.cc b/src/mainwindow.cc index 61156c4..4b56b61 100644 --- a/src/mainwindow.cc +++ b/src/mainwindow.cc @@ -37,8 +37,13 @@ /* Used for profile sorting */ struct profile_prio_compare { - bool operator() (const pa_card_profile_info& lhs, const pa_card_profile_info& rhs) const - {return lhs.priority>rhs.priority;} + bool operator() (const pa_card_profile_info& lhs, const pa_card_profile_info& rhs) const { + + if (lhs.priority == rhs.priority) + return strcmp(lhs.name, rhs.name) > 0; + + return lhs.priority > rhs.priority; + } }; @@ -155,10 +160,12 @@ void MainWindow::updateCard(const pa_card_info &info) { w->hasSources = w->hasSources || (info.profiles[i].n_sources > 0); profile_priorities.insert(info.profiles[i]); } + w->profiles.clear(); - for (std::set::iterator i=profile_priorities.begin(); i != profile_priorities.end(); ++i) { - w->profiles.push_back(std::pair(i->name,i->description)); - } + + for (std::set::iterator i = profile_priorities.begin(); i != profile_priorities.end(); ++i) + w->profiles.push_back(std::pair(i->name, i->description)); + w->activeProfile = info.active_profile->name; w->updating = false; -- cgit