fix Coverity issues
This commit is contained in:
parent
7f2a9da5d3
commit
63ad26491f
|
@ -54,8 +54,8 @@
|
|||
# include <TopTools_IndexedMapOfShape.hxx>
|
||||
# include <Poly_PolygonOnTriangulation.hxx>
|
||||
# include <TColStd_Array1OfInteger.hxx>
|
||||
# include <TopTools_ListOfShape.hxx>
|
||||
# include <Inventor/SoPickedPoint.h>
|
||||
# include <TopTools_ListOfShape.hxx>
|
||||
# include <Inventor/SoPickedPoint.h>
|
||||
# include <Inventor/events/SoMouseButtonEvent.h>
|
||||
# include <Inventor/nodes/SoCoordinate3.h>
|
||||
# include <Inventor/nodes/SoDrawStyle.h>
|
||||
|
@ -98,7 +98,19 @@ PROPERTY_SOURCE(PartGui::ViewProviderPartReference, Gui::ViewProviderGeometryObj
|
|||
//**************************************************************************
|
||||
// Construction/Destruction
|
||||
|
||||
ViewProviderPartReference::ViewProviderPartReference() : pcControlPoints(0)
|
||||
ViewProviderPartReference::ViewProviderPartReference()
|
||||
: EdgeRoot(0)
|
||||
, FaceRoot(0)
|
||||
, VertexRoot(0)
|
||||
, pcLineMaterial(0)
|
||||
, pcPointMaterial(0)
|
||||
, pcLineStyle(0)
|
||||
, pcPointStyle(0)
|
||||
, pcControlPoints(0)
|
||||
, pShapeHints(0)
|
||||
, meshDeviation(0.01f)
|
||||
, noPerVertexNormals(true)
|
||||
, qualityNormals(false)
|
||||
{
|
||||
App::Material mat;
|
||||
mat.ambientColor.set(0.2f,0.2f,0.2f);
|
||||
|
@ -116,8 +128,8 @@ ViewProviderPartReference::ViewProviderPartReference() : pcControlPoints(0)
|
|||
//PointSize.setConstraints(&floatRange);
|
||||
//ADD_PROPERTY(PointSize,(2.0f));
|
||||
//ADD_PROPERTY(ControlPoints,(false));
|
||||
//ADD_PROPERTY(Lighting,(1));
|
||||
//Lighting.setEnums(LightingEnums);
|
||||
//ADD_PROPERTY(Lighting,(1));
|
||||
//Lighting.setEnums(LightingEnums);
|
||||
|
||||
//EdgeRoot = new SoSeparator();
|
||||
//EdgeRoot->ref();
|
||||
|
@ -142,11 +154,11 @@ ViewProviderPartReference::ViewProviderPartReference() : pcControlPoints(0)
|
|||
//pcPointStyle->ref();
|
||||
//pcPointStyle->style = SoDrawStyle::POINTS;
|
||||
//pcPointStyle->pointSize = PointSize.getValue();
|
||||
|
||||
//pShapeHints = new SoShapeHints;
|
||||
//pShapeHints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
|
||||
//pShapeHints->ref();
|
||||
//Lighting.touch();
|
||||
|
||||
//pShapeHints = new SoShapeHints;
|
||||
//pShapeHints->shapeType = SoShapeHints::UNKNOWN_SHAPE_TYPE;
|
||||
//pShapeHints->ref();
|
||||
//Lighting.touch();
|
||||
|
||||
sPixmap = "Tree_Part";
|
||||
//loadParameter();
|
||||
|
@ -161,7 +173,7 @@ ViewProviderPartReference::~ViewProviderPartReference()
|
|||
//pcPointMaterial->unref();
|
||||
//pcLineStyle->unref();
|
||||
//pcPointStyle->unref();
|
||||
//pShapeHints->unref();
|
||||
//pShapeHints->unref();
|
||||
}
|
||||
|
||||
void ViewProviderPartReference::onChanged(const App::Property* prop)
|
||||
|
@ -211,12 +223,12 @@ void ViewProviderPartReference::onChanged(const App::Property* prop)
|
|||
// App::Property* shape = obj->getPropertyByName("Shape");
|
||||
// showControlPoints(ControlPoints.getValue(), shape);
|
||||
//}
|
||||
//else if (prop == &Lighting) {
|
||||
// if (Lighting.getValue() == 0)
|
||||
// pShapeHints->vertexOrdering = SoShapeHints::UNKNOWN_ORDERING;
|
||||
// else
|
||||
// pShapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
|
||||
//}
|
||||
//else if (prop == &Lighting) {
|
||||
// if (Lighting.getValue() == 0)
|
||||
// pShapeHints->vertexOrdering = SoShapeHints::UNKNOWN_ORDERING;
|
||||
// else
|
||||
// pShapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE;
|
||||
//}
|
||||
//else {
|
||||
// ViewProviderGeometryObject::onChanged(prop);
|
||||
//}
|
||||
|
|
|
@ -124,6 +124,8 @@ const std::list<gp_Trsf> MultiTransform::getTransformations(const std::vector<Ap
|
|||
// In other words, the length of the result vector is equal to the length of the
|
||||
// oldTransformations vector
|
||||
|
||||
if (newTransformations.empty())
|
||||
throw Base::Exception("Number of occurrences must be a divisor of previous number of occurrences");
|
||||
if (oldTransformations.size() % newTransformations.size() != 0)
|
||||
throw Base::Exception("Number of occurrences must be a divisor of previous number of occurrences");
|
||||
|
||||
|
|
|
@ -601,6 +601,7 @@ void CmdPartDesignMoveFeature::activated(int iMsg)
|
|||
items, 0, false, &ok);
|
||||
if (!ok) return;
|
||||
int index = items.indexOf(text);
|
||||
if (index < 0) return;
|
||||
|
||||
PartDesign::Body* target = static_cast<PartDesign::Body*>(bodies[index]);
|
||||
|
||||
|
|
|
@ -208,6 +208,8 @@ std::vector<App::DocumentObject*> TaskFeaturePick::buildFeatures() {
|
|||
int index = 0;
|
||||
std::vector<App::DocumentObject*> result;
|
||||
auto activeBody = PartDesignGui::getBody(false);
|
||||
if (!activeBody)
|
||||
return result;
|
||||
auto activePart = PartDesignGui::getPartFor(activeBody, false);
|
||||
|
||||
for (std::vector<featureStatus>::const_iterator st = statuses.begin(); st != statuses.end(); st++) {
|
||||
|
|
|
@ -58,7 +58,7 @@ using namespace Gui;
|
|||
/* TRANSLATOR PartDesignGui::TaskMultiTransformParameters */
|
||||
|
||||
TaskMultiTransformParameters::TaskMultiTransformParameters(ViewProviderTransformed *TransformedView,QWidget *parent)
|
||||
: TaskTransformedParameters(TransformedView, parent), subTask(NULL)
|
||||
: TaskTransformedParameters(TransformedView, parent), subTask(nullptr), subFeature(nullptr)
|
||||
{
|
||||
// we need a separate container widget to add all controls to
|
||||
proxy = new QWidget(this);
|
||||
|
|
|
@ -778,10 +778,11 @@ bool TaskDlgPipeParameters::accept()
|
|||
|
||||
//we need to add the copied features to the body after the command action, as otherwise freecad crashs unexplainable
|
||||
for(auto obj : copies) {
|
||||
if(pcActiveBody)
|
||||
pcActiveBody->addFeature(obj);
|
||||
else if (pcActivePart)
|
||||
pcActivePart->addObject(obj);
|
||||
//Dead code: pcActiveBody was previously used without checking for null, so it won't be null here either.
|
||||
//if(pcActiveBody)
|
||||
pcActiveBody->addFeature(obj);
|
||||
//else if (pcActivePart)
|
||||
// pcActivePart->addObject(obj);
|
||||
}
|
||||
}
|
||||
catch (const Base::Exception& e) {
|
||||
|
|
|
@ -94,30 +94,29 @@ const QString TaskSketchBasedParameters::onAddSelection(const Gui::SelectionChan
|
|||
void TaskSketchBasedParameters::onSelectReference(const bool pressed, const bool edge, const bool face, const bool planar) {
|
||||
// Note: Even if there is no solid, App::Plane and Part::Datum can still be selected
|
||||
|
||||
PartDesign::ProfileBased* pcSketchBased = static_cast<PartDesign::ProfileBased*>(vp->getObject());
|
||||
PartDesign::ProfileBased* pcSketchBased = dynamic_cast<PartDesign::ProfileBased*>(vp->getObject());
|
||||
if (pcSketchBased) {
|
||||
// The solid this feature will be fused to
|
||||
App::DocumentObject* prevSolid = pcSketchBased->getBaseObject( /* silent =*/ true );
|
||||
|
||||
// The solid this feature will be fused to
|
||||
App::DocumentObject* prevSolid = pcSketchBased->getBaseObject( /* silent =*/ true );
|
||||
|
||||
if (pressed) {
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc) {
|
||||
if (pcSketchBased)
|
||||
if (pressed) {
|
||||
Gui::Document* doc = vp->getDocument();
|
||||
if (doc) {
|
||||
doc->setHide(pcSketchBased->getNameInDocument());
|
||||
if (prevSolid)
|
||||
doc->setShow(prevSolid->getNameInDocument());
|
||||
}
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelectionGate
|
||||
(new ReferenceSelection(prevSolid, edge, face, planar));
|
||||
} else {
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
Gui::Document* doc = Gui::Application::Instance->activeDocument();
|
||||
if (doc) {
|
||||
if (pcSketchBased)
|
||||
if (prevSolid)
|
||||
doc->setShow(prevSolid->getNameInDocument());
|
||||
}
|
||||
Gui::Selection().clearSelection();
|
||||
Gui::Selection().addSelectionGate
|
||||
(new ReferenceSelection(prevSolid, edge, face, planar));
|
||||
} else {
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
Gui::Document* doc = vp->getDocument();
|
||||
if (doc) {
|
||||
doc->setShow(pcSketchBased->getNameInDocument());
|
||||
if (prevSolid)
|
||||
doc->setHide(prevSolid->getNameInDocument());
|
||||
if (prevSolid)
|
||||
doc->setHide(prevSolid->getNameInDocument());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -129,7 +128,7 @@ void TaskSketchBasedParameters::exitSelectionMode()
|
|||
|
||||
const QByteArray TaskSketchBasedParameters::onFaceName(const QString& text)
|
||||
{
|
||||
if (text.length() == 0)
|
||||
if (text.isEmpty())
|
||||
return QByteArray();
|
||||
|
||||
QStringList parts = text.split(QChar::fromLatin1(':'));
|
||||
|
@ -141,6 +140,9 @@ const QByteArray TaskSketchBasedParameters::onFaceName(const QString& text)
|
|||
return QByteArray();
|
||||
|
||||
PartDesign::Body* activeBody = Gui::Application::Instance->activeView()->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
if (!activeBody)
|
||||
return QByteArray();
|
||||
|
||||
if (obj->getTypeId().isDerivedFrom(App::Plane::getClassTypeId())) {
|
||||
// everything is OK (we assume a Part can only have exactly 3 App::Plane objects located at the base of the feature tree)
|
||||
return QByteArray();
|
||||
|
|
|
@ -65,8 +65,9 @@ TaskTransformedParameters::TaskTransformedParameters(ViewProviderTransformed *Tr
|
|||
QString::fromLatin1((TransformedView->featureName + " parameters").c_str()),
|
||||
true,
|
||||
parent),
|
||||
proxy(nullptr),
|
||||
TransformedView(TransformedView),
|
||||
parentTask(NULL),
|
||||
parentTask(nullptr),
|
||||
insideMultiTransform(false),
|
||||
blockUpdate(false)
|
||||
{
|
||||
|
@ -75,7 +76,8 @@ TaskTransformedParameters::TaskTransformedParameters(ViewProviderTransformed *Tr
|
|||
|
||||
TaskTransformedParameters::TaskTransformedParameters(TaskMultiTransformParameters *parentTask)
|
||||
: TaskBox(QPixmap(), tr(""), true, parentTask),
|
||||
TransformedView(NULL),
|
||||
proxy(nullptr),
|
||||
TransformedView(nullptr),
|
||||
parentTask(parentTask),
|
||||
insideMultiTransform(true),
|
||||
blockUpdate(false)
|
||||
|
@ -345,7 +347,7 @@ void TaskTransformedParameters::addReferenceSelectionGate(bool edge, bool face)
|
|||
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
|
||||
|
||||
TaskDlgTransformedParameters::TaskDlgTransformedParameters(ViewProviderTransformed *TransformedView_)
|
||||
: TaskDlgFeatureParameters(TransformedView_)
|
||||
: TaskDlgFeatureParameters(TransformedView_), parameter(0)
|
||||
{
|
||||
assert(vp);
|
||||
message = new TaskTransformedMessages(getTransformedView());
|
||||
|
|
|
@ -59,23 +59,22 @@ PartDesign::Body *getBody(bool messageIfNot)
|
|||
PartDesign::Body * activeBody = nullptr;
|
||||
Gui::MDIView *activeView = Gui::Application::Instance->activeView();
|
||||
|
||||
if ( PartDesignGui::assureModernWorkflow ( activeView->getAppDocument() ) ) {
|
||||
|
||||
if (activeView) {
|
||||
if (activeView) {
|
||||
if ( PartDesignGui::assureModernWorkflow ( activeView->getAppDocument() ) ) {
|
||||
activeBody = activeView->getActiveObject<PartDesign::Body*>(PDBODYKEY);
|
||||
}
|
||||
|
||||
if (!activeBody && messageIfNot) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No active Body"),
|
||||
QObject::tr("In order to use PartDesign you need an active Body object in the document. "
|
||||
"Please make one active (double click) or create one. If you have a legacy document "
|
||||
"with PartDesign objects without Body, use the transfer function in "
|
||||
"PartDesign to put them into a Body."
|
||||
));
|
||||
if (!activeBody && messageIfNot) {
|
||||
QMessageBox::warning(Gui::getMainWindow(), QObject::tr("No active Body"),
|
||||
QObject::tr("In order to use PartDesign you need an active Body object in the document. "
|
||||
"Please make one active (double click) or create one. If you have a legacy document "
|
||||
"with PartDesign objects without Body, use the transfer function in "
|
||||
"PartDesign to put them into a Body."
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
return activeBody;
|
||||
|
||||
return activeBody;
|
||||
}
|
||||
|
||||
PartDesign::Body *getBodyFor(const App::DocumentObject* obj, bool messageIfNot)
|
||||
|
|
|
@ -65,11 +65,9 @@ ViewProviderPrimitive::~ViewProviderPrimitive()
|
|||
}
|
||||
|
||||
void ViewProviderPrimitive::attach(App::DocumentObject* obj) {
|
||||
|
||||
ViewProviderAddSub::attach(obj);
|
||||
}
|
||||
|
||||
|
||||
bool ViewProviderPrimitive::setEdit(int ModNum)
|
||||
{
|
||||
if (ModNum == ViewProvider::Default ) {
|
||||
|
@ -80,8 +78,6 @@ bool ViewProviderPrimitive::setEdit(int ModNum)
|
|||
// the task panel
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
TaskPrimitiveParameters *primitiveDlg = qobject_cast<TaskPrimitiveParameters *>(dlg);
|
||||
if (primitiveDlg)
|
||||
primitiveDlg = 0; // another pad left open its task panel
|
||||
if (dlg && !primitiveDlg) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
|
||||
|
@ -102,6 +98,7 @@ bool ViewProviderPrimitive::setEdit(int ModNum)
|
|||
oldWb = Gui::Command::assureWorkbench("PartDesignWorkbench");
|
||||
|
||||
// start the edit dialog
|
||||
// another pad left open its task panel
|
||||
if (primitiveDlg)
|
||||
Gui::Control().showDialog(primitiveDlg);
|
||||
else
|
||||
|
@ -119,14 +116,10 @@ void ViewProviderPrimitive::unsetEdit(int ModNum) {
|
|||
}
|
||||
|
||||
void ViewProviderPrimitive::updateData(const App::Property* p) {
|
||||
|
||||
PartDesignGui::ViewProviderAddSub::updateData(p);
|
||||
}
|
||||
|
||||
|
||||
|
||||
std::vector< App::DocumentObject* > ViewProviderPrimitive::claimChildren(void) const {
|
||||
|
||||
std::vector< App::DocumentObject* > vec;
|
||||
vec.push_back(static_cast<PartDesign::FeaturePrimitive*>(getObject())->CoordinateSystem.getValue());
|
||||
|
||||
|
@ -134,42 +127,41 @@ std::vector< App::DocumentObject* > ViewProviderPrimitive::claimChildren(void) c
|
|||
}
|
||||
|
||||
QIcon ViewProviderPrimitive::getIcon(void) const {
|
||||
|
||||
|
||||
QString str = QString::fromLatin1("PartDesign_");
|
||||
auto* prim = static_cast<PartDesign::FeaturePrimitive*>(getObject());
|
||||
if(prim->getAddSubType() == PartDesign::FeatureAddSub::Additive)
|
||||
str += QString::fromLatin1("Additive_");
|
||||
else
|
||||
str += QString::fromLatin1("Subtractive_");
|
||||
|
||||
|
||||
switch(prim->getPrimitiveType()) {
|
||||
|
||||
case PartDesign::FeaturePrimitive::Box:
|
||||
str += QString::fromLatin1("Box");
|
||||
break;
|
||||
case PartDesign::FeaturePrimitive::Cylinder:
|
||||
str += QString::fromLatin1("Cylinder");
|
||||
break;
|
||||
case PartDesign::FeaturePrimitive::Sphere:
|
||||
str += QString::fromLatin1("Sphere");
|
||||
break;
|
||||
case PartDesign::FeaturePrimitive::Cone:
|
||||
str += QString::fromLatin1("Cone");
|
||||
break;
|
||||
case PartDesign::FeaturePrimitive::Ellipsoid:
|
||||
str += QString::fromLatin1("Ellipsoid");
|
||||
break;
|
||||
case PartDesign::FeaturePrimitive::Torus:
|
||||
str += QString::fromLatin1("Torus");
|
||||
break;
|
||||
case PartDesign::FeaturePrimitive::Prism:
|
||||
str += QString::fromLatin1("Prism");
|
||||
break;
|
||||
case PartDesign::FeaturePrimitive::Wedge:
|
||||
str += QString::fromLatin1("Wedge");
|
||||
break;
|
||||
case PartDesign::FeaturePrimitive::Box:
|
||||
str += QString::fromLatin1("Box");
|
||||
break;
|
||||
case PartDesign::FeaturePrimitive::Cylinder:
|
||||
str += QString::fromLatin1("Cylinder");
|
||||
break;
|
||||
case PartDesign::FeaturePrimitive::Sphere:
|
||||
str += QString::fromLatin1("Sphere");
|
||||
break;
|
||||
case PartDesign::FeaturePrimitive::Cone:
|
||||
str += QString::fromLatin1("Cone");
|
||||
break;
|
||||
case PartDesign::FeaturePrimitive::Ellipsoid:
|
||||
str += QString::fromLatin1("Ellipsoid");
|
||||
break;
|
||||
case PartDesign::FeaturePrimitive::Torus:
|
||||
str += QString::fromLatin1("Torus");
|
||||
break;
|
||||
case PartDesign::FeaturePrimitive::Prism:
|
||||
str += QString::fromLatin1("Prism");
|
||||
break;
|
||||
case PartDesign::FeaturePrimitive::Wedge:
|
||||
str += QString::fromLatin1("Wedge");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
str += QString::fromLatin1(".svg");
|
||||
return Gui::BitmapFactory().pixmap(str.toStdString().c_str());
|
||||
}
|
||||
|
|
|
@ -81,15 +81,12 @@ ViewProviderShapeBinder::~ViewProviderShapeBinder()
|
|||
bool ViewProviderShapeBinder::setEdit(int ModNum) {
|
||||
// TODO Share code with other view providers (2015-09-11, Fat-Zer)
|
||||
|
||||
if (ModNum == ViewProvider::Default || ModNum == 1 ) {
|
||||
|
||||
if (ModNum == ViewProvider::Default || ModNum == 1) {
|
||||
// When double-clicking on the item for this pad the
|
||||
// object unsets and sets its edit mode without closing
|
||||
// the task panel
|
||||
Gui::TaskView::TaskDialog *dlg = Gui::Control().activeDialog();
|
||||
TaskDlgShapeBinder *sbDlg = qobject_cast<TaskDlgShapeBinder*>(dlg);
|
||||
if (sbDlg)
|
||||
sbDlg = 0; // another pad left open its task panel
|
||||
if (dlg && !sbDlg) {
|
||||
QMessageBox msgBox;
|
||||
msgBox.setText(QObject::tr("A dialog is already open in the task panel"));
|
||||
|
@ -107,6 +104,7 @@ bool ViewProviderShapeBinder::setEdit(int ModNum) {
|
|||
Gui::Selection().clearSelection();
|
||||
|
||||
// start the edit dialog
|
||||
// another pad left open its task panel
|
||||
if (sbDlg)
|
||||
Gui::Control().showDialog(sbDlg);
|
||||
else
|
||||
|
|
|
@ -37,7 +37,7 @@ class PartDesignGuiExport ViewProviderTransformed : public ViewProvider
|
|||
public:
|
||||
/// constructor
|
||||
ViewProviderTransformed()
|
||||
: featureName("undefined") {}
|
||||
: featureName("undefined"), pcRejectedRoot(nullptr) {}
|
||||
/// destructor
|
||||
virtual ~ViewProviderTransformed()
|
||||
{}
|
||||
|
|
Loading…
Reference in New Issue
Block a user