gwaldron / osgearth

3D Maps for OpenSceneGraph / C++14
https://www.pelicanmapping.com/home-1/opensource
Other
1.48k stars 774 forks source link

Crash with removeModelLayer #639

Closed jasonbeverage closed 8 years ago

jasonbeverage commented 9 years ago

Hi, in my application I want to update the style of my modelLayer, so I need to remove the layer than insert the new one with the new style;

But removeModelLayer crash almost all time when I use a DRAPE technique(no problem for other techniques) My model is added like the following code: osgEarth::Drivers::OGRFeatureOptions fo; fo.url()=path.toStdString(); fo.openWrite()=false; osg::ref_ptr< FeatureSource > features = FeatureSourceFactory::create( fo ); features->initialize(NULL); features->getFeatureProfile(); fgm_opt.featureOptions() = fo; AltitudeSymbol* alt = new AltitudeSymbol(); alt->clamping() = AltitudeSymbol::CLAMP_TO_TERRAIN; alt->technique()=AltitudeSymbol::TECHNIQUE_DRAPE; style.add(alt); style.getOrCreate()->fill()->color() =colE; style.getOrCreate()->size() =5; style.setName("POINT"); styleSheet->addStyle( style ); fgm_opt.styles() = styleSheet; return( new ModelLayer( "POINT", fgm_opt ) );

I tried removeModelLayer from eventHandler and directly from a Qt function, but in the 2 cases it crash.

What am I doing wrong ??? How to remove dynamically a ModelLayer with Drape technique???

Thanks in advance.

gwaldron commented 9 years ago

I quickly modified osgearth.toc to remove a model layer -- could not reproduce it immediately..

MCA4213 commented 9 years ago

Hi, In the post I forgot to told you that fgm_opt is a FeatureGeomModelOptions :

On my VS 2013 I got this error most the time when I try to remove a modelLayer (I dont have a debug version) : "First-chance exception at 0x5CD82D05 (ot20-OpenThreads.dll) in Imagery Situation Pro.exe: 0xC0000005: Access violation writing location 0xFEEEFEF6."

I notice taht IF I don't turn the globe to the position of my modelLayer (the model was never loaded on the screen) then It can be removed without problem!!!

This happen only on drape technique. Thank you for your help.

gwaldron commented 9 years ago

This should be fixed now. See #640. Let us know, thanks.

MCA4213 commented 9 years ago

Thank you, now removing ModelLayer is safe ( no crash). Build on vs2013/windows10x64/osg3.4/Qt5.4.

thanks.