From f67de69c908609aed071e37648816f5c162b4384 Mon Sep 17 00:00:00 2001 From: Christophe Geuzaine <cgeuzaine@ulg.ac.be> Date: Fri, 7 Dec 2012 17:52:13 +0000 Subject: [PATCH] fix faulty logic --- Post/PView.cpp | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Post/PView.cpp b/Post/PView.cpp index 6e82ac3086..39cbbb645d 100644 --- a/Post/PView.cpp +++ b/Post/PView.cpp @@ -33,22 +33,19 @@ void PView::_init(int tag) va_points = va_lines = va_triangles = va_vectors = va_ellipses = 0; normals = 0; - bool replaced = false; for(unsigned int i = 0; i < list.size(); i++){ if(list[i]->getTag() == _tag){ - // warning: this can potentially break aliases - Msg::Info("Replacing View[%d] (tag = %d)", i, _tag); - replaced = true; - delete list[i]; - _index = i; - list[i] = this; - break; + // in normal operation this should not happen, but we allow it when + // programmatically forcing view tags (e.g. when using the views from + // within getdp's post-processing operations); this is dangerous, as it + // breaks aliases + Msg::Info("Removing existing View[%d] (tag = %d)", i, _tag); + delete list[i]; // warning: this changes the list } } - if(!replaced){ - _index = list.size(); - list.push_back(this); - } + + list.push_back(this); + for(unsigned int i = 0; i < list.size(); i++) list[i]->setIndex(i); } PView::PView(int tag) -- GitLab