From 286f81f3051800c2f87e92b6e25e3ef43002a425 Mon Sep 17 00:00:00 2001 From: Ozan Tonkal Date: Sun, 8 Sep 2013 00:15:14 +0200 Subject: [PATCH] fix crucial bug in get method, hide add and remove methods from user --- modules/viz/include/opencv2/viz.hpp | 7 +++++-- modules/viz/src/viz.cpp | 4 ++-- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/modules/viz/include/opencv2/viz.hpp b/modules/viz/include/opencv2/viz.hpp index 7f7cc7d2fe..df89339dd9 100644 --- a/modules/viz/include/opencv2/viz.hpp +++ b/modules/viz/include/opencv2/viz.hpp @@ -101,8 +101,6 @@ namespace cv static void release(); Viz3d get(const String &window_name); - void add(Viz3d window); - void remove(const String &window_name); //! window names automatically have Viz - prefix even though not provided by the users static void generateWindowName(const String &window_name, String &output); @@ -111,9 +109,14 @@ namespace cv VizAccessor(); // Singleton ~VizAccessor(); + void add(Viz3d window); + void remove(const String &window_name); + static VizAccessor * instance_; static bool is_instantiated_; static VizMap viz_map_; + + friend class Viz3d; }; } /* namespace viz */ } /* namespace cv */ diff --git a/modules/viz/src/viz.cpp b/modules/viz/src/viz.cpp index c8e09ba9ee..8bce61ca2a 100644 --- a/modules/viz/src/viz.cpp +++ b/modules/viz/src/viz.cpp @@ -126,7 +126,7 @@ cv::viz::Viz3d cv::viz::VizAccessor::get(const String & window_name) VizMap::iterator vm_itr = viz_map_.find(name); bool exists = vm_itr != viz_map_.end(); if (exists) return vm_itr->second; - else return viz_map_.insert(VizPair(window_name, Viz3d(window_name))).first->second; + else return Viz3d(window_name); } void cv::viz::VizAccessor::add(Viz3d window) @@ -135,7 +135,7 @@ void cv::viz::VizAccessor::add(Viz3d window) VizMap::iterator vm_itr = viz_map_.find(window_name); bool exists = vm_itr != viz_map_.end(); if (exists) return ; - viz_map_.insert(std::pair(window_name, window)); + viz_map_.insert(VizPair(window_name, window)); } void cv::viz::VizAccessor::remove(const String &window_name)