From 1c4ff5c6470694d6e1849de412c8397769ced574 Mon Sep 17 00:00:00 2001 From: ibs Date: Fri, 9 Nov 2012 12:11:20 +0400 Subject: [PATCH] 0023500: MFC samples are crached on 3D visualisation void FreeTexture() in OpenGl_TextureBox.cxx - avoid possible NULL-pointer dereference after debug x64 compilation the executable viewer3d had been moved to the bin folder. now executable viewer3d located in bind folder. --- .../mfc/standard/04_Viewer3d/adm/win/vc10/Viewer3d.vcxproj | 2 +- src/OpenGl/OpenGl_TextureBox.cxx | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/samples/mfc/standard/04_Viewer3d/adm/win/vc10/Viewer3d.vcxproj b/samples/mfc/standard/04_Viewer3d/adm/win/vc10/Viewer3d.vcxproj index 3e84d694d0..63f3bb2233 100644 --- a/samples/mfc/standard/04_Viewer3d/adm/win/vc10/Viewer3d.vcxproj +++ b/samples/mfc/standard/04_Viewer3d/adm/win/vc10/Viewer3d.vcxproj @@ -240,7 +240,7 @@ TKBRep.lib;FWOSPlugin.lib;PTKernel.lib;TKBool.lib;TKCAF.lib;TKCDF.lib;TKernel.lib;TKFeat.lib;TKFillet.lib;TKG2d.lib;TKG3d.lib;TKGeomAlgo.lib;TKGeomBase.lib;TKHLR.lib;TKMath.lib;TKOffset.lib;TKPCAF.lib;TKPrim.lib;TKPShape.lib;TKService.lib;TKTopAlgo.lib;TKV2d.lib;TKV3d.lib;mfcsample.lib;%(AdditionalDependencies) - ../../../../x64\vc10\bin/Viewer3d.exe + ../../../../x64\vc10\bind/Viewer3d.exe true ..\..\..\..\x64\vc10\libd;$(CSF_OPT_LIB64D);%(AdditionalLibraryDirectories) true diff --git a/src/OpenGl/OpenGl_TextureBox.cxx b/src/OpenGl/OpenGl_TextureBox.cxx index 3342ff25ce..5f9f139f42 100755 --- a/src/OpenGl/OpenGl_TextureBox.cxx +++ b/src/OpenGl/OpenGl_TextureBox.cxx @@ -684,7 +684,10 @@ void FreeTexture (const Handle(OpenGl_Context)& theContext, for (int i = 0; i < textab(ID).contextdata.Length(); ++i) { Handle(OpenGl_ResourceTexture) aResource = new OpenGl_ResourceTexture (textab(ID).contextdata(i).number); - theContext->DelayedRelease (aResource); + + if (!theContext.IsNull()) { + theContext->DelayedRelease (aResource); + } } texdata(data).status = TEXDATA_NONE;