Skip to content

Commit

Permalink
Fix multiple definitions of vtkInteractionCallback
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
msmolens committed Jul 5, 2016
1 parent d978f25 commit e8170ff
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 52 deletions.
44 changes: 0 additions & 44 deletions Interaction/Widgets/vtkImplicitCylinderWidget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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()
{
Expand Down Expand Up @@ -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();
}

//----------------------------------------------------------------------
Expand Down Expand Up @@ -336,11 +312,6 @@ void vtkImplicitCylinderWidget::SetEnabled(int enabling)
return;
}

if(this->GetCurrentRenderer() && !enabling)
{
this->GetCurrentRenderer()->GetActiveCamera()->RemoveObserver(this->InteractionCallback);
}

Superclass::SetEnabled(enabling);
}

Expand Down Expand Up @@ -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)
{
Expand Down
8 changes: 0 additions & 8 deletions Interaction/Widgets/vtkImplicitCylinderWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -144,11 +141,6 @@ class VTKINTERACTIONWIDGETS_EXPORT vtkImplicitCylinderWidget : public vtkAbstrac
// 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
Expand Down

0 comments on commit e8170ff

Please sign in to comment.