Selection: handle exception in observer callback

Selection callback are sometimes called while traversing Coin node tree.
If any unhandled exception is thrown while traversing the tree, FC 3D
rendering will become unstable and non-usable thereafter.
This commit is contained in:
Zheng, Lei
2018-08-22 16:51:48 +08:00
committed by wmayer
parent 561be08211
commit 69efa47374
3 changed files with 32 additions and 4 deletions

View File

@@ -49,7 +49,7 @@
#include <Gui/SelectionObjectPy.h>
#include "MainWindow.h"
FC_LOG_LEVEL_INIT("Selection",false,true,true)
using namespace Gui;
using namespace std;
@@ -83,7 +83,20 @@ void SelectionObserver::attachSelection()
{
if (!connectSelection.connected()) {
connectSelection = Selection().signalSelectionChanged.connect(boost::bind
(&SelectionObserver::onSelectionChanged, this, _1));
(&SelectionObserver::_onSelectionChanged, this, _1));
}
}
void SelectionObserver::_onSelectionChanged(const SelectionChanges& msg) {
try {
onSelectionChanged(msg);
} catch (Base::Exception &e) {
e.ReportException();
FC_ERR("Unhandled Base::Exception caught in selection observer: ");
} catch (std::exception &e) {
FC_ERR("Unhandled std::exception caught in selection observer: " << e.what());
} catch (...) {
FC_ERR("Unhandled unknown exception caught in selection observer");
}
}