From bde3dd0644c445fd31fe6166df1ac2acb60380eb Mon Sep 17 00:00:00 2001 From: Richard Harrison Date: Thu, 16 Feb 2017 09:16:27 +0100 Subject: [PATCH] Canvas texture replacement visitor compiler fix. Change to use pointers rather than osg::ref_ptr - based on http://andesengineering.com/OSG_ProducerArticles/RefPointers/RefPointers I think that it is not possible that the scenegraph can be modified between the visitor and the modify, provided that the methods are called after each other like this: ReplaceStaticTextureVisitor visitor(name, new_texture); branch->accept(visitor); visitor.modify_groups(); return visitor.getPlacements(); --- src/Cockpit/od_gauge.cxx | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/Cockpit/od_gauge.cxx b/src/Cockpit/od_gauge.cxx index 3bf03b6bd..f6efb0251 100644 --- a/src/Cockpit/od_gauge.cxx +++ b/src/Cockpit/od_gauge.cxx @@ -70,9 +70,16 @@ FGODGauge::~FGODGauge() * Used to remember the located groups that require modification */ typedef struct { - typedef osg::ref_ptr GroupPtr; - GroupPtr parent; - GroupPtr node; + // could be: + //typedef osg::ref_ptr GroupPtr; + //GroupPtr parent; + //GroupPtr node; + // However this gives compile errors on linux; + // so change to use good old fashioned pointers. + // This means that the pointer may become invalid; however provided that this is a short lived operation + // and that modify is called immediately after visit it should work. + osg::Group *parent; + osg::Group *node; int unit; }GroupListItem; @@ -207,6 +214,7 @@ class ReplaceStaticTextureVisitor: * this section of code used to be in the apply method above, however to work this requires modification of the scenegraph nodes * that are currently iterating, so instead the apply method will locate the groups to be modified and when finished then the * nodes can actually be modified safely. Initially found thanks to the debug RTL in MSVC2015 throwing an exception. + * should be called immediately after the visitor to ensure that the groups are still valid and that nothing else has modified these groups. */ void modify_groups() {