<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 14 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri","sans-serif";}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p
        {mso-style-priority:99;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:12.0pt;
        font-family:"Times New Roman","serif";}
pre
        {mso-style-priority:99;
        mso-style-link:"HTML Preformatted Char";
        margin:0in;
        margin-bottom:.0001pt;
        font-size:10.0pt;
        font-family:"Courier New";}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri","sans-serif";
        color:windowtext;}
span.HTMLPreformattedChar
        {mso-style-name:"HTML Preformatted Char";
        mso-style-priority:99;
        mso-style-link:"HTML Preformatted";
        font-family:"Courier New";}
span.kwd
        {mso-style-name:kwd;}
span.pln
        {mso-style-name:pln;}
span.pun
        {mso-style-name:pun;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-family:"Calibri","sans-serif";}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal" style="margin-bottom:12.0pt;line-height:13.35pt;background:white;vertical-align:baseline">
<span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">Hello,<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt;line-height:13.35pt;background:white;vertical-align:baseline">
<span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">We have a WinForms c++/cli CAD based application that uses VTK 6.1. One of the application's features is playing a script which plays back operations the user had previously done interactively.
 We pop a modal progress form while the script is playing and do the non-ui work of the script in a background thread. Part of the work of the background thread is creating and deleting vtkPolyDataMappers. While the background thread is going and the progress
 form is showing we need to update a display in the main thread by calling vtkWin32RenderWindowInteractor::Render().<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt;line-height:13.35pt;background:white;vertical-align:baseline">
<span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">We have a timer setup so Render is called every few hundred milliseconds at most in a UserControl::OnPaint event handler. This allows the view to update while the script is playing
 giving the user feedback.<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt;line-height:13.35pt;background:white;vertical-align:baseline">
<span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">This used to work in VTK 5. But now an infinite loop happens upon deletion of a vtkPolyDataMapper in the background thread. The infinite loop is in vtkClearOpenGLErrors:<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline">
<span style="font-size:10.0pt;font-family:Consolas;color:darkblue;border:none windowtext 1.0pt;padding:0in">void</span><span style="font-size:10.0pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in"> vtkClearOpenGLErrors()<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline">
<span style="font-size:10.0pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">{<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline">
<span style="font-size:10.0pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in"></span><span style="font-size:10.0pt;font-family:Consolas;color:darkblue;border:none windowtext 1.0pt;padding:0in">while</span><span style="font-size:10.0pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">
 (glGetError()!=GL_NO_ERROR){;}<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:13.35pt;background:#EEEEEE;vertical-align:baseline">
<span style="font-size:10.0pt;font-family:Consolas;color:black;border:none windowtext 1.0pt;padding:0in">}</span><span style="font-size:10.0pt;font-family:Consolas;color:black"><o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt;line-height:13.35pt;background:white;vertical-align:baseline">
<span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">Inside the vtkpolydatamapper is a vtkOpenGLDisplayListPainter. When this gets deleted by vtkGarbageCollectorImpl::CollectInternal we get stuck in vtkClearOpenGLErrors.<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt;line-height:13.35pt;background:white;vertical-align:baseline">
<span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">Does anyone have experience with VTK and threading that could help? Do you know anything about this? It's only an apparent problem in VTK 6.1. Is it illegal to have the main UI thread
 calling Render on a vtkWin32RenderWindowInteractor while a background thread is doing deletes on a vtkPolyDataMapper? It isn't a timing issue. I think it might be an OpenGL context issue but not sure how to fix it. The problem does go away if we avoid calling
 Render on the display while the background thread is going but we'd like to give the user feedback while the script is playing.<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt;line-height:13.35pt;background:white;vertical-align:baseline">
<span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">Thanks,<o:p></o:p></span></p>
<p class="MsoNormal" style="margin-bottom:12.0pt;line-height:13.35pt;background:white;vertical-align:baseline">
<span style="font-size:10.0pt;font-family:"Arial","sans-serif";color:black">Adam<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>