mirror of
https://github.com/brunoherbelin/vimix.git
synced 2025-12-11 18:34:58 +01:00
BugFix: prevent visitors for failed sources. Avoid duplicate list of
source ids.
This commit is contained in:
@@ -393,7 +393,8 @@ void DeviceSource::setDevice(const std::string &devicename)
|
|||||||
void DeviceSource::accept(Visitor& v)
|
void DeviceSource::accept(Visitor& v)
|
||||||
{
|
{
|
||||||
Source::accept(v);
|
Source::accept(v);
|
||||||
v.visit(*this);
|
if (!failed())
|
||||||
|
v.visit(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceSource::failed() const
|
bool DeviceSource::failed() const
|
||||||
|
|||||||
@@ -147,7 +147,8 @@ void PatternSource::setPattern(int type, glm::ivec2 resolution)
|
|||||||
void PatternSource::accept(Visitor& v)
|
void PatternSource::accept(Visitor& v)
|
||||||
{
|
{
|
||||||
Source::accept(v);
|
Source::accept(v);
|
||||||
v.visit(*this);
|
if (!failed())
|
||||||
|
v.visit(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
Pattern *PatternSource::pattern() const
|
Pattern *PatternSource::pattern() const
|
||||||
|
|||||||
@@ -257,6 +257,9 @@ std::list<uint64_t> Session::getIdList() const
|
|||||||
for( auto sit = sources_.begin(); sit != sources_.end(); sit++)
|
for( auto sit = sources_.begin(); sit != sources_.end(); sit++)
|
||||||
idlist.push_back( (*sit)->id() );
|
idlist.push_back( (*sit)->id() );
|
||||||
|
|
||||||
|
// make sure no duplicate
|
||||||
|
idlist.unique();
|
||||||
|
|
||||||
return idlist;
|
return idlist;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -104,6 +104,8 @@ SessionLoader::SessionLoader(Session *session): Visitor(), session_(session)
|
|||||||
|
|
||||||
void SessionLoader::load(XMLElement *sessionNode)
|
void SessionLoader::load(XMLElement *sessionNode)
|
||||||
{
|
{
|
||||||
|
sources_id_.clear();
|
||||||
|
|
||||||
if (sessionNode != nullptr && session_ != nullptr) {
|
if (sessionNode != nullptr && session_ != nullptr) {
|
||||||
|
|
||||||
XMLElement* sourceNode = sessionNode->FirstChildElement("Source");
|
XMLElement* sourceNode = sessionNode->FirstChildElement("Source");
|
||||||
@@ -147,7 +149,6 @@ void SessionLoader::load(XMLElement *sessionNode)
|
|||||||
|
|
||||||
// add source to session
|
// add source to session
|
||||||
session_->addSource(load_source);
|
session_->addSource(load_source);
|
||||||
id__ = load_source->id();
|
|
||||||
}
|
}
|
||||||
// get reference to the existing source
|
// get reference to the existing source
|
||||||
else
|
else
|
||||||
@@ -156,7 +157,7 @@ void SessionLoader::load(XMLElement *sessionNode)
|
|||||||
// apply config to source
|
// apply config to source
|
||||||
load_source->accept(*this);
|
load_source->accept(*this);
|
||||||
// remember
|
// remember
|
||||||
sources_id_.push_back( id__ );
|
sources_id_.push_back( load_source->id() );
|
||||||
}
|
}
|
||||||
|
|
||||||
// create clones after all sources, to be able to clone a source created above
|
// create clones after all sources, to be able to clone a source created above
|
||||||
@@ -167,47 +168,38 @@ void SessionLoader::load(XMLElement *sessionNode)
|
|||||||
|
|
||||||
// verify type of node
|
// verify type of node
|
||||||
const char *pType = xmlCurrent_->Attribute("type");
|
const char *pType = xmlCurrent_->Attribute("type");
|
||||||
if (!pType)
|
if ( pType && std::string(pType) == "CloneSource") {
|
||||||
continue;
|
|
||||||
if ( std::string(pType) == "CloneSource") {
|
|
||||||
|
|
||||||
// clone to load
|
|
||||||
Source *clone_source = nullptr;
|
|
||||||
|
|
||||||
// check if a source with same id exists
|
// check if a source with same id exists
|
||||||
uint64_t id__ = -1;
|
uint64_t id__ = 0;
|
||||||
xmlCurrent_->QueryUnsigned64Attribute("id", &id__);
|
xmlCurrent_->QueryUnsigned64Attribute("id", &id__);
|
||||||
SourceList::iterator sit = session_->find(id__);
|
SourceList::iterator sit = session_->find(id__);
|
||||||
|
|
||||||
// no source clone with this id exists
|
// no source clone with this id exists
|
||||||
if ( sit == session_->end() ) {
|
if ( sit == session_->end() ) {
|
||||||
|
|
||||||
|
// clone from given origin
|
||||||
XMLElement* originNode = xmlCurrent_->FirstChildElement("origin");
|
XMLElement* originNode = xmlCurrent_->FirstChildElement("origin");
|
||||||
if (originNode) {
|
if (originNode) {
|
||||||
std::string sourcename = std::string ( originNode->GetText() );
|
std::string sourcename = std::string ( originNode->GetText() );
|
||||||
SourceList::iterator origin = session_->find(sourcename);
|
SourceList::iterator origin = session_->find(sourcename);
|
||||||
|
// found the orign source
|
||||||
if (origin != session_->end()) {
|
if (origin != session_->end()) {
|
||||||
// create a new source of type Clone
|
// create a new source of type Clone
|
||||||
clone_source = (*origin)->clone();
|
Source *clone_source = (*origin)->clone();
|
||||||
|
// add source to session
|
||||||
|
session_->addSource(clone_source);
|
||||||
|
// apply config to source
|
||||||
|
clone_source->accept(*this);
|
||||||
|
// remember
|
||||||
|
sources_id_.push_back( clone_source->id() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// skip failed
|
|
||||||
if (!clone_source)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// add source to session
|
|
||||||
session_->addSource(clone_source);
|
|
||||||
id__ = clone_source->id();
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
clone_source = *sit;
|
|
||||||
|
|
||||||
// apply config to source
|
|
||||||
clone_source->accept(*this);
|
|
||||||
// remember
|
|
||||||
sources_id_.push_back( id__ );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// make sure no duplicate
|
||||||
|
sources_id_.unique();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -237,7 +237,8 @@ void SessionSource::render()
|
|||||||
void SessionSource::accept(Visitor& v)
|
void SessionSource::accept(Visitor& v)
|
||||||
{
|
{
|
||||||
Source::accept(v);
|
Source::accept(v);
|
||||||
v.visit(*this);
|
if (!failed())
|
||||||
|
v.visit(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -317,5 +318,6 @@ void RenderSource::render()
|
|||||||
void RenderSource::accept(Visitor& v)
|
void RenderSource::accept(Visitor& v)
|
||||||
{
|
{
|
||||||
Source::accept(v);
|
Source::accept(v);
|
||||||
v.visit(*this);
|
if (!failed())
|
||||||
|
v.visit(*this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -508,6 +508,7 @@ void CloneSource::render()
|
|||||||
void CloneSource::accept(Visitor& v)
|
void CloneSource::accept(Visitor& v)
|
||||||
{
|
{
|
||||||
Source::accept(v);
|
Source::accept(v);
|
||||||
v.visit(*this);
|
if (!failed())
|
||||||
|
v.visit(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,7 +33,8 @@ void GenericStreamSource::setDescription(const std::string &desc)
|
|||||||
void GenericStreamSource::accept(Visitor& v)
|
void GenericStreamSource::accept(Visitor& v)
|
||||||
{
|
{
|
||||||
Source::accept(v);
|
Source::accept(v);
|
||||||
v.visit(*this);
|
if (!failed())
|
||||||
|
v.visit(*this);
|
||||||
}
|
}
|
||||||
|
|
||||||
StreamSource::StreamSource() : Source()
|
StreamSource::StreamSource() : Source()
|
||||||
|
|||||||
Reference in New Issue
Block a user