From 16931917b70169babecd5d44c252ce76d05c3b70 Mon Sep 17 00:00:00 2001 From: Bruno Herbelin Date: Thu, 16 Feb 2023 19:15:25 +0100 Subject: [PATCH] BugFix: Clone source failed do not crash Clone source that lost its origin can be replaced. --- src/CloneSource.cpp | 8 ++++---- src/ImGuiVisitor.cpp | 17 ++++++++++++----- src/InfoVisitor.cpp | 6 ++++-- src/Session.cpp | 5 +++-- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/CloneSource.cpp b/src/CloneSource.cpp index 5e46416..22d5de6 100644 --- a/src/CloneSource.cpp +++ b/src/CloneSource.cpp @@ -212,8 +212,9 @@ guint64 CloneSource::playtime () const { if (filter_->type() != FrameBufferFilter::FILTER_PASSTHROUGH) return guint64( filter_->updateTime() * GST_SECOND ) ; - - return origin_->playtime(); + if (origin_) + return origin_->playtime(); + return 0; } @@ -221,8 +222,7 @@ uint CloneSource::texture() const { if (origin_) return origin_->frame()->texture(); - else - return Resource::getTextureBlack(); + return Resource::getTextureBlack(); } void CloneSource::accept(Visitor& v) diff --git a/src/ImGuiVisitor.cpp b/src/ImGuiVisitor.cpp index 36c4cd5..b708995 100644 --- a/src/ImGuiVisitor.cpp +++ b/src/ImGuiVisitor.cpp @@ -1043,11 +1043,18 @@ void ImGuiVisitor::visit (CloneSource& s) } // link to origin source - std::string label = std::string(s.origin()->initials()) + " - " + s.origin()->name(); - if (ImGui::Button(label.c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0) )) - Mixer::manager().setCurrentSource(s.origin()); - ImGui::SameLine(0, IMGUI_SAME_LINE); - ImGui::Text("Origin"); + if ( !s.failed() ) { + std::string label = std::string(s.origin()->initials()) + " - " + s.origin()->name(); + if (ImGui::Button(label.c_str(), ImVec2(IMGUI_RIGHT_ALIGN, 0) )) + Mixer::manager().setCurrentSource(s.origin()); + ImGui::SameLine(0, IMGUI_SAME_LINE); + ImGui::Text("Origin"); + } + else { + ImGuiToolkit::ButtonDisabled("No source", ImVec2(IMGUI_RIGHT_ALIGN, 0) ); + ImGui::SameLine(0, IMGUI_SAME_LINE); + ImGui::Text("Origin"); + } // filter selection std::ostringstream oss; diff --git a/src/InfoVisitor.cpp b/src/InfoVisitor.cpp index 13ed649..bce9a76 100644 --- a/src/InfoVisitor.cpp +++ b/src/InfoVisitor.cpp @@ -223,12 +223,12 @@ void InfoVisitor::visit (RenderSource& s) void InfoVisitor::visit (CloneSource& s) { - if (current_id_ == s.id() || s.origin() == nullptr) + if (current_id_ == s.id() && !s.failed()) return; std::ostringstream oss; - if (s.frame()){ + if (!s.failed() && s.frame()){ if (brief_) { oss << (s.frame()->flags() & FrameBuffer::FrameBuffer_alpha ? "RGBA, " : "RGB, "); oss << s.frame()->width() << " x " << s.frame()->height(); @@ -241,6 +241,8 @@ void InfoVisitor::visit (CloneSource& s) oss << s.frame()->width() << " x " << s.frame()->height(); } } + else + oss << "Undefined"; information_ = oss.str(); current_id_ = s.id(); diff --git a/src/Session.cpp b/src/Session.cpp index ae6cfcf..b8536d2 100644 --- a/src/Session.cpp +++ b/src/Session.cpp @@ -247,13 +247,14 @@ void Session::update(float dt) // insert source in list of failed // (NB: insert in set fails if source is already listed) failed_.insert( *it ); + // do not render + render_.scene.ws()->detach( (*it)->group(View::RENDERING) ); } // render normally else { + // session is not ready if one source is not ready if ( !(*it)->ready() ) ready = false; - // set inputs - // update the source (*it)->setActive(activation_threshold_); (*it)->update(dt);