BugFix CountVisitor

This commit is contained in:
Bruno Herbelin
2022-04-09 15:07:55 +02:00
parent edffcf8902
commit 54a23f5ae7
3 changed files with 23 additions and 11 deletions

View File

@@ -79,14 +79,22 @@ void CountVisitor::visit (MediaSource& s)
void CountVisitor::visit (SessionFileSource& s)
{
num_source_ += s.session()->numSources();
if (s.session() != nullptr)
num_source_ += s.session()->numSources();
else
++num_source_;
if (s.playable())
++num_playable_;
}
void CountVisitor::visit (SessionGroupSource& s)
{
num_source_ += s.session()->numSources();
if (s.session() != nullptr)
num_source_ += s.session()->numSources();
else
++num_source_;
if (s.playable())
++num_playable_;
}

View File

@@ -151,7 +151,7 @@ void Mixer::update()
// cosmetics saved ok
Rendering::manager().setMainWindowTitle(SystemToolkit::filename(filename));
Settings::application.recentSessions.push(filename);
Log::Notify("Session %s saved.", filename.c_str());
Log::Notify("Session '%s' saved.", filename.c_str());
}
busy_ = false;
}
@@ -274,7 +274,7 @@ Source * Mixer::createSourceFile(const std::string &path)
}
else {
Settings::application.recentImport.remove(path);
Log::Notify("File %s does not exist.", path.c_str());
Log::Notify("File '%s' does not exist.", path.c_str());
}
return s;
@@ -1396,9 +1396,9 @@ void Mixer::swap()
Action::manager().init();
// notification
uint N = session_->numSources();
std::string numsource = ( N>0 ? std::to_string(N) : "No" ) + " source" + (N>1 ? "s" : "");
Log::Notify("Session %s loaded. %s created.", session_->filename().c_str(), numsource.c_str());
uint N = session_->size();
std::string numsource = ( N>0 ? std::to_string(N) : "no" ) + " source" + (N>1 ? "s" : "");
Log::Notify("Session '%s' loaded with %s.", session_->filename().c_str(), numsource.c_str());
}
void Mixer::close(bool smooth)

View File

@@ -440,11 +440,15 @@ uint Session::size() const
uint Session::numSources() const
{
CountVisitor counter;
for( SourceList::const_iterator it = sources_.cbegin(); it != sources_.cend(); ++it) {
(*it)->accept(counter);
if (true) {
CountVisitor counter;
for( SourceList::const_iterator it = sources_.cbegin(); it != sources_.cend(); ++it) {
(*it)->accept(counter);
}
return counter.numSources();
}
return counter.numSources();
else
return size();
}