From 11e9ee9363a33cee4f3433c83b1f5fd76b95b57e Mon Sep 17 00:00:00 2001 From: ronag Date: Sat, 22 Oct 2011 20:39:51 +0000 Subject: [PATCH] 2.0.0: Fixed potential pure virtual function call. git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@1382 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d --- common/diagnostics/graph.cpp | 45 +++++++++---------- common/diagnostics/graph.h | 4 +- common/memory/safe_ptr.h | 23 ++++++---- modules/decklink/interop/DeckLinkAPI_h.h | 2 +- modules/decklink/interop/DeckLinkAPI_i.c | 2 +- .../decklink/producer/decklink_producer.cpp | 2 +- modules/ffmpeg/producer/ffmpeg_producer.cpp | 4 +- modules/flash/producer/flash_producer.cpp | 5 ++- shell/casparcg.config | 1 - 9 files changed, 46 insertions(+), 42 deletions(-) diff --git a/common/diagnostics/graph.cpp b/common/diagnostics/graph.cpp index 5378f5156..db6eff790 100644 --- a/common/diagnostics/graph.cpp +++ b/common/diagnostics/graph.cpp @@ -258,25 +258,26 @@ public: struct graph::implementation : public drawable { std::map lines_; - const printer parent_printer_; std::string name_; + std::string text_; int counter_; implementation(const std::string& name) : name_(name) + , text_(name) , counter_(0){} - - implementation(const printer& parent_printer) - : parent_printer_(parent_printer) - , name_(parent_printer_ ? narrow(parent_printer_()) : "") - , counter_(0){} - + void update(const std::string& name, double value) { lines_[name].update(value); } + void update_text(const std::string& value) + { + text_ = value; + } + void set(const std::string& name, double value) { lines_[name].set(value); @@ -300,17 +301,11 @@ struct graph::implementation : public drawable private: void render(sf::RenderTarget& target) { - if(counter_++ > 25) // Don't update name too often since print can be implemented with locks. - { - counter_ = 0; - if(parent_printer_) - name_ = narrow(parent_printer_()); - } const size_t text_size = 15; const size_t text_margin = 2; const size_t text_offset = (text_size+text_margin*2)*2; - sf::String text(name_.c_str(), sf::Font::GetDefaultFont(), text_size); + sf::String text(text_.c_str(), sf::Font::GetDefaultFont(), text_size); text.SetStyle(sf::String::Italic); text.Move(text_margin, text_margin); @@ -362,23 +357,30 @@ graph::graph(const std::string& name) : impl_(env::properties().get("configurati context::register_drawable(impl_); } -graph::graph(const printer& parent_printer) : impl_(env::properties().get("configuration.diagnostics.graphs", true) ? new implementation(parent_printer) : nullptr) +void graph::update_value(const std::string& name, double value) { if(impl_) - context::register_drawable(impl_); + { + auto p = impl_; + context::begin_invoke([=] + { + p->update(name, value); + }); + } } -void graph::update_value(const std::string& name, double value) +void graph::update_text(const std::string& value) { if(impl_) - { + { auto p = impl_; context::begin_invoke([=] { - p->update(name, value); + p->update_text(value); }); } } + void graph::set_value(const std::string& name, double value) { if(impl_) @@ -428,11 +430,6 @@ safe_ptr create_graph(const std::string& name) { return safe_ptr(new graph(name)); } -safe_ptr create_graph(const printer& parent_printer) -{ - return safe_ptr(new graph(parent_printer)); -} - //namespace v2 //{ diff --git a/common/diagnostics/graph.h b/common/diagnostics/graph.h index 3f54c0a7c..0d9ef3d62 100644 --- a/common/diagnostics/graph.h +++ b/common/diagnostics/graph.h @@ -52,11 +52,10 @@ struct color class graph { friend safe_ptr create_graph(const std::string& name); - friend safe_ptr create_graph(const printer& parent_printer); graph(const std::string& name); - graph(const printer& parent_printer); public: void update_value(const std::string& name, double value); + void update_text(const std::string& value); void set_value(const std::string& name, double value); void set_color(const std::string& name, color c); void add_tag(const std::string& name); @@ -67,7 +66,6 @@ private: }; safe_ptr create_graph(const std::string& name); -safe_ptr create_graph(const printer& parent_printer); //namespace v2 //{ diff --git a/common/memory/safe_ptr.h b/common/memory/safe_ptr.h index e4269e69b..88c184af3 100644 --- a/common/memory/safe_ptr.h +++ b/common/memory/safe_ptr.h @@ -35,8 +35,8 @@ public: safe_ptr() : impl_(std::make_shared()){} - safe_ptr(const safe_ptr& other) : impl_(other.impl_){} // noexcept - safe_ptr(safe_ptr&& other) : impl_(std::move(other.impl_)){} + safe_ptr(const safe_ptr& other) : impl_(other.impl_){} // noexcept + safe_ptr(safe_ptr&& other) : impl_(std::move(other.impl_)){} template safe_ptr(const safe_ptr& other, typename std::enable_if::value, void*>::type = 0) : impl_(other.impl_){} // noexcept @@ -86,19 +86,26 @@ public: } template - typename std::enable_if::value, safe_ptr&>::type + typename std::enable_if::type, T*>::value, safe_ptr&>::type operator=(const safe_ptr& other) { - safe_ptr temp(other); - temp.swap(*this); + safe_ptr(other).swap(*this); + return *this; + } + + template + typename std::enable_if::type, T*>::value, safe_ptr&>::type + operator=(safe_ptr&& other) + { + safe_ptr(std::move(other)).swap(*this); return *this; } template - typename std::enable_if::type, T*>::value, safe_ptr&>::type + typename std::enable_if::type, T*>::value, safe_ptr&>::type operator=(U&& impl) { - safe_ptr temp(std::forward(impl)); + safe_ptr temp(std::forward(impl)); temp.swap(*this); return *this; } @@ -127,7 +134,7 @@ public: operator const std::shared_ptr&() const { return impl_;} // noexcept template - bool owner_before(const safe_ptr& ptr){ return impl_.owner_before(ptr.impl_); } // noexcept + bool owner_before(const safe_ptr& ptr){ return impl_.owner_before(ptr.impl_); } // noexcept template bool owner_before(const std::shared_ptr& ptr){ return impl_.owner_before(ptr); } // noexcept diff --git a/modules/decklink/interop/DeckLinkAPI_h.h b/modules/decklink/interop/DeckLinkAPI_h.h index 4a466545a..df6064712 100644 --- a/modules/decklink/interop/DeckLinkAPI_h.h +++ b/modules/decklink/interop/DeckLinkAPI_h.h @@ -4,7 +4,7 @@ /* File created by MIDL compiler version 7.00.0555 */ -/* at Wed Sep 21 22:02:53 2011 +/* at Wed Sep 21 23:31:49 2011 */ /* Compiler settings for interop\DeckLinkAPI.idl: Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 diff --git a/modules/decklink/interop/DeckLinkAPI_i.c b/modules/decklink/interop/DeckLinkAPI_i.c index a31a6cd25..86e24837f 100644 --- a/modules/decklink/interop/DeckLinkAPI_i.c +++ b/modules/decklink/interop/DeckLinkAPI_i.c @@ -6,7 +6,7 @@ /* File created by MIDL compiler version 7.00.0555 */ -/* at Wed Sep 21 22:02:53 2011 +/* at Wed Sep 21 23:31:49 2011 */ /* Compiler settings for interop\DeckLinkAPI.idl: Oicf, W1, Zp8, env=Win32 (32b run), target_arch=X86 7.00.0555 diff --git a/modules/decklink/producer/decklink_producer.cpp b/modules/decklink/producer/decklink_producer.cpp index 902d78e21..178b0042c 100644 --- a/modules/decklink/producer/decklink_producer.cpp +++ b/modules/decklink/producer/decklink_producer.cpp @@ -108,7 +108,7 @@ public: { frame_buffer_.set_capacity(2); - graph_ = diagnostics::create_graph(boost::bind(&decklink_producer::print, this)); + graph_ = diagnostics::create_graph(narrow(print())); graph_->add_guide("tick-time", 0.5); graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f)); graph_->set_color("late-frame", diagnostics::color(0.6f, 0.3f, 0.3f)); diff --git a/modules/ffmpeg/producer/ffmpeg_producer.cpp b/modules/ffmpeg/producer/ffmpeg_producer.cpp index 480e95b8d..5641222a1 100644 --- a/modules/ffmpeg/producer/ffmpeg_producer.cpp +++ b/modules/ffmpeg/producer/ffmpeg_producer.cpp @@ -79,7 +79,7 @@ struct ffmpeg_producer : public core::frame_producer public: explicit ffmpeg_producer(const safe_ptr& frame_factory, const std::wstring& filename, const std::wstring& filter, bool loop, int start, size_t length) : filename_(filename) - , graph_(diagnostics::create_graph([this]{return print();})) + , graph_(diagnostics::create_graph("")) , frame_factory_(frame_factory) , format_desc_(frame_factory->get_video_format_desc()) , input_(graph_, filename_, loop, start, length) @@ -137,6 +137,8 @@ public: else graph_->add_tag("underflow"); } + + graph_->update_text(narrow(print())); return frame; } diff --git a/modules/flash/producer/flash_producer.cpp b/modules/flash/producer/flash_producer.cpp index 13a0fa342..8f3f95759 100644 --- a/modules/flash/producer/flash_producer.cpp +++ b/modules/flash/producer/flash_producer.cpp @@ -281,7 +281,7 @@ public: fps_ = 0; - graph_ = diagnostics::create_graph([this]{return print();}); + graph_ = diagnostics::create_graph(narrow(print())); graph_->set_color("output-buffer-count", diagnostics::color(1.0f, 1.0f, 0.0f)); graph_->set_color("underflow", diagnostics::color(0.6f, 0.3f, 0.9f)); @@ -390,7 +390,8 @@ public: } graph_->set_value("output-buffer-count", static_cast(frame_buffer_.size())/static_cast(frame_buffer_.capacity())); - fps_.fetch_and_store(static_cast(context_->fps()*100.0)); + fps_.fetch_and_store(static_cast(context_->fps()*100.0)); + graph_->update_text(narrow(print())); render(renderer); } diff --git a/shell/casparcg.config b/shell/casparcg.config index 236741a0c..fd68da33d 100644 --- a/shell/casparcg.config +++ b/shell/casparcg.config @@ -39,7 +39,6 @@ 1 true - -- 2.39.2