diff --git a/src/App/PropertyFile.cpp b/src/App/PropertyFile.cpp index 1a38e36dab..4e27331f51 100644 --- a/src/App/PropertyFile.cpp +++ b/src/App/PropertyFile.cpp @@ -516,7 +516,7 @@ void PropertyFileIncluded::RestoreDocFile(Base::Reader &reader) Property *PropertyFileIncluded::Copy(void) const { - PropertyFileIncluded *prop = new PropertyFileIncluded(); + std::unique_ptr prop(new PropertyFileIncluded()); // remember the base name prop->_BaseFileName = _BaseFileName; @@ -556,7 +556,7 @@ Property *PropertyFileIncluded::Copy(void) const newName.setPermissions(Base::FileInfo::ReadWrite); } - return prop; + return prop.release(); } void PropertyFileIncluded::Paste(const Property &from) diff --git a/src/Gui/DlgPreferencesImp.cpp b/src/Gui/DlgPreferencesImp.cpp index a1b74d3438..f7868d5a49 100644 --- a/src/Gui/DlgPreferencesImp.cpp +++ b/src/Gui/DlgPreferencesImp.cpp @@ -79,7 +79,8 @@ DlgPreferencesImp::DlgPreferencesImp(QWidget* parent, Qt::WindowFlags fl) */ DlgPreferencesImp::~DlgPreferencesImp() { - // no need to delete child widgets, Qt does it all for us + // no need to delete child widgets, Qt does it all for us + delete ui; } void DlgPreferencesImp::setupPages() diff --git a/src/Gui/DlgProjectUtility.cpp b/src/Gui/DlgProjectUtility.cpp index b5ffc4919e..66887dccfd 100644 --- a/src/Gui/DlgProjectUtility.cpp +++ b/src/Gui/DlgProjectUtility.cpp @@ -122,6 +122,7 @@ DlgProjectUtility::DlgProjectUtility(QWidget* parent, Qt::WindowFlags fl) DlgProjectUtility::~DlgProjectUtility() { // no need to delete child widgets, Qt does it all for us + delete ui; } void DlgProjectUtility::on_extractButton_clicked() diff --git a/src/Gui/View3DInventorExamples.cpp b/src/Gui/View3DInventorExamples.cpp index 53cfacebab..af70857964 100644 --- a/src/Gui/View3DInventorExamples.cpp +++ b/src/Gui/View3DInventorExamples.cpp @@ -407,6 +407,8 @@ timersensorcallback(void * data, SoSensor *) void AnimationTexture(SoSeparator * root) { + // Scene graph + if ( root == NULL ) return; // Shouldn't happen. // Generate a julia set to use as a texturemap julia(cr, ci, 2.5, texturewidth, textureheight, 4, bitmap, 64); @@ -425,8 +427,6 @@ void AnimationTexture(SoSeparator * root) texturetimer->setInterval(0.05); texturetimer->schedule(); - // Scene graph - if ( root == NULL ) return; // Shouldn't happen. root->ref(); // prevent from being deleted because of the still running timer sensor // SoSeparator * root = new SoSeparator; // root->ref(); diff --git a/src/Gui/ViewProviderBuilder.cpp b/src/Gui/ViewProviderBuilder.cpp index 66dde49e31..99385a814a 100644 --- a/src/Gui/ViewProviderBuilder.cpp +++ b/src/Gui/ViewProviderBuilder.cpp @@ -101,21 +101,20 @@ ViewProviderColorBuilder::~ViewProviderColorBuilder() { } -void ViewProviderColorBuilder::buildNodes(const App::Property* prop, std::vector&) const +void ViewProviderColorBuilder::buildNodes(const App::Property* prop, std::vector& node) const { const App::PropertyColorList* color = static_cast(prop); const std::vector& val = color->getValues(); unsigned long i=0; SoMaterial* material = new SoMaterial(); - material->enableNotify(false); - material->diffuseColor.deleteValues(0); material->diffuseColor.setNum(val.size()); + SbColor* colors = material->diffuseColor.startEditing(); for (std::vector::const_iterator it = val.begin(); it != val.end(); ++it) { - material->diffuseColor.set1Value(i++, SbColor(it->r, it->g, it->b)); + colors[i].setValue(it->r, it->g, it->b); + i++; } - - material->enableNotify(true); - material->touch(); + material->diffuseColor.finishEditing(); + node.push_back(material); } diff --git a/src/Main/FreeCADGuiPy.cpp b/src/Main/FreeCADGuiPy.cpp index fb6b769797..547c190f4a 100644 --- a/src/Main/FreeCADGuiPy.cpp +++ b/src/Main/FreeCADGuiPy.cpp @@ -260,6 +260,7 @@ QWidget* setupMainWindow() Base::PyGILStateLocker lock; PyObject* input = PySys_GetObject("stdin"); Gui::MainWindow *mw = new Gui::MainWindow(); + mw->setAttribute(Qt::WA_DeleteOnClose); hasMainWindow = true; QIcon icon = qApp->windowIcon(); diff --git a/src/Mod/Image/Gui/ImageOrientationDialog.cpp b/src/Mod/Image/Gui/ImageOrientationDialog.cpp index b09d4df113..f51a2e2f03 100644 --- a/src/Mod/Image/Gui/ImageOrientationDialog.cpp +++ b/src/Mod/Image/Gui/ImageOrientationDialog.cpp @@ -52,7 +52,7 @@ ImageOrientationDialog::ImageOrientationDialog() ImageOrientationDialog::~ImageOrientationDialog() { - + delete ui; } void ImageOrientationDialog::accept() diff --git a/src/Mod/Import/App/dxf.cpp b/src/Mod/Import/App/dxf.cpp index 597a4390b6..2468e6ec29 100644 --- a/src/Mod/Import/App/dxf.cpp +++ b/src/Mod/Import/App/dxf.cpp @@ -57,6 +57,10 @@ m_layerName("none") CDxfWrite::~CDxfWrite() { delete m_ofs; + delete m_ssBlock; + delete m_ssBlkRecord; + delete m_ssEntity; + delete m_ssLayer; } void CDxfWrite::init(void) diff --git a/src/Mod/Mesh/Gui/DlgSettingsImportExportImp.cpp b/src/Mod/Mesh/Gui/DlgSettingsImportExportImp.cpp index d8f43df43b..2168b6de94 100644 --- a/src/Mod/Mesh/Gui/DlgSettingsImportExportImp.cpp +++ b/src/Mod/Mesh/Gui/DlgSettingsImportExportImp.cpp @@ -40,6 +40,7 @@ DlgSettingsImportExport::DlgSettingsImportExport(QWidget* parent) DlgSettingsImportExport::~DlgSettingsImportExport() { // no need to delete child widgets, Qt does it all for us + delete ui; } void DlgSettingsImportExport::saveSettings() diff --git a/src/Mod/Part/Gui/TaskDimension.cpp b/src/Mod/Part/Gui/TaskDimension.cpp index 8c244733cb..ecb71f1af7 100644 --- a/src/Mod/Part/Gui/TaskDimension.cpp +++ b/src/Mod/Part/Gui/TaskDimension.cpp @@ -994,6 +994,7 @@ void PartGui::goDimensionAngularNoTask(const VectorAdapter &vector1Adapter, cons } DimensionAngular *dimension = new DimensionAngular(); + dimension->ref(); dimension->matrix.setValue(dimSys); dimension->radius.setValue(radius); dimension->angle.setValue(static_cast(displayAngle)); @@ -1001,10 +1002,9 @@ void PartGui::goDimensionAngularNoTask(const VectorAdapter &vector1Adapter, cons dimension->dColor.setValue(SbColor(0.0, 0.0, 1.0)); Gui::View3DInventorViewer *viewer = getViewer(); - if (!viewer) - return; - - viewer->addDimension3d(dimension); + if (viewer) + viewer->addDimension3d(dimension); + dimension->unref(); } SO_KIT_SOURCE(PartGui::DimensionAngular); @@ -1058,6 +1058,7 @@ void PartGui::DimensionAngular::setupDimension() //color SoMaterial *material = new SoMaterial; + material->ref(); material->diffuseColor.connectFrom(&dColor); //dimension arrows. @@ -1110,22 +1111,21 @@ void PartGui::DimensionAngular::setupDimension() coordinates->point.connectFrom(&arcEngine->points); SoLineSet *lineSet = new SoLineSet(); + lineSet->ref(); lineSet->vertexProperty.setValue(coordinates); lineSet->numVertices.connectFrom(&arcEngine->pointCount); lineSet->startIndex.setValue(0); SoSeparator *arcSep = static_cast(getPart("arcSep", true)); - if (!arcSep) - return; - arcSep->addChild(material); - arcSep->addChild(lineSet); + if (arcSep) { + arcSep->addChild(material); + arcSep->addChild(lineSet); + } //text SoSeparator *textSep = static_cast(getPart("textSep", true)); - if (!textSep) - return; - - textSep->addChild(material); + if (textSep) + textSep->addChild(material); SoCalculator *textVecCalc = new SoCalculator(); textVecCalc->a.connectFrom(&angle); @@ -1158,6 +1158,9 @@ void PartGui::DimensionAngular::setupDimension() SoResetTransform *rTrans = new SoResetTransform; rTrans->whatToReset = SoResetTransform::BBOX; textSep->addChild(rTrans); + + lineSet->unref(); + material->unref(); } SO_ENGINE_SOURCE(PartGui::ArcEngine); diff --git a/src/Mod/Part/Gui/ViewProviderReference.cpp b/src/Mod/Part/Gui/ViewProviderReference.cpp index 59a74758d5..f6d1e359c1 100644 --- a/src/Mod/Part/Gui/ViewProviderReference.cpp +++ b/src/Mod/Part/Gui/ViewProviderReference.cpp @@ -241,9 +241,9 @@ void ViewProviderPartReference::attach(App::DocumentObject *pcFeat) ViewProviderGeometryObject::attach(pcFeat); SoGroup* pcNormalRoot = new SoGroup(); - SoGroup* pcFlatRoot = new SoGroup(); - SoGroup* pcWireframeRoot = new SoGroup(); - SoGroup* pcPointsRoot = new SoGroup(); + //SoGroup* pcFlatRoot = new SoGroup(); + //SoGroup* pcWireframeRoot = new SoGroup(); + //SoGroup* pcPointsRoot = new SoGroup(); // enable two-side rendering pShapeHints->vertexOrdering = SoShapeHints::COUNTERCLOCKWISE; @@ -256,15 +256,15 @@ void ViewProviderPartReference::attach(App::DocumentObject *pcFeat) pcNormalRoot->addChild(VertexRoot); // just faces with no edges or points - pcFlatRoot->addChild(pShapeHints); - pcFlatRoot->addChild(FaceRoot); + //pcFlatRoot->addChild(pShapeHints); + //pcFlatRoot->addChild(FaceRoot); // only edges - pcWireframeRoot->addChild(EdgeRoot); - pcWireframeRoot->addChild(VertexRoot); + //pcWireframeRoot->addChild(EdgeRoot); + //pcWireframeRoot->addChild(VertexRoot); // normal viewing with edges and points - pcPointsRoot->addChild(VertexRoot); + //pcPointsRoot->addChild(VertexRoot); // putting all together with the switch addDisplayMaskMode(pcNormalRoot, "Reference"); diff --git a/src/Mod/Path/Gui/DlgProcessorChooser.cpp b/src/Mod/Path/Gui/DlgProcessorChooser.cpp index 62a473a887..94465348c7 100644 --- a/src/Mod/Path/Gui/DlgProcessorChooser.cpp +++ b/src/Mod/Path/Gui/DlgProcessorChooser.cpp @@ -58,6 +58,7 @@ DlgProcessorChooser::DlgProcessorChooser(std::vector &scriptnames, DlgProcessorChooser::~DlgProcessorChooser() { + delete ui; } std::string DlgProcessorChooser::getProcessor() diff --git a/src/Mod/ReverseEngineering/App/ApproxSurface.cpp b/src/Mod/ReverseEngineering/App/ApproxSurface.cpp index e7ea0c8d90..62379037ad 100644 --- a/src/Mod/ReverseEngineering/App/ApproxSurface.cpp +++ b/src/Mod/ReverseEngineering/App/ApproxSurface.cpp @@ -865,7 +865,7 @@ void BSplineParameterCorrection::DoParameterCorrection(int iIter) fMaxScalar = 1.0; fMaxDiff = 0.0; - Geom_BSplineSurface* pclBSplineSurf = new Geom_BSplineSurface(_vCtrlPntsOfSurf, + Handle(Geom_BSplineSurface) pclBSplineSurf = new Geom_BSplineSurface(_vCtrlPntsOfSurf, _vUKnots, _vVKnots, _vUMults, _vVMults, _usUOrder-1, _usVOrder-1); for (int ii=_pvcPoints->Lower();ii <=_pvcPoints->Upper();ii++) { diff --git a/src/Mod/Robot/Gui/CommandTrajectory.cpp b/src/Mod/Robot/Gui/CommandTrajectory.cpp index 76adc1ccb7..eef291a0c8 100644 --- a/src/Mod/Robot/Gui/CommandTrajectory.cpp +++ b/src/Mod/Robot/Gui/CommandTrajectory.cpp @@ -226,17 +226,16 @@ CmdRobotSetDefaultOrientation::CmdRobotSetDefaultOrientation() void CmdRobotSetDefaultOrientation::activated(int) { // create placement dialog - Gui::Dialog::Placement *Dlg = new Gui::Dialog::Placement(); + Gui::Dialog::Placement Dlg; Base::Placement place; - Dlg->setPlacement(place); - if(Dlg->exec() == QDialog::Accepted ){ - place = Dlg->getPlacement(); + Dlg.setPlacement(place); + if (Dlg.exec() == QDialog::Accepted ){ + place = Dlg.getPlacement(); Base::Rotation rot = place.getRotation(); Base::Vector3d disp = place.getPosition(); doCommand(Doc,"_DefOrientation = FreeCAD.Rotation(%f,%f,%f,%f)",rot[0],rot[1],rot[2],rot[3]); doCommand(Doc,"_DefDisplacement = FreeCAD.Vector(%f,%f,%f)",disp[0],disp[1],disp[2]); } - } bool CmdRobotSetDefaultOrientation::isActive(void) diff --git a/src/Mod/Robot/Gui/TaskRobot6Axis.cpp b/src/Mod/Robot/Gui/TaskRobot6Axis.cpp index 080653bbe3..8e3326cc62 100644 --- a/src/Mod/Robot/Gui/TaskRobot6Axis.cpp +++ b/src/Mod/Robot/Gui/TaskRobot6Axis.cpp @@ -117,10 +117,10 @@ void TaskRobot6Axis::setRobot(Robot::RobotObject *pcRobotObject) void TaskRobot6Axis::createPlacementDlg(void) { - Gui::Dialog::Placement *plc = new Gui::Dialog::Placement(); - plc->setPlacement(pcRobot->Tool.getValue()); - if(plc->exec()==QDialog::Accepted) - pcRobot->Tool.setValue(plc->getPlacement()); + Gui::Dialog::Placement plc; + plc.setPlacement(pcRobot->Tool.getValue()); + if (plc.exec()==QDialog::Accepted) + pcRobot->Tool.setValue(plc.getPlacement()); viewTool(pcRobot->Tool.getValue()); } diff --git a/src/Mod/Robot/Gui/TaskTrajectoryDressUpParameter.cpp b/src/Mod/Robot/Gui/TaskTrajectoryDressUpParameter.cpp index c519ee4957..e515562a12 100644 --- a/src/Mod/Robot/Gui/TaskTrajectoryDressUpParameter.cpp +++ b/src/Mod/Robot/Gui/TaskTrajectoryDressUpParameter.cpp @@ -93,10 +93,10 @@ void TaskTrajectoryDressUpParameter::writeValues(void) void TaskTrajectoryDressUpParameter::createPlacementDlg(void) { - Gui::Dialog::Placement *plc = new Gui::Dialog::Placement(); - plc->setPlacement(PosAdd); - if(plc->exec()==QDialog::Accepted){ - PosAdd = plc->getPlacement(); + Gui::Dialog::Placement plc; + plc.setPlacement(PosAdd); + if (plc.exec() == QDialog::Accepted) { + PosAdd = plc.getPlacement(); viewPlacement(); } diff --git a/src/Mod/Robot/Gui/ViewProviderRobotObject.cpp b/src/Mod/Robot/Gui/ViewProviderRobotObject.cpp index ffc97ecf35..78d7ac5d11 100644 --- a/src/Mod/Robot/Gui/ViewProviderRobotObject.cpp +++ b/src/Mod/Robot/Gui/ViewProviderRobotObject.cpp @@ -60,13 +60,13 @@ ViewProviderRobotObject::ViewProviderRobotObject() { ADD_PROPERTY(Manipulator,(0)); - pcRobotRoot = new Gui::SoFCSelection(); + pcRobotRoot = new Gui::SoFCSelection(); pcRobotRoot->highlightMode = Gui::SoFCSelection::OFF; //pcRobotRoot->selectionMode = Gui::SoFCSelection::SEL_OFF; //pcRobotRoot->style = Gui::SoFCSelection::BOX; pcRobotRoot->ref(); - pcSimpleRoot = new Gui::SoFCSelection(); + pcSimpleRoot = new Gui::SoFCSelection(); pcSimpleRoot->highlightMode = Gui::SoFCSelection::OFF; //pcSimpleRoot->selectionMode = Gui::SoFCSelection::SEL_OFF; pcSimpleRoot->ref(); @@ -82,6 +82,14 @@ ViewProviderRobotObject::ViewProviderRobotObject() Axis1Node = Axis2Node = Axis3Node = Axis4Node = Axis5Node = Axis6Node = 0; } +ViewProviderRobotObject::~ViewProviderRobotObject() +{ + pcRobotRoot->unref(); + pcSimpleRoot->unref(); + pcOffRoot->unref(); + pcTcpRoot->unref(); +} + void ViewProviderRobotObject::setDragger() { assert(pcDragger==0); @@ -98,23 +106,13 @@ void ViewProviderRobotObject::setDragger() SbVec3f(150,150,150) ); pcDragger->setMotionMatrix(M); - - } + void ViewProviderRobotObject::resetDragger() { assert(pcDragger); pcTcpRoot->removeAllChildren(); pcDragger = 0; - - } - -ViewProviderRobotObject::~ViewProviderRobotObject() -{ - pcRobotRoot->unref(); - pcSimpleRoot->unref(); - pcOffRoot->unref(); - } void ViewProviderRobotObject::attach(App::DocumentObject *pcObj) @@ -135,8 +133,6 @@ void ViewProviderRobotObject::attach(App::DocumentObject *pcObj) addDisplayMaskMode(pcOffRoot, "Off"); pcOffRoot->addChild(pcTcpRoot); - - } void ViewProviderRobotObject::setDisplayMode(const char* ModeName) diff --git a/src/Mod/Sketcher/App/SketchObject.cpp b/src/Mod/Sketcher/App/SketchObject.cpp index 6482ba9ae3..3d7aa28677 100644 --- a/src/Mod/Sketcher/App/SketchObject.cpp +++ b/src/Mod/Sketcher/App/SketchObject.cpp @@ -4865,8 +4865,7 @@ bool SketchObject::increaseBSplineDegree(int GeoId, int degreeincrement /*= 1*/) const Handle(Geom_BSplineCurve) curve = Handle(Geom_BSplineCurve)::DownCast(bsp->handle()); - Part::GeomBSplineCurve *bspline = new Part::GeomBSplineCurve(curve); - + std::unique_ptr bspline(new Part::GeomBSplineCurve(curve)); try { int cdegree = bspline->getDegree(); @@ -4882,7 +4881,7 @@ bool SketchObject::increaseBSplineDegree(int GeoId, int degreeincrement /*= 1*/) std::vector< Part::Geometry * > newVals(vals); - newVals[GeoId] = bspline; + newVals[GeoId] = bspline.release(); Geometry.setValues(newVals); Constraints.acceptGeometry(getCompleteGeometry()); diff --git a/src/Mod/Sketcher/Gui/SketchMirrorDialog.cpp b/src/Mod/Sketcher/Gui/SketchMirrorDialog.cpp index 86013e0966..041d263472 100644 --- a/src/Mod/Sketcher/Gui/SketchMirrorDialog.cpp +++ b/src/Mod/Sketcher/Gui/SketchMirrorDialog.cpp @@ -49,7 +49,7 @@ SketchMirrorDialog::SketchMirrorDialog(void) SketchMirrorDialog::~SketchMirrorDialog() { - + delete ui; } void SketchMirrorDialog::accept() diff --git a/src/Mod/Sketcher/Gui/SketchOrientationDialog.cpp b/src/Mod/Sketcher/Gui/SketchOrientationDialog.cpp index df0a025830..3b4f86e731 100644 --- a/src/Mod/Sketcher/Gui/SketchOrientationDialog.cpp +++ b/src/Mod/Sketcher/Gui/SketchOrientationDialog.cpp @@ -52,7 +52,7 @@ SketchOrientationDialog::SketchOrientationDialog(void) SketchOrientationDialog::~SketchOrientationDialog() { - + delete ui; } void SketchOrientationDialog::accept() diff --git a/src/Mod/Sketcher/Gui/SketchRectangularArrayDialog.cpp b/src/Mod/Sketcher/Gui/SketchRectangularArrayDialog.cpp index d00cfa9021..cc37c5f59c 100644 --- a/src/Mod/Sketcher/Gui/SketchRectangularArrayDialog.cpp +++ b/src/Mod/Sketcher/Gui/SketchRectangularArrayDialog.cpp @@ -53,7 +53,7 @@ SketchRectangularArrayDialog::SketchRectangularArrayDialog(void) SketchRectangularArrayDialog::~SketchRectangularArrayDialog() { - + delete ui; } void SketchRectangularArrayDialog::accept() diff --git a/src/Mod/Sketcher/Gui/SketcherRegularPolygonDialog.cpp b/src/Mod/Sketcher/Gui/SketcherRegularPolygonDialog.cpp index c1b8d92a7f..bf7dc3ef88 100644 --- a/src/Mod/Sketcher/Gui/SketcherRegularPolygonDialog.cpp +++ b/src/Mod/Sketcher/Gui/SketcherRegularPolygonDialog.cpp @@ -49,7 +49,7 @@ SketcherRegularPolygonDialog::SketcherRegularPolygonDialog(void) SketcherRegularPolygonDialog::~SketcherRegularPolygonDialog() { - + delete ui; } void SketcherRegularPolygonDialog::accept()