<div dir='auto'><div>What version of VTK are you using?</div><div dir="auto"><br></div><div dir="auto">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. </div><div dir="auto"><br></div><div dir="auto">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.</div><div dir="auto"><br></div><div dir="auto">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.</div><div dir="auto"><div dir="auto"><br><div class="elided-text">On 21 Mar 2018 3:33 a.m., Jesse Kinross-Smith <Jesse.Kinross-Smith@bentley.com> wrote:<br><blockquote style="margin:0 0 0 0.8ex;border-left:1px #ccc solid;padding-left:1ex"><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 href="https://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/DisplayCoordinateAxes">
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><br></div></div></div>