[vtkusers] ActiViz | Garbage Collection unhandled exception

franko franko at mixzon.com
Fri Feb 14 16:51:05 EST 2014


OK, I think I've resolved this one.

I have the following code:

// Redirect output (error messages) that by default go to the VTK Output
Window
void CorViz::RedirectVTKOutput() {
	this->FileOutputWindow = gcnew vtkFileOutputWindow();
	this->FileOutputWindow->SetFileName("c:\vtkerror.txt");
	this->FileOutputWindow->SetFlush(1);
	vtkOutputWindow^ outputWindow = vtkOutputWindow::GetInstance();
	if (outputWindow != nullptr) {
		outputWindow->SetInstance(this->FileOutputWindow);
		this->FileOutputWindow->ErrorEvt += gcnew
vtkObject::vtkObjectEventHandler(this, &CorViz::outputWindowErrorEvt);
	}
}

// Output Window Error Event Handler
void CorViz::outputWindowErrorEvt(vtkObject^ sender, vtkObjectEventArgs^ e)
{
	String^ s = "ERROR: unknown\n";
	try {
		if (e->CallData != System::IntPtr::Zero) {
			s =
System::Runtime::InteropServices::Marshal::PtrToStringAnsi(e->CallData);
		}
		Debug::Write(s);
	}
	catch (Exception^ ex) {
		// handle exception
		String^ msg = "Event Handler outputWindowErrorEvt had Exception: \n" +
ex->ToString();
		Debug::Write(msg);
	}
}

The problem seems to be related to the order that I call:

this->RedirectVTKOutput();
this->renWindow->AddRenderer(this->renderer);    // not shown above

The problem occurs if I call RedirectVTKOutput() after AddRenderer().
If anyone has any comments on what I'm doing, please reply.

Thanks,
Frank Opila





--
View this message in context: http://vtk.1045678.n5.nabble.com/ActiViz-Garbage-Collection-unhandled-exception-tp5725932p5725934.html
Sent from the VTK - Users mailing list archive at Nabble.com.


More information about the vtkusers mailing list