Commit 41274058 authored by Bill Hoffman's avatar Bill Hoffman
Browse files

BUG: fix crash with makecurrent

parent 73b27ad7
......@@ -43,7 +43,7 @@ public:
};
#ifndef VTK_IMPLEMENT_MESA_CXX
vtkCxxRevisionMacro(vtkOpenGLRenderer, "1.44");
vtkCxxRevisionMacro(vtkOpenGLRenderer, "1.45");
vtkStandardNewMacro(vtkOpenGLRenderer);
#endif
......@@ -223,7 +223,7 @@ void vtkOpenGLRenderer::StartPick(unsigned int pickFromSize)
// other windows might get rendered since the last time
// a MakeCurrent was called.
this->RenderWindow->MakeCurrent();
this->RenderWindow->IsPickingOn();
this->PickInfo->PickBuffer = new GLuint[bufferSize];
glSelectBuffer(bufferSize, this->PickInfo->PickBuffer);
// change to selection mode
......@@ -315,6 +315,7 @@ void vtkOpenGLRenderer::DonePick()
}
delete [] this->PickInfo->PickBuffer;
this->PickInfo->PickBuffer = 0;
this->RenderWindow->IsPickingOff();
}
float vtkOpenGLRenderer::GetPickedZ()
......
......@@ -25,7 +25,7 @@
#include "vtkRendererCollection.h"
#include "vtkTransform.h"
vtkCxxRevisionMacro(vtkRenderWindow, "1.130");
vtkCxxRevisionMacro(vtkRenderWindow, "1.131");
//----------------------------------------------------------------------------
// Needed when we don't use the vtkStandardNewMacro.
......@@ -37,6 +37,7 @@ vtkInstantiatorNewMacro(vtkRenderWindow);
// buffering turned on, stereo capable off.
vtkRenderWindow::vtkRenderWindow()
{
this->IsPicking = 0;
this->Borders = 1;
this->FullScreen = 0;
this->OldScreen[0] = this->OldScreen[1] = 0;
......
......@@ -308,6 +308,10 @@ public:
vtkSetMacro(InAbortCheck,int);
virtual int CheckAbortStatus();
vtkGetMacro(IsPicking,int);
vtkSetMacro(IsPicking,int);
vtkBooleanMacro(IsPicking,int);
// Description:
// Check to see if a mouse button has been pressed. All other events
// are ignored by this method. Ideally, you want to abort the render
......@@ -437,6 +441,7 @@ protected:
void (*AbortCheckMethodArgDelete)(void *);
void *AbortCheckMethodArg;
int CurrentCursor;
int IsPicking;
private:
vtkRenderWindow(const vtkRenderWindow&); // Not implemented.
......
......@@ -38,7 +38,7 @@ PURPOSE. See the above copyright notice for more information.
#include <GL/gl.h>
#endif
vtkCxxRevisionMacro(vtkWin32OpenGLRenderWindow, "1.110");
vtkCxxRevisionMacro(vtkWin32OpenGLRenderWindow, "1.111");
vtkStandardNewMacro(vtkWin32OpenGLRenderWindow);
#define VTK_MAX_LIGHTS 8
......@@ -199,25 +199,34 @@ int vtkWin32OpenGLRenderWindow::GetEventPending()
void vtkWin32OpenGLRenderWindow::MakeCurrent()
{
// Try to avoid doing anything (for performance).
if (this->ContextId)
if (this->ContextId != wglGetCurrentContext())
{
if (wglMakeCurrent(this->DeviceContext, this->ContextId) != TRUE)
if(this->IsPickingOn)
{
vtkErrorMacro("Attempting to call MakeCurrent for a different window"
" than the one doing the picking, this can causes crashes"
" and/or bad pick results");
}
else
{
LPVOID lpMsgBuf;
::FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
vtkErrorMacro("wglMakeCurrent failed in MakeCurrent(), error: "
<< (LPCTSTR)lpMsgBuf);
::LocalFree( lpMsgBuf );
if (wglMakeCurrent(this->DeviceContext, this->ContextId) != TRUE)
{
LPVOID lpMsgBuf;
::FormatMessage(
FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM |
FORMAT_MESSAGE_IGNORE_INSERTS,
NULL,
GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), // Default language
(LPTSTR) &lpMsgBuf,
0,
NULL
);
vtkErrorMacro("wglMakeCurrent failed in MakeCurrent(), error: "
<< (LPCTSTR)lpMsgBuf);
::LocalFree( lpMsgBuf );
}
}
}
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment