ViewProvider: fix potential crash when exit editing

This commit is contained in:
Zheng, Lei
2018-09-03 12:28:54 +08:00
committed by wmayer
parent 50ab6e292c
commit 70918ba683

View File

@@ -24,6 +24,7 @@
#include "PreCompiled.h"
#ifndef _PreComp_
# include <QApplication>
# include <QPixmap>
# include <QTimer>
# include <Inventor/SoPickedPoint.h>
@@ -56,6 +57,8 @@
#include <boost/bind.hpp>
FC_LOG_LEVEL_INIT("ViewProvider",true,true)
using namespace std;
using namespace Gui;
@@ -178,13 +181,22 @@ void ViewProvider::eventCallback(void * ud, SoEventCallback * node)
if (self->keyPressed (press, ke->getKey())) {
node->setHandled();
}
else {
else if(QApplication::mouseButtons()==Qt::NoButton) {
// Because of a Coin bug (https://bitbucket.org/Coin3D/coin/pull-requests/119),
// FC may crash if user hits ESC to cancel while still
// holding the mouse button while using some SoDragger.
// Therefore, we shall ignore ESC while any mouse button is
// pressed, until this Coin bug is fixed.
Gui::TimerFunction* func = new Gui::TimerFunction();
func->setAutoDelete(true);
Gui::Document* doc = Gui::Application::Instance->activeDocument();
func->setFunction(boost::bind(&Document::resetEdit, doc));
QTimer::singleShot(0, func, SLOT(timeout()));
}
else if (press) {
FC_WARN("Please release all mouse buttons before exiting editing");
}
break;
default:
// call the virtual method