Gui: add coinRemoveAllChildren to work around Coin3D bug

See bug description:
https://bitbucket.org/Coin3D/coin/pull-requests/119/fix-sochildlist-auditing/diff

Because of path based rendering (SoFCPathAnnotation) in mouse over
highlight, this bug causes crash more frequently here comparing to
upstream.

All C++ calling of SoGroup::removeAllChildren() is replaced by
Gui::coinRemoveAllChildren(), and python code is fixed by monkey
patching SoGroup.removeAllChildren() in FreeCADGuiInit.py.
This commit is contained in:
Zheng, Lei
2019-05-31 06:28:00 +08:00
committed by wmayer
parent c744157e9a
commit c8891be856
36 changed files with 115 additions and 55 deletions

View File

@@ -118,7 +118,7 @@ void ViewProviderFemConstraintBearing::updateData(const App::Property* prop)
if (strcmp(prop->getName(),"BasePoint") == 0) {
// Remove and recreate the symbol
pShapeSep->removeAllChildren();
Gui::coinRemoveAllChildren(pShapeSep);
// This should always point outside of the cylinder
Base::Vector3d normal = pcConstraint->NormalDirection.getValue();

View File

@@ -121,7 +121,7 @@ void ViewProviderFemConstraintContact::updateData(const App::Property* prop)
std::vector<Base::Vector3d>::const_iterator n = normals.begin();
// Points and Normals are always updated together
pShapeSep->removeAllChildren();
Gui::coinRemoveAllChildren(pShapeSep);
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
//Define base and normal directions

View File

@@ -186,7 +186,7 @@ void ViewProviderFemConstraintDisplacement::updateData(const App::Property* prop
int idrotz = 0;
#else
// Note: Points and Normals are always updated together
pShapeSep->removeAllChildren();
Gui::coinRemoveAllChildren(pShapeSep);
#endif
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {

View File

@@ -143,7 +143,7 @@ void ViewProviderFemConstraintFixed::updateData(const App::Property* prop)
int idx = 0;
#else
// Note: Points and Normals are always updated together
pShapeSep->removeAllChildren();
Gui::coinRemoveAllChildren(pShapeSep);
#endif
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {

View File

@@ -170,7 +170,7 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro
int idx = 0;
#else
// Redraw all arrows
pShapeSep->removeAllChildren();
Gui::coinRemoveAllChildren(pShapeSep);
#endif
// This should always point outside of the solid
Base::Vector3d normal = pcConstraint->NormalDirection.getValue();
@@ -272,7 +272,7 @@ void ViewProviderFemConstraintFluidBoundary::updateData(const App::Property* pro
int idx = 0;
#else
// Note: Points and Normals are always updated together
pShapeSep->removeAllChildren();
Gui::coinRemoveAllChildren(pShapeSep);
#endif
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {

View File

@@ -139,7 +139,7 @@ void ViewProviderFemConstraintForce::updateData(const App::Property* prop)
int idx = 0;
#else
// Redraw all arrows
pShapeSep->removeAllChildren();
Gui::coinRemoveAllChildren(pShapeSep);
#endif
// This should always point outside of the solid
Base::Vector3d normal = pcConstraint->NormalDirection.getValue();

View File

@@ -115,7 +115,7 @@ void ViewProviderFemConstraintGear::updateData(const App::Property* prop)
if (strcmp(prop->getName(),"BasePoint") == 0) {
if (pcConstraint->Height.getValue() > Precision::Confusion()) {
// Remove and recreate the symbol
pShapeSep->removeAllChildren();
Gui::coinRemoveAllChildren(pShapeSep);
Base::Vector3d base = pcConstraint->BasePoint.getValue();
Base::Vector3d axis = pcConstraint->Axis.getValue();

View File

@@ -120,7 +120,7 @@ void ViewProviderFemConstraintHeatflux::updateData(const App::Property* prop)
std::vector<Base::Vector3d>::const_iterator n = normals.begin();
// Note: Points and Normals are always updated together
pShapeSep->removeAllChildren();
Gui::coinRemoveAllChildren(pShapeSep);
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
//Define base and normal directions

View File

@@ -119,7 +119,7 @@ void ViewProviderFemConstraintPlaneRotation::updateData(const App::Property* pro
std::vector<Base::Vector3d>::const_iterator n = normals.begin();
// Points and Normals are always updated together
pShapeSep->removeAllChildren();
Gui::coinRemoveAllChildren(pShapeSep);
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
//Define base and normal directions

View File

@@ -127,7 +127,7 @@ void ViewProviderFemConstraintPressure::updateData(const App::Property* prop)
int idx = 0;
#else
// Redraw all arrows
pShapeSep->removeAllChildren();
Gui::coinRemoveAllChildren(pShapeSep);
#endif
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {

View File

@@ -114,7 +114,7 @@ void ViewProviderFemConstraintPulley::updateData(const App::Property* prop)
if (strcmp(prop->getName(),"BasePoint") == 0) {
if (pcConstraint->Height.getValue() > Precision::Confusion()) {
// Remove and recreate the symbol
pShapeSep->removeAllChildren();
Gui::coinRemoveAllChildren(pShapeSep);
// This should always point outside of the cylinder
Base::Vector3d base = pcConstraint->BasePoint.getValue();

View File

@@ -119,7 +119,7 @@ void ViewProviderFemConstraintTemperature::updateData(const App::Property* prop)
std::vector<Base::Vector3d>::const_iterator n = normals.begin();
// Note: Points and Normals are always updated together
pShapeSep->removeAllChildren();
Gui::coinRemoveAllChildren(pShapeSep);
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
//Define base and normal directions

View File

@@ -135,7 +135,7 @@ void ViewProviderFemConstraintTransform::updateData(const App::Property* prop)
std::vector<Base::Vector3d>::const_iterator n = normals.begin();
// Points and Normals are always updated together
pShapeSep->removeAllChildren();
Gui::coinRemoveAllChildren(pShapeSep);
for (std::vector<Base::Vector3d>::const_iterator p = points.begin(); p != points.end(); p++) {
SbVec3f base(p->x, p->y, p->z);
@@ -269,7 +269,7 @@ void ViewProviderFemConstraintTransform::updateData(const App::Property* prop)
} else if (transform_type == "Cylindrical") {
// Points and Normals are always updated together
pShapeSep->removeAllChildren();
Gui::coinRemoveAllChildren(pShapeSep);
const std::vector<Base::Vector3d>& points = pcConstraint->Points.getValues();
const std::vector<Base::Vector3d>& normals = pcConstraint->Normals.getValues();

View File

@@ -232,7 +232,7 @@ void ViewProviderInspection::updateData(const App::Property* prop)
}
}
this->pcLinkRoot->removeAllChildren();
Gui::coinRemoveAllChildren(this->pcLinkRoot);
this->pcLinkRoot->addChild(this->pcCoords);
this->pcCoords->point.setNum(points.size());
SbVec3f* pts = this->pcCoords->point.startEditing();

View File

@@ -478,11 +478,11 @@ void MeshFillHole::startEditing(MeshGui::ViewProviderMesh* vp)
myConnection = App::GetApplication().signalChangedObject.connect(
boost::bind(&MeshFillHole::slotChangedObject, this, _1, _2));
myBoundariesRoot->removeAllChildren();
Gui::coinRemoveAllChildren(myBoundariesRoot);
myBoundariesRoot->addChild(viewer->getHeadlight());
myBoundariesRoot->addChild(viewer->getSoRenderManager()->getCamera());
myBoundariesRoot->addChild(myBoundariesGroup);
myBoundaryRoot->removeAllChildren();
Gui::coinRemoveAllChildren(myBoundaryRoot);
myBoundaryRoot->addChild(viewer->getHeadlight());
myBoundaryRoot->addChild(viewer->getSoRenderManager()->getCamera());
createPolygons();
@@ -541,7 +541,7 @@ void MeshFillHole::closeBridge()
void MeshFillHole::slotChangedObject(const App::DocumentObject& Obj, const App::Property& Prop)
{
if (&Obj == myMesh && strcmp(Prop.getName(),"Mesh") == 0) {
myBoundariesGroup->removeAllChildren();
Gui::coinRemoveAllChildren(myBoundariesGroup);
myVertex->point.setNum(0);
myNumPoints = 0;
myPolygon.clear();

View File

@@ -290,7 +290,7 @@ void ViewProviderMeshCurvature::updateData(const App::Property* prop)
// set to the expected size
if (prop->getTypeId().isDerivedFrom(App::PropertyLink::getClassTypeId())) {
Mesh::Feature* object = static_cast<const App::PropertyLink*>(prop)->getValue<Mesh::Feature*>();
this->pcLinkRoot->removeAllChildren();
Gui::coinRemoveAllChildren(this->pcLinkRoot);
if (object) {
const Mesh::MeshObject& kernel = object->Mesh.getValue();
pcColorMat->diffuseColor.setNum((int)kernel.countPoints());

View File

@@ -154,7 +154,7 @@ void ViewProviderMeshFaceSet::updateData(const App::Property* prop)
if (direct != directRendering) {
directRendering = direct;
pcShapeGroup->removeAllChildren();
Gui::coinRemoveAllChildren(pcShapeGroup);
if (directRendering) {
pcShapeGroup->addChild(pcMeshNode);

View File

@@ -128,7 +128,7 @@ SoSeparator* ViewProvider2DObject::createGrid(void)
double zGrid = 0.0; // carpet-grid separation
SoGroup *parent = new Gui::SoSkipBoundingGroup();
GridRoot->removeAllChildren();
Gui::coinRemoveAllChildren(GridRoot);
GridRoot->addChild(parent);
SoBaseColor *mycolor;
SoVertexProperty *vts;
@@ -228,7 +228,7 @@ void ViewProvider2DObject::updateData(const App::Property* prop)
if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId()) {
Base::BoundBox3d bbox = static_cast<const Part::PropertyPartShape*>(prop)->getBoundingBox();
if (!bbox.IsValid()) return;
GridRoot->removeAllChildren();
Gui::coinRemoveAllChildren(GridRoot);
Base::Placement place = static_cast<const Part::PropertyPartShape*>(prop)->getComplexData()->getPlacement();
place.invert();
Base::ViewProjMatrix proj(place.toMatrix());
@@ -252,11 +252,11 @@ void ViewProvider2DObject::onChanged(const App::Property* prop)
if (ShowGrid.getValue())
createGrid();
else
GridRoot->removeAllChildren();
Gui::coinRemoveAllChildren(GridRoot);
}
if ((prop == &GridSize) || (prop == &GridStyle) || (prop == &TightGrid)) {
if (ShowGrid.getValue()) {
GridRoot->removeAllChildren();
Gui::coinRemoveAllChildren(GridRoot);
createGrid();
}
}

View File

@@ -118,8 +118,8 @@ void ViewProviderCurveNet::updateData(const App::Property* prop)
if (cShape.IsNull())
return;
EdgeRoot->removeAllChildren();
VertexRoot->removeAllChildren();
Gui::coinRemoveAllChildren(EdgeRoot);
Gui::coinRemoveAllChildren(VertexRoot);
try{
computeEdges (EdgeRoot,cShape);

View File

@@ -167,7 +167,7 @@ void ViewProviderMirror::unsetEdit(int ModNum)
mf->Normal.setValue(norm[0],norm[1],norm[2]);
pcRoot->removeChild(pcEditNode);
pcEditNode->removeAllChildren();
Gui::coinRemoveAllChildren(pcEditNode);
}
else {
ViewProviderPart::unsetEdit(ModNum);

View File

@@ -93,7 +93,7 @@ void ViewProviderSpline::updateData(const App::Property* prop)
if (prop->getTypeId() == Part::PropertyPartShape::getClassTypeId() && strcmp(prop->getName(), "Shape") == 0) {
// update control points if there
if (pcControlPoints) {
pcControlPoints->removeAllChildren();
Gui::coinRemoveAllChildren(pcControlPoints);
showControlPoints(this->ControlPoints.getValue(), prop);
}
}

View File

@@ -119,12 +119,12 @@ void ViewProviderTransformed::unsetEdit(int ModNum)
while (pcRejectedRoot->getNumChildren() > 7) {
SoSeparator* sep = static_cast<SoSeparator*>(pcRejectedRoot->getChild(7));
SoMultipleCopy* rejectedTrfms = static_cast<SoMultipleCopy*>(sep->getChild(2));
rejectedTrfms ->removeAllChildren();
Gui::coinRemoveAllChildren(rejectedTrfms);
sep->removeChild(1);
sep->removeChild(0);
pcRejectedRoot ->removeChild(7);
}
pcRejectedRoot->removeAllChildren();
Gui::coinRemoveAllChildren(pcRejectedRoot);
pcRoot->removeChild(pcRejectedRoot);
@@ -168,7 +168,7 @@ void ViewProviderTransformed::recomputeFeature(void)
while (pcRejectedRoot->getNumChildren() > 7) {
SoSeparator* sep = static_cast<SoSeparator*>(pcRejectedRoot->getChild(7));
SoMultipleCopy* rejectedTrfms = static_cast<SoMultipleCopy*>(sep->getChild(2));
rejectedTrfms ->removeAllChildren();
Gui::coinRemoveAllChildren(rejectedTrfms);
sep->removeChild(1);
sep->removeChild(0);
pcRejectedRoot ->removeChild(7);

View File

@@ -111,7 +111,7 @@ void ViewProviderRobotObject::setDragger()
void ViewProviderRobotObject::resetDragger()
{
assert(pcDragger);
pcTcpRoot->removeAllChildren();
Gui::coinRemoveAllChildren(pcTcpRoot);
pcDragger = 0;
}
@@ -181,7 +181,7 @@ void ViewProviderRobotObject::updateData(const App::Property* prop)
QString fn = QString::fromUtf8(filename);
QFile file(fn);
SoInput in;
pcRobotRoot->removeAllChildren();
Gui::coinRemoveAllChildren(pcRobotRoot);
if (!fn.isEmpty() && file.open(QFile::ReadOnly)) {
QByteArray buffer = file.readAll();
in.setBuffer((void *)buffer.constData(), buffer.length());

View File

@@ -3528,7 +3528,7 @@ void ViewProviderSketch::draw(bool temp /*=false*/, bool rebuildinformationlayer
// information layer
if(rebuildinformationlayer) {
// every time we start with empty information layer
edit->infoGroup->removeAllChildren();
Gui::coinRemoveAllChildren(edit->infoGroup);
}
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
@@ -4282,7 +4282,7 @@ void ViewProviderSketch::draw(bool temp /*=false*/, bool rebuildinformationlayer
if (ShowGrid.getValue())
createGrid();
else
GridRoot->removeAllChildren();
Gui::coinRemoveAllChildren(GridRoot);
edit->RootCrossCoordinate->point.set1Value(0,SbVec3f(-dMagF, 0.0f, zCross));
edit->RootCrossCoordinate->point.set1Value(1,SbVec3f(dMagF, 0.0f, zCross));
@@ -5297,7 +5297,7 @@ void ViewProviderSketch::rebuildConstraintsVisual(void)
{
const std::vector<Sketcher::Constraint *> &constrlist = getSketchObject()->Constraints.getValues();
// clean up
edit->constrGroup->removeAllChildren();
Gui::coinRemoveAllChildren(edit->constrGroup);
edit->vConstrType.clear();
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath("User parameter:BaseApp/Preferences/View");
@@ -6056,7 +6056,7 @@ void ViewProviderSketch::unsetEdit(int ModNum)
if (edit->sketchHandler)
deactivateHandler();
edit->EditRoot->removeAllChildren();
Gui::coinRemoveAllChildren(edit->EditRoot);
pcRoot->removeChild(edit->EditRoot);
//visibility autoation