[vtkusers] Exception when using vtkOrientationMarkerWidget in a vtkMFCWindow

Jesse Kinross-Smith Jesse.Kinross-Smith at bentley.com
Tue Mar 20 19:41:18 EDT 2018


Well I’m a dunce then aren’t I (I’m blaming this cold I have!).

Yep – works great when in a local variable.
Definitely interested in that patch you’ve made too.

Thank you very much!

Jesse
--
Jesse Kinross-Smith
Senior Software Engineer - BSW
Bentley Systems, Fremantle

From: Todd [mailto:nztoddler at yahoo.com]
Sent: Wednesday, 21 March 2018 5:44 AM
To: Jesse Kinross-Smith <Jesse.Kinross-Smith at bentley.com>
Cc: vtkusers at vtk.org
Subject: Re: [vtkusers] Exception when using vtkOrientationMarkerWidget in a vtkMFCWindow

What version of VTK are you using?

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.

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.

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.

On 21 Mar 2018 3:33 a.m., Jesse Kinross-Smith <Jesse.Kinross-Smith at bentley.com<mailto:Jesse.Kinross-Smith at bentley.com>> wrote:

Long shot, but wondering if anyone has any clue here.

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.



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.



This is the code I’m using, which is almost identical to the sample code at:

  https://www.vtk.org/Wiki/VTK/Examples/Cxx/Visualization/DisplayCoordinateAxes<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=>



vtkSmartPointer<vtkAxesActor> axes = vtkSmartPointer<vtkAxesActor>::New();

vtkSmartPointer<vtkOrientationMarkerWidget> widget = vtkSmartPointer<vtkOrientationMarkerWidget>::New();

widget->SetOutlineColor(0.9300, 0.5700, 0.1300);

widget->SetOrientationMarker(axes);

widget->SetCurrentRenderer(m_vtkRenderer);

widget->SetInteractor(m_vtkRenderer->GetRenderWindow()->GetInteractor());

widget->SetViewport(0.0, 0.0, 0.4, 0.4);

widget->SetEnabled(1);

widget->InteractiveOn();



It actually displays both the model and the orientation axes briefly, then displays the following exception:

  0xC000041D: An unhandled exception was encountered during a user callback.



Call Stack:

> vtkMFCWindow::OnPaint() Line 169     C++

CWnd::OnWndMsg(unsigned int message, unsigned __int64 wParam, __int64 lParam, __int64 * pResult) Line 2459        C++

CWnd::WindowProc(unsigned int message, unsigned __int64 wParam, __int64 lParam) Line 2093      C++

AfxCallWndProc(CWnd * pWnd, HWND__ * hWnd, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 265           C++

AfxWndProc(HWND__ * hWnd, unsigned int nMsg, unsigned __int64 wParam, __int64 lParam) Line 418              C++



Anyone got any ideas?



--

Jesse Kinross-Smith

Senior Software Engineer - BSW

Bentley Systems, Fremantle



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://vtk.org/pipermail/vtkusers/attachments/20180320/fa622d8b/attachment.html>


More information about the vtkusers mailing list