reset highlighting of references if object is being deleted, fix crash with invalid sub-element names
This commit is contained in:
@@ -121,9 +121,11 @@ void ViewProviderFilling::highlightReferences(ShapeType type, const References&
|
||||
colors.resize(vMap.Extent(), svp->PointColor.getValue());
|
||||
|
||||
for (auto jt : it.second) {
|
||||
// check again that the index is in range because it's possible that the
|
||||
// sub-names are invalid
|
||||
std::size_t idx = static_cast<std::size_t>(std::stoi(jt.substr(6)) - 1);
|
||||
assert (idx < colors.size());
|
||||
colors[idx] = App::Color(1.0,0.0,1.0); // magenta
|
||||
if (idx < colors.size())
|
||||
colors[idx] = App::Color(1.0,0.0,1.0); // magenta
|
||||
}
|
||||
|
||||
svp->setHighlightedPoints(colors);
|
||||
@@ -141,8 +143,10 @@ void ViewProviderFilling::highlightReferences(ShapeType type, const References&
|
||||
|
||||
for (auto jt : it.second) {
|
||||
std::size_t idx = static_cast<std::size_t>(std::stoi(jt.substr(4)) - 1);
|
||||
assert (idx < colors.size());
|
||||
colors[idx] = App::Color(1.0,0.0,1.0); // magenta
|
||||
// check again that the index is in range because it's possible that the
|
||||
// sub-names are invalid
|
||||
if (idx < colors.size())
|
||||
colors[idx] = App::Color(1.0,0.0,1.0); // magenta
|
||||
}
|
||||
|
||||
svp->setHighlightedEdges(colors);
|
||||
@@ -160,8 +164,10 @@ void ViewProviderFilling::highlightReferences(ShapeType type, const References&
|
||||
|
||||
for (auto jt : it.second) {
|
||||
std::size_t idx = static_cast<std::size_t>(std::stoi(jt.substr(4)) - 1);
|
||||
assert (idx < colors.size());
|
||||
colors[idx] = App::Color(1.0,0.0,1.0); // magenta
|
||||
// check again that the index is in range because it's possible that the
|
||||
// sub-names are invalid
|
||||
if (idx < colors.size())
|
||||
colors[idx] = App::Color(1.0,0.0,1.0); // magenta
|
||||
}
|
||||
|
||||
svp->setHighlightedFaces(colors);
|
||||
@@ -399,6 +405,22 @@ void FillingPanel::slotRedoDocument(const Gui::Document&)
|
||||
checkCommand = true;
|
||||
}
|
||||
|
||||
void FillingPanel::slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj)
|
||||
{
|
||||
// If this view provider is being deleted then reset the colors of
|
||||
// referenced part objects. The dialog will be deleted later.
|
||||
if (this->vp == &Obj) {
|
||||
this->vp->highlightReferences(ViewProviderFilling::Edge,
|
||||
editedObject->BoundaryEdges.getSubListValues(), false);
|
||||
|
||||
// unhighlight the referenced face
|
||||
std::vector<App::PropertyLinkSubList::SubSet> links;
|
||||
links.push_back(std::make_pair(editedObject->InitialFace.getValue(),
|
||||
editedObject->InitialFace.getSubValues()));
|
||||
this->vp->highlightReferences(ViewProviderFilling::Face, links, false);
|
||||
}
|
||||
}
|
||||
|
||||
bool FillingPanel::accept()
|
||||
{
|
||||
selectionMode = None;
|
||||
@@ -716,6 +738,8 @@ void FillingPanel::onDeleteEdge()
|
||||
}
|
||||
this->vp->highlightReferences(ViewProviderFilling::Edge,
|
||||
editedObject->BoundaryEdges.getSubListValues(), true);
|
||||
|
||||
editedObject->recomputeFeature();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -760,6 +784,8 @@ void FillingPanel::on_buttonAccept_clicked()
|
||||
ui->comboBoxFaces->clear();
|
||||
ui->comboBoxCont->clear();
|
||||
ui->statusLabel->clear();
|
||||
|
||||
editedObject->recomputeFeature();
|
||||
}
|
||||
|
||||
void FillingPanel::on_buttonIgnore_clicked()
|
||||
@@ -818,6 +844,7 @@ void TaskFilling::setEditedObject(Surface::Filling* obj)
|
||||
void TaskFilling::open()
|
||||
{
|
||||
widget1->open();
|
||||
widget2->open();
|
||||
}
|
||||
|
||||
bool TaskFilling::accept()
|
||||
|
||||
@@ -87,6 +87,8 @@ protected:
|
||||
virtual void slotUndoDocument(const Gui::Document& Doc);
|
||||
/** Notifies on redo */
|
||||
virtual void slotRedoDocument(const Gui::Document& Doc);
|
||||
/** Notifies when the object is about to be removed. */
|
||||
virtual void slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj);
|
||||
void modifyBoundary(bool);
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
@@ -220,6 +220,16 @@ void FillingVertexPanel::slotRedoDocument(const Gui::Document&)
|
||||
checkCommand = true;
|
||||
}
|
||||
|
||||
void FillingVertexPanel::slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj)
|
||||
{
|
||||
// If this view provider is being deleted then reset the colors of
|
||||
// referenced part objects. The dialog will be deleted later.
|
||||
if (this->vp == &Obj) {
|
||||
this->vp->highlightReferences(ViewProviderFilling::Vertex,
|
||||
editedObject->Points.getSubListValues(), false);
|
||||
}
|
||||
}
|
||||
|
||||
void FillingVertexPanel::on_buttonVertexAdd_clicked()
|
||||
{
|
||||
// 'selectionMode' is passed by reference and changed when the filter is deleted
|
||||
|
||||
@@ -72,6 +72,8 @@ protected:
|
||||
virtual void slotUndoDocument(const Gui::Document& Doc);
|
||||
/** Notifies on redo */
|
||||
virtual void slotRedoDocument(const Gui::Document& Doc);
|
||||
/** Notifies when the object is about to be removed. */
|
||||
virtual void slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj);
|
||||
|
||||
private Q_SLOTS:
|
||||
void on_buttonVertexAdd_clicked();
|
||||
|
||||
@@ -297,9 +297,17 @@ void GeomFillSurface::slotRedoDocument(const Gui::Document&)
|
||||
checkCommand = true;
|
||||
}
|
||||
|
||||
void GeomFillSurface::slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj)
|
||||
{
|
||||
// If this view provider is being deleted then reset the colors of
|
||||
// referenced part objects. The dialog will be deleted later.
|
||||
if (this->vp == &Obj) {
|
||||
this->vp->highlightReferences(false);
|
||||
}
|
||||
}
|
||||
|
||||
bool GeomFillSurface::accept()
|
||||
{
|
||||
this->vp->highlightReferences(false);
|
||||
selectionMode = None;
|
||||
Gui::Selection().rmvSelectionGate();
|
||||
|
||||
@@ -325,6 +333,8 @@ bool GeomFillSurface::accept()
|
||||
return false;
|
||||
}
|
||||
|
||||
this->vp->highlightReferences(false);
|
||||
|
||||
Gui::Command::commitCommand();
|
||||
Gui::Command::doCommand(Gui::Command::Gui,"Gui.ActiveDocument.resetEdit()");
|
||||
Gui::Command::updateActive();
|
||||
|
||||
@@ -82,6 +82,8 @@ protected:
|
||||
virtual void slotUndoDocument(const Gui::Document& Doc);
|
||||
/** Notifies on redo */
|
||||
virtual void slotRedoDocument(const Gui::Document& Doc);
|
||||
/** Notifies when the object is about to be removed. */
|
||||
virtual void slotDeletedObject(const Gui::ViewProviderDocumentObject& Obj);
|
||||
void changeFillType(GeomFill_FillingStyle);
|
||||
|
||||
private Q_SLOTS:
|
||||
|
||||
Reference in New Issue
Block a user