diff --git a/src/Mod/Part/Gui/ViewProviderBoolean.cpp b/src/Mod/Part/Gui/ViewProviderBoolean.cpp index db5411bc96..d888e71043 100644 --- a/src/Mod/Part/Gui/ViewProviderBoolean.cpp +++ b/src/Mod/Part/Gui/ViewProviderBoolean.cpp @@ -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 colBase = static_cast(vpBase)->DiffuseColor.getValues(); - std::vector colTool = static_cast(vpTool)->DiffuseColor.getValues(); - std::vector colBool; - colBool.resize(boolMap.Extent(), this->ShapeColor.getValue()); - applyTransparency(static_cast(vpBase)->Transparency.getValue(),colBase); - applyTransparency(static_cast(vpTool)->Transparency.getValue(),colTool); + if (vpBase && vpTool) { + std::vector colBase = static_cast(vpBase)->DiffuseColor.getValues(); + std::vector colTool = static_cast(vpTool)->DiffuseColor.getValues(); + std::vector colBool; + colBool.resize(boolMap.Extent(), this->ShapeColor.getValue()); + applyTransparency(static_cast(vpBase)->Transparency.getValue(),colBase); + applyTransparency(static_cast(vpTool)->Transparency.getValue(),colTool); - bool setColor=false; - if (static_cast(colBase.size()) == baseMap.Extent()) { - applyColor(hist[0], colBase, colBool); - setColor = true; + bool setColor=false; + if (static_cast(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(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(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 colBase = static_cast(vpBase)->DiffuseColor.getValues(); - applyTransparency(static_cast(vpBase)->Transparency.getValue(),colBase); - if (static_cast(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 colBase = static_cast(vpBase)->DiffuseColor.getValues(); + applyTransparency(static_cast(vpBase)->Transparency.getValue(),colBase); + if (static_cast(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 colBase = static_cast(vpBase)->DiffuseColor.getValues(); - applyTransparency(static_cast(vpBase)->Transparency.getValue(),colBase); - if (static_cast(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 colBase = static_cast(vpBase)->DiffuseColor.getValues(); + applyTransparency(static_cast(vpBase)->Transparency.getValue(),colBase); + if (static_cast(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; + } } }