move check for grabbed node and releasing it from ViewProviderDragger::unsetEditViewer to View3DInventorViewer::resetEditingViewProvider

This commit is contained in:
wmayer
2018-09-11 17:27:17 +02:00
parent 8f3c135a5c
commit 90258a47f0
3 changed files with 9 additions and 5 deletions

View File

@@ -43,6 +43,7 @@
#include <Inventor/SoPrimitiveVertex.h>
#include <Inventor/SbTesselator.h>
#include <Inventor/SbViewportRegion.h>
#include <Inventor/SoEventManager.h>
#include <Inventor/actions/SoBoxHighlightRenderAction.h>
#include <Inventor/actions/SoGetBoundingBoxAction.h>
#include <Inventor/actions/SoGetMatrixAction.h>

View File

@@ -33,6 +33,7 @@
# include <GL/gl.h>
# endif
# include <Inventor/SbBox.h>
# include <Inventor/SoEventManager.h>
# include <Inventor/actions/SoGetBoundingBoxAction.h>
# include <Inventor/actions/SoGetMatrixAction.h>
# include <Inventor/actions/SoHandleEventAction.h>
@@ -720,6 +721,13 @@ SbBool View3DInventorViewer::setEditingViewProvider(Gui::ViewProvider* p, int Mo
void View3DInventorViewer::resetEditingViewProvider()
{
if (this->editViewProvider) {
// In case the event action still has grabbed a node when leaving edit mode
// force to release it now
SoEventManager* mgr = this->getSoEventManager();
SoHandleEventAction* heaction = mgr->getHandleEventAction();
if (heaction && heaction->getGrabber())
heaction->releaseGrabber();
this->editViewProvider->unsetEditViewer(this);
removeEventCallback(SoEvent::getClassTypeId(), Gui::ViewProvider::eventCallback,this->editViewProvider);
this->editViewProvider = 0;

View File

@@ -43,7 +43,6 @@
# include <Inventor/SoPickedPoint.h>
# include <Inventor/actions/SoRayPickAction.h>
#endif
# include <Inventor/SoEventManager.h>
/// Here the FreeCAD includes sorted by Base,App,Gui......
#include "ViewProviderDragger.h"
@@ -179,10 +178,6 @@ void ViewProviderDragger::setEditViewer(Gui::View3DInventorViewer* viewer, int M
void ViewProviderDragger::unsetEditViewer(Gui::View3DInventorViewer* viewer)
{
SoEventManager* mgr = viewer->getSoEventManager();
SoHandleEventAction* heaction = mgr->getHandleEventAction();
if (heaction && heaction->getGrabber())
heaction->releaseGrabber();
SoFCUnifiedSelection* selection = static_cast<SoFCUnifiedSelection*>(viewer->getSceneGraph());
SoNode *child = selection->getChild(0);
if (child && child->isOfType(SoPickStyle::getClassTypeId())) {