Coverity: Uncaught exception

This commit is contained in:
wmayer
2020-07-20 13:58:15 +02:00
parent aff2e5a76d
commit b480a207c0
4 changed files with 81 additions and 46 deletions

View File

@@ -251,15 +251,20 @@ Gui::Document* DocumentWeakPtrT::operator->() noexcept
class ViewProviderWeakPtrT::Private {
public:
Private(ViewProviderDocumentObject* obj) : object(obj), indocument(false) {
if (obj) {
indocument = true;
Gui::Document* doc = obj->getDocument();
connectApplicationDeletedDocument = doc->signalDeleteDocument.connect(boost::bind
(&Private::deletedDocument, this, bp::_1));
connectDocumentCreatedObject = doc->signalNewObject.connect(boost::bind
(&Private::createdObject, this, bp::_1));
connectDocumentDeletedObject = doc->signalDeletedObject.connect(boost::bind
(&Private::deletedObject, this, bp::_1));
try {
if (obj) {
Gui::Document* doc = obj->getDocument();
indocument = true;
connectApplicationDeletedDocument = doc->signalDeleteDocument.connect(boost::bind
(&Private::deletedDocument, this, bp::_1));
connectDocumentCreatedObject = doc->signalNewObject.connect(boost::bind
(&Private::createdObject, this, bp::_1));
connectDocumentDeletedObject = doc->signalDeletedObject.connect(boost::bind
(&Private::deletedObject, this, bp::_1));
}
}
catch (const Base::RuntimeError&) {
// getDocument() may raise an exception
}
}
void deletedDocument(const Gui::Document& doc) {

View File

@@ -131,14 +131,16 @@ bool SelectionObserver::isConnectionAttached() const
void SelectionObserver::attachSelection()
{
if (!connectSelection.connected()) {
auto &signal = resolve>1?Selection().signalSelectionChanged3:(
resolve?Selection().signalSelectionChanged2:
Selection().signalSelectionChanged);
auto &signal = resolve > 1 ? Selection().signalSelectionChanged3 :
resolve ? Selection().signalSelectionChanged2 :
Selection().signalSelectionChanged ;
connectSelection = signal.connect(boost::bind
(&SelectionObserver::_onSelectionChanged, this, bp::_1));
if(filterDocName.size())
if (filterDocName.size()) {
Selection().addSelectionGate(
new SelectionGateFilterExternal(filterDocName.c_str(),filterObjName.c_str()));
}
}
}
@@ -596,7 +598,13 @@ void SelectionSingleton::notify(SelectionChanges &&Chng) {
}
if(notify) {
Notify(msg);
signalSelectionChanged(msg);
try {
signalSelectionChanged(msg);
}
catch (const boost::exception&) {
// reported by code analyzers
Base::Console().Warning("notify: Unexpected boost exception\n");
}
}
NotificationQueue.pop_front();
}
@@ -732,16 +740,28 @@ void SelectionSingleton::slotSelectionChanged(const SelectionChanges& msg) {
newElementName.size()?newElementName.c_str():oldElementName.c_str(),
pObject->getTypeId().getName(), msg.x,msg.y,msg.z);
msg2.pOriginalMsg = &msg;
signalSelectionChanged3(msg2);
try {
msg2.pOriginalMsg = &msg;
signalSelectionChanged3(msg2);
msg2.Object.setSubName(oldElementName.c_str());
msg2.pSubName = msg2.Object.getSubName().c_str();
signalSelectionChanged2(msg2);
}else {
signalSelectionChanged3(msg);
signalSelectionChanged2(msg);
msg2.Object.setSubName(oldElementName.c_str());
msg2.pSubName = msg2.Object.getSubName().c_str();
signalSelectionChanged2(msg2);
}
catch (const boost::exception&) {
// reported by code analyzers
Base::Console().Warning("slotSelectionChanged: Unexpected boost exception\n");
}
}
else {
try {
signalSelectionChanged3(msg);
signalSelectionChanged2(msg);
}
catch (const boost::exception&) {
// reported by code analyzers
Base::Console().Warning("slotSelectionChanged: Unexpected boost exception\n");
}
}
}

View File

@@ -593,7 +593,7 @@ void PartGui::DlgProjectionOnSurface::higlight_object(Part::Feature* iCurrentObj
{
if (!iCurrentObject) return;
auto partenShape = iCurrentObject->Shape.getShape().getShape();
auto subShape = iCurrentObject->Shape.getShape().getSubShape(iShapeName.c_str());
auto subShape = iCurrentObject->Shape.getShape().getSubShape(iShapeName.c_str(), true);
TopoDS_Shape currentShape = subShape;
if (subShape.IsNull()) currentShape = partenShape;

View File

@@ -120,19 +120,24 @@ TaskPipeParameters::TaskPipeParameters(ViewProviderPipe *PipeView, bool /*newObj
TaskPipeParameters::~TaskPipeParameters()
{
if (vp) {
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject());
Gui::Document* doc = vp->getDocument();
try {
if (vp) {
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject());
Gui::Document* doc = vp->getDocument();
//make sure the user sees all important things: the
//spine/auxiliary spine he already selected
if (pipe->Spine.getValue()) {
auto* svp = doc->getViewProvider(pipe->Spine.getValue());
svp->setVisible(spineShow);
spineShow = false;
//make sure the user sees all important things: the
//spine/auxiliary spine he already selected
if (pipe->Spine.getValue()) {
auto* svp = doc->getViewProvider(pipe->Spine.getValue());
svp->setVisible(spineShow);
spineShow = false;
}
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, false);
}
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, false);
}
catch (const Base::RuntimeError&) {
// getDocument() may raise an exception
}
delete ui;
@@ -420,19 +425,24 @@ TaskPipeOrientation::TaskPipeOrientation(ViewProviderPipe* PipeView, bool /*newO
TaskPipeOrientation::~TaskPipeOrientation()
{
if (vp) {
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject());
Gui::Document* doc = vp->getDocument();
try {
if (vp) {
PartDesign::Pipe* pipe = static_cast<PartDesign::Pipe*>(vp->getObject());
Gui::Document* doc = vp->getDocument();
//make sure the user sees al important things: the base feature to select edges and the
//spine/auxiliary spine he already selected
if (pipe->AuxillerySpine.getValue()) {
auto* svp = doc->getViewProvider(pipe->AuxillerySpine.getValue());
svp->setVisible(auxSpineShow);
auxSpineShow = false;
//make sure the user sees al important things: the base feature to select edges and the
//spine/auxiliary spine he already selected
if (pipe->AuxillerySpine.getValue()) {
auto* svp = doc->getViewProvider(pipe->AuxillerySpine.getValue());
svp->setVisible(auxSpineShow);
auxSpineShow = false;
}
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, true);
}
static_cast<ViewProviderPipe*>(vp)->highlightReferences(false, true);
}
catch (const Base::RuntimeError&) {
// getDocument() may raise an exception
}
}