1
0
mirror of https://git.dev.opencascade.org/repos/occt.git synced 2025-04-09 18:50:54 +03:00

OCC22150 Problem with GetWindowLong function on 64-bit platform

This commit is contained in:
APL 2011-04-28 15:11:03 +00:00 committed by bugmaster
parent 3ba3388b06
commit 8ab673bb2f
2 changed files with 8 additions and 49 deletions

View File

@ -83,7 +83,6 @@ Old code resulted in crashes on some ATI Radeon cards under Linux.
#include <stdio.h> #include <stdio.h>
#include <OpenGl_Memory.hxx> #include <OpenGl_Memory.hxx>
#include <OpenGl_ResourceCleaner.hxx>
#ifdef WNT #ifdef WNT
@ -313,8 +312,6 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
if( !ctx) return TFailure; if( !ctx) return TFailure;
OpenGl_ResourceCleaner::GetInstance()->AppendContext( ctx, true );
cmap = XCreateColormap( disp, par, vis->visual, AllocNone ); cmap = XCreateColormap( disp, par, vis->visual, AllocNone );
color.red = (unsigned short) (bgcolr * 0xFFFF); color.red = (unsigned short) (bgcolr * 0xFFFF);
@ -420,11 +417,7 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
if ( pfd.dwFlags & PFD_NEED_PALETTE ) if ( pfd.dwFlags & PFD_NEED_PALETTE )
{ {
#ifndef _WIN64 WINDOW_DATA* wd = ( WINDOW_DATA* )GetWindowLongPtr ( par, GWLP_USERDATA );
WINDOW_DATA* wd = ( WINDOW_DATA* )GetWindowLong ( par, GWL_USERDATA );
#else
WINDOW_DATA* wd = ( WINDOW_DATA* )GetWindowLong ( par, GWLP_USERDATA );
#endif
InterfaceGraphic_RealizePalette (hte -> hDC, wd -> hPal, FALSE, InterfaceGraphic_RealizePalette (hte -> hDC, wd -> hPal, FALSE,
s_sysPalInUse = pfd.dwFlags & PFD_NEED_SYSTEM_PALETTE ? TRUE : FALSE); s_sysPalInUse = pfd.dwFlags & PFD_NEED_SYSTEM_PALETTE ? TRUE : FALSE);
@ -458,29 +451,12 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
return 0; return 0;
} }
Standard_Boolean isShared = Standard_True;
if (previous_ctx == 0 ) if (previous_ctx == 0 )
previous_ctx = hte -> hGLRC;
// if we already have some shared context
else
{ {
// try to share context with one from resource cleaner list previous_ctx = hte -> hGLRC;
GLCONTEXT shareCtx = OpenGl_ResourceCleaner::GetInstance()->GetSharedContext(); } else
wglShareLists(previous_ctx, hte -> hGLRC);
if (shareCtx != 0)
isShared = (Standard_Boolean)wglShareLists(shareCtx, hte -> hGLRC);
else
{
isShared = (Standard_Boolean)wglShareLists(previous_ctx, hte -> hGLRC);
// add shared previous_ctx to a control list if it's not there
if (isShared)
OpenGl_ResourceCleaner::GetInstance()->AppendContext(previous_ctx, isShared);
}
}
// add the context to OpenGl_ResourceCleaner control list
OpenGl_ResourceCleaner::GetInstance()->AppendContext( hte -> hGLRC, isShared);
_Txgl_Map.Bind( (Tint)par, hte ); _Txgl_Map.Bind( (Tint)par, hte );
return par; return par;
@ -614,11 +590,7 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
if ( pfd.dwFlags & PFD_NEED_PALETTE ) if ( pfd.dwFlags & PFD_NEED_PALETTE )
{ {
#ifndef _WIN64 WINDOW_DATA* wd = ( WINDOW_DATA* )GetWindowLongPtr ( par, GWLP_USERDATA );
WINDOW_DATA* wd = ( WINDOW_DATA* )GetWindowLong ( par, GWL_USERDATA );
#else
WINDOW_DATA* wd = ( WINDOW_DATA* )GetWindowLong ( par, GWLP_USERDATA );
#endif
InterfaceGraphic_RealizePalette (hte -> hDC, wd -> hPal, FALSE, InterfaceGraphic_RealizePalette (hte -> hDC, wd -> hPal, FALSE,
s_sysPalInUse = pfd.dwFlags & PFD_NEED_SYSTEM_PALETTE ? TRUE : FALSE); s_sysPalInUse = pfd.dwFlags & PFD_NEED_SYSTEM_PALETTE ? TRUE : FALSE);
@ -791,7 +763,6 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
/* FSXXX sync necessary if non-direct rendering */ /* FSXXX sync necessary if non-direct rendering */
glXWaitGL(); glXWaitGL();
OpenGl_ResourceCleaner::GetInstance()->RemoveContext( ctx );
_Txgl_Map.UnBind( win ); _Txgl_Map.UnBind( win );
if (previous_ctx == ctx) { if (previous_ctx == ctx) {
@ -832,11 +803,7 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
/* palette messages in the main application message loop. */ /* palette messages in the main application message loop. */
/* In debug version we don't have message loop for most */ /* In debug version we don't have message loop for most */
/* cases. So, let's restore system colors here now. */ /* cases. So, let's restore system colors here now. */
#ifndef _WIN64 wd = ( WINDOW_DATA* )GetWindowLongPtr ( win, GWLP_USERDATA );
wd = ( WINDOW_DATA* )GetWindowLong ( win, GWL_USERDATA );
#else
wd = ( WINDOW_DATA* )GetWindowLong ( win, GWLP_USERDATA );
#endif
if ( wd != NULL ) InterfaceGraphic_RealizePalette ( if ( wd != NULL ) InterfaceGraphic_RealizePalette (
hte -> hDC, wd -> hPal, TRUE, s_sysPalInUse); hte -> hDC, wd -> hPal, TRUE, s_sysPalInUse);
@ -844,16 +811,12 @@ __declspec( dllexport ) int __fastcall __OpenGl_INIT__ (
if ( --hte -> nUsed == 0 ) if ( --hte -> nUsed == 0 )
{ {
OpenGl_ResourceCleaner::GetInstance()->RemoveContext( hte -> hGLRC );
#ifdef OCC954 #ifdef OCC954
if ( wglGetCurrentContext() != NULL ) if ( wglGetCurrentContext() != NULL )
#endif #endif
wglDeleteContext ( hte -> hGLRC ); wglDeleteContext ( hte -> hGLRC );
ReleaseDC ( win, hte -> hDC ); ReleaseDC ( win, hte -> hDC );
_Txgl_Map.UnBind( (Tint ) win ); _Txgl_Map.UnBind( (Tint ) win );
if( _Txgl_Map.Size() == 0 ) {
previous_ctx = 0;
}
delete hte; delete hte;
} }

View File

@ -479,11 +479,7 @@ const Handle(WNT_Window) theWindow = *(Handle(WNT_Window) *) &AWindow;
#ifdef RIC120302 #ifdef RIC120302
MyCView.DefWindow.XParentWindow = ( HWND )(theWindow->HParentWindow()); MyCView.DefWindow.XParentWindow = ( HWND )(theWindow->HParentWindow());
#endif #endif
#ifndef _WIN64 wd = ( WNT_WindowData* )GetWindowLongPtr (( HWND )(theWindow->HWindow()), GWLP_USERDATA);
wd = ( WNT_WindowData* )GetWindowLong (( HWND )(theWindow->HWindow()), GWL_USERDATA);
#else
wd = ( WNT_WindowData* )GetWindowLong (( HWND )(theWindow->HWindow()), GWLP_USERDATA);
#endif
wd -> WNT_WDriver_Ptr = ( void* )this; wd -> WNT_WDriver_Ptr = ( void* )this;
wd -> WNT_VMgr = ( void* )MyPtrViewManager; wd -> WNT_VMgr = ( void* )MyPtrViewManager;
#endif /* WNT */ #endif /* WNT */