fix possible crash in view provider of boolean algorithm features

This commit is contained in:
wmayer
2017-03-27 22:43:13 +02:00
parent 64754a655e
commit 7e9da5e957

View File

@@ -102,34 +102,36 @@ void ViewProviderBoolean::updateData(const App::Property* prop)
Gui::ViewProvider* vpBase = Gui::Application::Instance->getViewProvider(objBase);
Gui::ViewProvider* vpTool = Gui::Application::Instance->getViewProvider(objTool);
std::vector<App::Color> colBase = static_cast<PartGui::ViewProviderPart*>(vpBase)->DiffuseColor.getValues();
std::vector<App::Color> colTool = static_cast<PartGui::ViewProviderPart*>(vpTool)->DiffuseColor.getValues();
std::vector<App::Color> colBool;
colBool.resize(boolMap.Extent(), this->ShapeColor.getValue());
applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpBase)->Transparency.getValue(),colBase);
applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpTool)->Transparency.getValue(),colTool);
if (vpBase && vpTool) {
std::vector<App::Color> colBase = static_cast<PartGui::ViewProviderPart*>(vpBase)->DiffuseColor.getValues();
std::vector<App::Color> colTool = static_cast<PartGui::ViewProviderPart*>(vpTool)->DiffuseColor.getValues();
std::vector<App::Color> colBool;
colBool.resize(boolMap.Extent(), this->ShapeColor.getValue());
applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpBase)->Transparency.getValue(),colBase);
applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpTool)->Transparency.getValue(),colTool);
bool setColor=false;
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
applyColor(hist[0], colBase, colBool);
setColor = true;
bool setColor=false;
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
applyColor(hist[0], colBase, colBool);
setColor = true;
}
else if (!colBase.empty() && colBase[0] != this->ShapeColor.getValue()) {
colBase.resize(baseMap.Extent(), colBase[0]);
applyColor(hist[0], colBase, colBool);
setColor = true;
}
if (static_cast<int>(colTool.size()) == toolMap.Extent()) {
applyColor(hist[1], colTool, colBool);
setColor = true;
}
else if (!colTool.empty() && colTool[0] != this->ShapeColor.getValue()) {
colTool.resize(toolMap.Extent(), colTool[0]);
applyColor(hist[1], colTool, colBool);
setColor = true;
}
if (setColor)
this->DiffuseColor.setValues(colBool);
}
else if (!colBase.empty() && colBase[0] != this->ShapeColor.getValue()) {
colBase.resize(baseMap.Extent(), colBase[0]);
applyColor(hist[0], colBase, colBool);
setColor = true;
}
if (static_cast<int>(colTool.size()) == toolMap.Extent()) {
applyColor(hist[1], colTool, colBool);
setColor = true;
}
else if (!colTool.empty() && colTool[0] != this->ShapeColor.getValue()) {
colTool.resize(toolMap.Extent(), colTool[0]);
applyColor(hist[1], colTool, colBool);
setColor = true;
}
if (setColor)
this->DiffuseColor.setValues(colBool);
}
}
else if (prop->getTypeId() == App::PropertyLink::getClassTypeId()) {
@@ -204,16 +206,18 @@ void ViewProviderMultiFuse::updateData(const App::Property* prop)
TopExp::MapShapes(baseShape, TopAbs_FACE, baseMap);
Gui::ViewProvider* vpBase = Gui::Application::Instance->getViewProvider(objBase);
std::vector<App::Color> colBase = static_cast<PartGui::ViewProviderPart*>(vpBase)->DiffuseColor.getValues();
applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpBase)->Transparency.getValue(),colBase);
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
applyColor(hist[index], colBase, colBool);
setColor = true;
}
else if (!colBase.empty() && colBase[0] != this->ShapeColor.getValue()) {
colBase.resize(baseMap.Extent(), colBase[0]);
applyColor(hist[index], colBase, colBool);
setColor = true;
if (vpBase) {
std::vector<App::Color> colBase = static_cast<PartGui::ViewProviderPart*>(vpBase)->DiffuseColor.getValues();
applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpBase)->Transparency.getValue(),colBase);
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
applyColor(hist[index], colBase, colBool);
setColor = true;
}
else if (!colBase.empty() && colBase[0] != this->ShapeColor.getValue()) {
colBase.resize(baseMap.Extent(), colBase[0]);
applyColor(hist[index], colBase, colBool);
setColor = true;
}
}
}
@@ -334,16 +338,18 @@ void ViewProviderMultiCommon::updateData(const App::Property* prop)
TopExp::MapShapes(baseShape, TopAbs_FACE, baseMap);
Gui::ViewProvider* vpBase = Gui::Application::Instance->getViewProvider(objBase);
std::vector<App::Color> colBase = static_cast<PartGui::ViewProviderPart*>(vpBase)->DiffuseColor.getValues();
applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpBase)->Transparency.getValue(),colBase);
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
applyColor(hist[index], colBase, colBool);
setColor = true;
}
else if (!colBase.empty() && colBase[0] != this->ShapeColor.getValue()) {
colBase.resize(baseMap.Extent(), colBase[0]);
applyColor(hist[index], colBase, colBool);
setColor = true;
if (vpBase) {
std::vector<App::Color> colBase = static_cast<PartGui::ViewProviderPart*>(vpBase)->DiffuseColor.getValues();
applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpBase)->Transparency.getValue(),colBase);
if (static_cast<int>(colBase.size()) == baseMap.Extent()) {
applyColor(hist[index], colBase, colBool);
setColor = true;
}
else if (!colBase.empty() && colBase[0] != this->ShapeColor.getValue()) {
colBase.resize(baseMap.Extent(), colBase[0]);
applyColor(hist[index], colBase, colBool);
setColor = true;
}
}
}