Commit e0d26a7e authored by Ken Martin's avatar Ken Martin
Browse files

better delete handling

parent 16a67208
......@@ -17,7 +17,7 @@
#include "vtkObjectFactory.h"
#include "vtkRenderWindowInteractor.h"
vtkCxxRevisionMacro(vtkInteractorEventRecorder, "1.7");
vtkCxxRevisionMacro(vtkInteractorEventRecorder, "1.8");
vtkStandardNewMacro(vtkInteractorEventRecorder);
float vtkInteractorEventRecorder::StreamVersion = 1.0;
......@@ -44,6 +44,8 @@ vtkInteractorEventRecorder::vtkInteractorEventRecorder()
vtkInteractorEventRecorder::~vtkInteractorEventRecorder()
{
this->SetInteractor(0);
if ( this->FileName )
{
delete [] this->FileName;
......@@ -295,8 +297,8 @@ void vtkInteractorEventRecorder::ProcessCharEvent(vtkObject* object,
switch(event)
{
case vtkCommand::DeleteEvent:
//self->Interactor = NULL; //its going bye bye
//self->Enabled = 0; //can't write to a deleted object
// if the interactor is being deleted then remove the event handlers
self->SetInteractor(0);
break;
case vtkCommand::CharEvent:
......
......@@ -20,7 +20,7 @@
#include "vtkRenderWindow.h"
#include "vtkRenderWindowInteractor.h"
vtkCxxRevisionMacro(vtkInteractorObserver, "1.30");
vtkCxxRevisionMacro(vtkInteractorObserver, "1.31");
vtkCxxSetObjectMacro(vtkInteractorObserver,DefaultRenderer,vtkRenderer);
......@@ -123,9 +123,9 @@ void vtkInteractorObserver::SetInteractor(vtkRenderWindowInteractor* i)
this->Interactor->RemoveObserver(this->DeleteObserverTag);
this->DeleteObserverTag = 0;
}
this->Interactor = i;
// add observers for each of the events handled in ProcessEvents
if (i)
{
......@@ -145,14 +145,22 @@ void vtkInteractorObserver::ProcessEvents(vtkObject* vtkNotUsed(object),
void* clientdata,
void* vtkNotUsed(calldata))
{
if (event == vtkCommand::CharEvent)
if (event == vtkCommand::CharEvent ||
event == vtkCommand::DeleteEvent)
{
vtkObject *vobj = reinterpret_cast<vtkObject *>( clientdata );
vtkInteractorObserver* self
= vtkInteractorObserver::SafeDownCast(vobj);
if (self)
{
self->OnChar();
if (event == vtkCommand::CharEvent)
{
self->OnChar();
}
else // delete event
{
self->SetInteractor(0);
}
}
else
{
......
......@@ -32,7 +32,7 @@
#include "vtkRenderer.h"
#include "vtkTextProperty.h"
vtkCxxRevisionMacro(vtkInteractorStyle, "1.95");
vtkCxxRevisionMacro(vtkInteractorStyle, "1.96");
vtkStandardNewMacro(vtkInteractorStyle);
//----------------------------------------------------------------------------
......@@ -1084,7 +1084,7 @@ void vtkInteractorStyle::ProcessEvents(vtkObject* vtkNotUsed(object),
break;
case vtkCommand::DeleteEvent:
self->Interactor = 0;
self->SetInteractor(0);
break;
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment