diff --git a/src/osgPlugins/p3d/ReaderWriterP3D.cpp b/src/osgPlugins/p3d/ReaderWriterP3D.cpp index aa1c663fb..adfa265c7 100644 --- a/src/osgPlugins/p3d/ReaderWriterP3D.cpp +++ b/src/osgPlugins/p3d/ReaderWriterP3D.cpp @@ -2335,8 +2335,8 @@ void ReaderWriterP3DXML::parsePdfDocument(osgPresentation::SlideShowConstructor& osgPresentation::SlideShowConstructor::ScriptData scriptData; getProperties(cur, scriptData); - osg::Image* image = constructor.addInteractiveImage(cur->contents, positionData, imageData, scriptData); - osgWidget::PdfImage* pdfImage = dynamic_cast(image); + osg::ref_ptr image = constructor.addInteractiveImage(cur->contents, positionData, imageData, scriptData); + osgWidget::PdfImage* pdfImage = dynamic_cast(image.get()); if (pdfImage) { int numPages = pdfImage->getNumOfPages();