mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-12 10:49:59 +01:00
Fixed unique source name algorithm
This commit is contained in:
@@ -658,14 +658,11 @@ void Mixer::renameSource(Source *s, const std::string &newname)
|
||||
// tentative new name
|
||||
std::string tentativename = s->name();
|
||||
|
||||
std::list<std::string> others = session_->getNameList();
|
||||
others.remove(tentativename);
|
||||
|
||||
// try the given new name if valid
|
||||
if ( !newname.empty() )
|
||||
tentativename = newname;
|
||||
|
||||
tentativename = BaseToolkit::uniqueName(tentativename, others);
|
||||
tentativename = BaseToolkit::uniqueName(tentativename, session_->getNameList(s->id()));
|
||||
|
||||
// ok to rename
|
||||
s->setName(tentativename);
|
||||
|
||||
@@ -287,12 +287,14 @@ SourceIdList Session::getIdList() const
|
||||
return ids(sources_);
|
||||
}
|
||||
|
||||
std::list<std::string> Session::getNameList() const
|
||||
std::list<std::string> Session::getNameList(uint64_t exceptid) const
|
||||
{
|
||||
std::list<std::string> namelist;
|
||||
|
||||
for( SourceList::const_iterator it = sources_.cbegin(); it != sources_.cend(); ++it)
|
||||
for( SourceList::const_iterator it = sources_.cbegin(); it != sources_.cend(); ++it) {
|
||||
if ( (*it)->id() != exceptid )
|
||||
namelist.push_back( (*it)->name() );
|
||||
}
|
||||
|
||||
return namelist;
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ public:
|
||||
SourceList::iterator find (uint64_t id);
|
||||
SourceIdList getIdList() const;
|
||||
|
||||
std::list<std::string> getNameList() const;
|
||||
std::list<std::string> getNameList(uint64_t exceptid=0) const;
|
||||
|
||||
SourceList::iterator at (int index);
|
||||
int index (SourceList::iterator it) const;
|
||||
|
||||
Reference in New Issue
Block a user