Part: fix dangerous static_cast usage in view provider
Because Gui::ViewProviderLink can be used to override the view provider of any object, it is not safe to assume view provider type without explicit checking.
This commit is contained in:
@@ -111,15 +111,17 @@ void ViewProviderCompound::updateData(const App::Property* prop)
|
||||
TopTools_IndexedMapOfShape baseMap;
|
||||
TopExp::MapShapes(baseShape, TopAbs_FACE, baseMap);
|
||||
|
||||
Gui::ViewProvider* vpBase = Gui::Application::Instance->getViewProvider(objBase);
|
||||
std::vector<App::Color> baseCol = static_cast<PartGui::ViewProviderPart*>(vpBase)->DiffuseColor.getValues();
|
||||
applyTransparency(static_cast<PartGui::ViewProviderPart*>(vpBase)->Transparency.getValue(),baseCol);
|
||||
if (static_cast<int>(baseCol.size()) == baseMap.Extent()) {
|
||||
applyColor(hist[index], baseCol, compCol);
|
||||
}
|
||||
else if (!baseCol.empty() && baseCol[0] != this->ShapeColor.getValue()) {
|
||||
baseCol.resize(baseMap.Extent(), baseCol[0]);
|
||||
applyColor(hist[index], baseCol, compCol);
|
||||
auto vpBase = dynamic_cast<PartGui::ViewProviderPart*>(Gui::Application::Instance->getViewProvider(objBase));
|
||||
if (vpBase) {
|
||||
std::vector<App::Color> baseCol = vpBase->DiffuseColor.getValues();
|
||||
applyTransparency(vpBase->Transparency.getValue(),baseCol);
|
||||
if (static_cast<int>(baseCol.size()) == baseMap.Extent()) {
|
||||
applyColor(hist[index], baseCol, compCol);
|
||||
}
|
||||
else if (!baseCol.empty() && baseCol[0] != this->ShapeColor.getValue()) {
|
||||
baseCol.resize(baseMap.Extent(), baseCol[0]);
|
||||
applyColor(hist[index], baseCol, compCol);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user