<html xmlns="http://www.w3.org/1999/xhtml" xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office"><head><!--[if gte mso 9]><xml><o:OfficeDocumentSettings><o:AllowPNG/><o:PixelsPerInch>96</o:PixelsPerInch></o:OfficeDocumentSettings></xml><![endif]--></head><body><div style="font-family:Helvetica Neue, Helvetica, Arial, sans-serif;font-size:16px;"><div></div>
            <div>Hi Jesse</div><div><br></div><div><div>No problem. I made a similar mistake using c# wrappers.</div><div>Here's the MR. Looking at the gitlab site, it is not obvious to me whether it got in before the 8.1 release or not, but it is definitely in the master branch.<br></div><div><a href="https://gitlab.kitware.com/vtk/vtk/merge_requests/3546/diffs?commit_id=75eb8e8a3b2a3dcaa11287a3bb2623861b322113" class="ydpc859664eenhancr_card_1764142343" rel="nofollow" target="_blank">Remove OrientationMarkerWidget from render window on destruction (!3546) · Merge Requests · VTK / VTK</a></div><br></div><div><br></div><div id="ydp5bc7934denhancr_card_1764142343" class="ydp5bc7934dyahoo-link-enhancr-card ydp5bc7934dymail-preserve-class ydp5bc7934dymail-preserve-style" style="max-width:400px;font-family:"Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif;" data-url="https://gitlab.kitware.com/vtk/vtk/merge_requests/3546/diffs?commit_id=75eb8e8a3b2a3dcaa11287a3bb2623861b322113" data-type="YENHANCER" data-size="MEDIUM" contenteditable="false"><a href="https://gitlab.kitware.com/vtk/vtk/merge_requests/3546/diffs?commit_id=75eb8e8a3b2a3dcaa11287a3bb2623861b322113" style="text-decoration:none !important;color:#000 !important;" class="ydp5bc7934dyahoo-enhancr-cardlink" rel="nofollow" target="_blank"><table class="ydp5bc7934dcard-wrapper ydp5bc7934dyahoo-ignore-table" style="max-width:400px;" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td width="400"><table class="ydp5bc7934dcard ydp5bc7934dyahoo-ignore-table" style="max-width:400px;border-width:1px;border-style:solid;border-color:rgb(224, 228, 233);border-radius:2px;" cellspacing="0" cellpadding="0" width="100%" border="0"><tbody><tr><td class="ydp5bc7934dcard-primary-image-cell" style="background-image: url("https://s.yimg.com/lo/api/res/1.2/hRS7K7svOTtDkV..yyh3rA--~A/Zmk9ZmlsbDt3PTQwMDtoPTIwMDthcHBpZD1pZXh0cmFjdA--/https://gitlab.kitware.com/uploads/-/system/project/avatar/13/vtk_logo-main1.png.cf.jpg"); background-color: rgb(0, 0, 0); background-repeat: no-repeat; background-size: cover; position: relative; border-radius: 2px 2px 0px 0px; min-height: 175px;" valign="top" height="175" background="https://s.yimg.com/lo/api/res/1.2/hRS7K7svOTtDkV..yyh3rA--~A/Zmk9ZmlsbDt3PTQwMDtoPTIwMDthcHBpZD1pZXh0cmFjdA--/https://gitlab.kitware.com/uploads/-/system/project/avatar/13/vtk_logo-main1.png.cf.jpg" bgcolor="#000000"><!--[if gte mso 9]><v:rect fill="true" stroke="false" style="width:396px;height:175px;position:absolute;top:0;left:0;"><v:fill type="frame" color="#000000" src="https://s.yimg.com/lo/api/res/1.2/hRS7K7svOTtDkV..yyh3rA--~A/Zmk9ZmlsbDt3PTQwMDtoPTIwMDthcHBpZD1pZXh0cmFjdA--/https://gitlab.kitware.com/uploads/-/system/project/avatar/13/vtk_logo-main1.png.cf.jpg"/></v:rect><![endif]--><table class="ydp5bc7934dcard-overlay-container-table ydp5bc7934dyahoo-ignore-table" style="width:100%;" cellspacing="0" cellpadding="0" border="0"><tbody><tr><td class="ydp5bc7934dcard-overlay-cell" style="background-image: url("https://s.yimg.com/cv/ae/nq/storm/assets/enhancrV21/1/enhancr_gradient-400x175.png"); background-color: transparent; border-radius: 2px 2px 0px 0px; min-height: 175px;" valign="top" background="https://s.yimg.com/cv/ae/nq/storm/assets/enhancrV21/1/enhancr_gradient-400x175.png" bgcolor="transparent"><!--[if gte mso 9]><v:rect fill="true" stroke="false" style="width:396px;height:175px;position:absolute;top:-18px;left:0;"><v:fill type="pattern" color="#000000" src="https://s.yimg.com/cv/ae/nq/storm/assets/enhancrV21/1/enhancr_gradient-400x175.png"/><v:textbox inset="0,0,20px,0"><![endif]--><table class="ydp5bc7934dyahoo-ignore-table" style="width: 100%; min-height: 175px;" height="175" border="0"><tbody><tr><td class="ydp5bc7934dcard-richInfo2" style="text-align:left;padding:15px 0 0 15px;vertical-align:top;"></td><td class="ydp5bc7934dcard-actions" style="text-align:right;padding:15px 15px 0 0;vertical-align:top;"><div class="ydp5bc7934dcard-share-container"></div></td></tr></tbody></table><!--[if gte mso 9]></v:textbox></v:rect><![endif]--></td></tr></tbody></table></td></tr><tr><td><table class="ydp5bc7934dcard-info ydp5bc7934dyahoo-ignore-table" style="background-color: rgb(255, 255, 255); background-image: none; background-repeat: repeat; background-attachment: scroll; background-size: auto auto; position: relative; z-index: 2; width: 100%; max-width: 400px; border-radius: 0px 0px 2px 2px; border-top: 1px solid rgb(224, 228, 233);" cellspacing="0" cellpadding="0" border="0" align="center"><tbody><tr><td style="background-color:#ffffff;padding:16px 0 16px 12px;vertical-align:top;border-radius:0 0 0 2px;"></td><td style="vertical-align:middle;padding:12px 24px 16px 12px;width:99%;font-family:"Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif;border-radius:0 0 2px 0;"><h2 class="ydp5bc7934dcard-title" style="font-size:14px;line-height:19px;margin:0 0 6px 0;font-family:"Helvetica Neue", "Segoe UI", Helvetica, Arial, sans-serif;word-break:break-word;color:#26282a;">Remove OrientationMarkerWidget from render window on destruction (!3546)...</h2><p class="ydp5bc7934dcard-description" style="font-size:12px;line-height:16px;margin:0px;color:#979ba7;word-break:break-word;">The orientation marker widget adds its own visual elements and an observer to the display window and also hooks ...</p></td></tr></tbody></table></td></tr></tbody></table></td></tr></tbody></table></a></div><div><br></div>
            
            <div id="ydp2830d55dyahoo_quoted_2174505480" class="ydp2830d55dyahoo_quoted">
                <div style="font-family:'Helvetica Neue', Helvetica, Arial, sans-serif;font-size:13px;color:#26282a;">
                    
                    <div>
                        On Wednesday, March 21, 2018, 12:41:22 PM GMT+13, Jesse Kinross-Smith <Jesse.Kinross-Smith@bentley.com> wrote:
                    </div>
                    <div><br></div>
                    <div><br></div>
                    <div><div id="ydp2830d55dyiv5198216096"><div>
<div class="ydp2830d55dyiv5198216096WordSection1">
<p class="ydp2830d55dyiv5198216096MsoNormal">Well I’m a dunce then aren’t I (I’m blaming this cold I have!).</p> 
<p class="ydp2830d55dyiv5198216096MsoNormal">  <br></p> 
<p class="ydp2830d55dyiv5198216096MsoNormal">Yep – works great when in a local variable.</p> 
<p class="ydp2830d55dyiv5198216096MsoNormal">Definitely interested in that patch you’ve made too. </p> 
<p class="ydp2830d55dyiv5198216096MsoNormal">  </p> 
<p class="ydp2830d55dyiv5198216096MsoNormal">Thank you very much!</p> 
<p class="ydp2830d55dyiv5198216096MsoNormal">  </p> 
<p class="ydp2830d55dyiv5198216096MsoNormal">Jesse</p> 
<p class="ydp2830d55dyiv5198216096MsoNormal">--</p> 
<p class="ydp2830d55dyiv5198216096MsoNormal">Jesse Kinross-Smith</p> 
<p class="ydp2830d55dyiv5198216096MsoNormal">Senior Software Engineer - BSW</p> 
<p class="ydp2830d55dyiv5198216096MsoNormal">Bentley Systems, Fremantle</p> 
<p class="ydp2830d55dyiv5198216096MsoNormal">  </p> 
<div class="ydp2830d55dyiv5198216096yqt0705255917" id="ydp2830d55dyiv5198216096yqt27376"><p class="ydp2830d55dyiv5198216096MsoNormal"><b>From:</b> Todd [mailto:nztoddler@yahoo.com] <br clear="none">
<b>Sent:</b> Wednesday, 21 March 2018 5:44 AM<br clear="none">
<b>To:</b> Jesse Kinross-Smith <Jesse.Kinross-Smith@bentley.com><br clear="none">
<b>Cc:</b> vtkusers@vtk.org<br clear="none">
<b>Subject:</b> Re: [vtkusers] Exception when using vtkOrientationMarkerWidget in a vtkMFCWindow</p> 
<p class="ydp2830d55dyiv5198216096MsoNormal">  </p> 
<div>
<div>
<p class="ydp2830d55dyiv5198216096MsoNormal">What version of VTK are you using?</p> 
</div>
<div>
<p class="ydp2830d55dyiv5198216096MsoNormal">  </p> 
</div>
<div>
<p class="ydp2830d55dyiv5198216096MsoNormal">You're using a local variable for the marker widget with a smart pointer. As soon as it goes out of scope, it will be destroyed. </p> 
</div>
<div>
<p class="ydp2830d55dyiv5198216096MsoNormal">  </p> 
</div>
<div>
<p class="ydp2830d55dyiv5198216096MsoNormal">To make matters worse the marker widget does not properly unhook itself from render window events upon destruction, so you get these nasty callbacks to a dead object. However I pushed a patch for this which was merged, as I recall, just
 after the official release of VTK8.1. I'll see if I can find the merge request number.</p> 
</div>
<div>
<p class="ydp2830d55dyiv5198216096MsoNormal">  </p> 
</div>
<div>
<p class="ydp2830d55dyiv5198216096MsoNormal">I would suggest creating a class member to hold onto the marker widget until you're finished with the render window; i.e. keep it alive.</p> 
</div>
<div>
<div>
<p class="ydp2830d55dyiv5198216096MsoNormal">  </p> 
<div>
<p class="ydp2830d55dyiv5198216096MsoNormal">On 21 Mar 2018 3:33 a.m., Jesse Kinross-Smith <<a shape="rect" href="mailto:Jesse.Kinross-Smith@bentley.com" rel="nofollow" target="_blank">Jesse.Kinross-Smith@bentley.com</a>> wrote:</p> 
<blockquote style="border-width: medium medium medium 1pt; border-style: none none none solid; border-color: currentcolor currentcolor currentcolor rgb(204, 204, 204); padding: 0cm 0cm 0cm 6pt; margin-left: 4.8pt; margin-right: 0cm;">
<div>
<div>
<p>Long shot, but wondering if anyone has any clue here.</p> 
<p>I’ve got a whole lot of rendering working nicely in a vtkMFCWindow and thought I’d try adding an orientation widget to show axes.</p> 
<p> </p> 
<p>I found some sample code which does this with a vtkOrientationMarkerWidget, but I tried it with our vtkMFCWindow and it’s causing an exception almost straight away.</p> 
<p> </p> 
<p>This is the code I’m using, which is almost identical to the sample code at:</p> 
<p>  <a shape="rect" href="https://urldefense.proofpoint.com/v2/url?u=https-3A__www.vtk.org_Wiki_VTK_Examples_Cxx_Visualization_DisplayCoordinateAxes&d=DwMGaQ&c=hmGTLOph1qd_VnCqj81HzEWkDaxmYdIWRBdoFggzhj8&r=QPUyrnKdkaGJHD0OTha3x09u1N6qkcvUsRW8n2fg59E&m=Ca3A5kG2b470KvD_mbq3zjTxpojP65Ujht5NwFwmiB8&s=kkG8QsL17hAP6OZCTF-wqwHw_QxzqgLZqnvJAvmwCGY&e=" rel="nofollow" target="_blank">
https://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/DisplayCoordinateAxes</a></p> 
<p> </p> 
<p><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;">vtkSmartPointer</span><span style="font-size:9.5pt;font-family:Consolas;color:black;"><</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;">vtkAxesActor</span><span style="font-size:9.5pt;font-family:Consolas;color:black;">>
 axes = </span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;">vtkSmartPointer</span><span style="font-size:9.5pt;font-family:Consolas;color:black;"><</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;">vtkAxesActor</span><span style="font-size:9.5pt;font-family:Consolas;color:black;">>::New();</span></p> 
<p><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;">vtkSmartPointer</span><span style="font-size:9.5pt;font-family:Consolas;color:black;"><</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;">vtkOrientationMarkerWidget</span><span style="font-size:9.5pt;font-family:Consolas;color:black;">>
 widget = </span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;">vtkSmartPointer</span><span style="font-size:9.5pt;font-family:Consolas;color:black;"><</span><span style="font-size:9.5pt;font-family:Consolas;color:#2B91AF;">vtkOrientationMarkerWidget</span><span style="font-size:9.5pt;font-family:Consolas;color:black;">>::New();</span></p> 
<p><span style="font-size:9.5pt;font-family:Consolas;color:black;">widget</span><span style="font-size:9.5pt;font-family:Consolas;color:teal;">-></span><span style="font-size:9.5pt;font-family:Consolas;color:black;">SetOutlineColor(0.9300, 0.5700, 0.1300);</span></p> 
<p><span style="font-size:9.5pt;font-family:Consolas;color:black;">widget</span><span style="font-size:9.5pt;font-family:Consolas;color:teal;">-></span><span style="font-size:9.5pt;font-family:Consolas;color:black;">SetOrientationMarker(axes);</span></p> 
<p><span style="font-size:9.5pt;font-family:Consolas;color:black;">widget</span><span style="font-size:9.5pt;font-family:Consolas;color:teal;">-></span><span style="font-size:9.5pt;font-family:Consolas;color:black;">SetCurrentRenderer(m_vtkRenderer);</span></p> 
<p><span style="font-size:9.5pt;font-family:Consolas;color:black;">widget</span><span style="font-size:9.5pt;font-family:Consolas;color:teal;">-></span><span style="font-size:9.5pt;font-family:Consolas;color:black;">SetInteractor(m_vtkRenderer->GetRenderWindow()->GetInteractor());</span></p> 
<p><span style="font-size:9.5pt;font-family:Consolas;color:black;">widget</span><span style="font-size:9.5pt;font-family:Consolas;color:teal;">-></span><span style="font-size:9.5pt;font-family:Consolas;color:black;">SetViewport(0.0, 0.0, 0.4, 0.4);</span></p> 
<p><span style="font-size:9.5pt;font-family:Consolas;color:black;">widget</span><span style="font-size:9.5pt;font-family:Consolas;color:teal;">-></span><span style="font-size:9.5pt;font-family:Consolas;color:black;">SetEnabled(1);</span></p> 
<p><span style="font-size:9.5pt;font-family:Consolas;color:black;">widget</span><span style="font-size:9.5pt;font-family:Consolas;color:teal;">-></span><span style="font-size:9.5pt;font-family:Consolas;color:black;">InteractiveOn();</span></p> 
<p> </p> 
<p>It actually displays both the model and the orientation axes briefly, then displays the following exception:</p> 
<p>  0xC000041D: An unhandled exception was encountered during a user callback.</p> 
<p> </p> 
<p>Call Stack:</p> 
<p>> vtkMFCWindow::OnPaint() Line 169     C++</p> 
<p>CWnd::OnWndMsg(unsigned int message, unsigned __int64 wParam, __int64 lParam, __int64 * pResult) Line 2459        C++</p> 
<p>CWnd::WindowProc(unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 2093      C++</p> 
<p>AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 265           C++</p> 
<p>AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 418              C++</p> 
<p> </p> 
<p>Anyone got any ideas?</p> 
<p> </p> 
<p>--</p> 
<p>Jesse Kinross-Smith</p> 
<p>Senior Software Engineer - BSW</p> 
<p>Bentley Systems, Fremantle</p> 
<p> </p> 
</div>
</div>
</blockquote>
</div>
<p class="ydp2830d55dyiv5198216096MsoNormal">  </p> 
</div>
</div>
</div></div>
</div>
</div></div></div>
                </div>
            </div></div></body></html>