Commit e8170ff5 authored by Max Smolens's avatar Max Smolens

Fix multiple definitions of vtkInteractionCallback

A class called vtkInteractionCallback was defined twice: in
vtkImplicitCylinderWidget.cxx and in vtkImplicitPlaneWidget2.cxx. This violates
the one definition rule and can lead to undefined behavior.

This commit resolves the ambiguity by removing the callback from
vtkImplicitCylinderWidget. vtkImplicitCylinderWidget does not actually require
the callback; the code is leftover from a copy/paste of vtkImplicitPlaneWidget2.
vtkImplicitPlaneWidget2 uses the callback to implement SetLockNormalToCamera(),
which does not exist on vtkImplicitCylinderWidget.
parent d978f250
Pipeline #18431 passed with stage
......@@ -30,26 +30,6 @@
vtkStandardNewMacro(vtkImplicitCylinderWidget);
// The implicit cylinder widget observes its representation. The representation
// may invoke an InteractionEvent when the camera moves when LockedNormalToCamera
// is enabled.
class vtkInteractionCallback : public vtkCommand
{
public:
static vtkInteractionCallback *New()
{ return new vtkInteractionCallback; }
virtual void Execute(vtkObject*, unsigned long eventId, void*)
{
switch (eventId)
{
case vtkCommand::ModifiedEvent:
this->CylinderWidget->InvokeInteractionCallback();
break;
}
}
vtkImplicitCylinderWidget *CylinderWidget;
};
//----------------------------------------------------------------------------
vtkImplicitCylinderWidget::vtkImplicitCylinderWidget()
{
......@@ -93,15 +73,11 @@ vtkImplicitCylinderWidget::vtkImplicitCylinderWidget()
vtkEvent::AnyModifier, 29, 1, "Left",
vtkWidgetEvent::Down,
this, vtkImplicitCylinderWidget::MoveCylinderAction);
this->InteractionCallback = vtkInteractionCallback::New();
this->InteractionCallback->CylinderWidget = this;
}
//----------------------------------------------------------------------------
vtkImplicitCylinderWidget::~vtkImplicitCylinderWidget()
{
this->InteractionCallback->Delete();
}
//----------------------------------------------------------------------
......@@ -336,11 +312,6 @@ void vtkImplicitCylinderWidget::SetEnabled(int enabling)
return;
}
if(this->GetCurrentRenderer() && !enabling)
{
this->GetCurrentRenderer()->GetActiveCamera()->RemoveObserver(this->InteractionCallback);
}
Superclass::SetEnabled(enabling);
}
......@@ -385,21 +356,6 @@ int vtkImplicitCylinderWidget::UpdateCursorShape( int state )
return 0;
}
//----------------------------------------------------------------------------
void vtkImplicitCylinderWidget::InvokeInteractionCallback()
{
unsigned long previousMtime;
vtkImplicitCylinderRepresentation* widgetRep =
reinterpret_cast<vtkImplicitCylinderRepresentation*>(this->WidgetRep);
previousMtime = widgetRep->GetMTime();
if(widgetRep->GetMTime() > previousMtime)
{
this->InvokeEvent(vtkCommand::InteractionEvent,NULL);
}
}
//----------------------------------------------------------------------------
void vtkImplicitCylinderWidget::PrintSelf(ostream& os, vtkIndent indent)
{
......
......@@ -87,12 +87,9 @@
#include "vtkAbstractWidget.h"
class vtkImplicitCylinderRepresentation;
class vtkInteractionCallback;
class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitCylinderWidget : public vtkAbstractWidget
{
friend class vtkInteractionCallback;
public:
// Description:
// Instantiate the object.
......@@ -144,11 +141,6 @@ protected:
// if the cursor shape requested is different from the existing one.
int UpdateCursorShape( int interactionState );
// Description:
// Handle the interaction callback that may come from the representation
vtkInteractionCallback *InteractionCallback;
void InvokeInteractionCallback();
private:
vtkImplicitCylinderWidget(const vtkImplicitCylinderWidget&); //Not implemented
void operator=(const vtkImplicitCylinderWidget&); //Not implemented
......
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